Jump to content
IGNORED

Simple Linux bash shell script to create "romlist.txt" for RetroHQ Lynx SD Cartridge


billkendrick

Recommended Posts

So I've got 3 Lynxes now, while I've now got two of the new RetroHQ Lynx GameDrives, I also still have the original Lynx SD Cart.  It works a bit differently, and I'm finally setting it up 'nicely' for my family to hopefully enjoy some 3-player games with me. :)

 

I finally noticed the "romlist.txt" feature in the new menu update that came out last year (see https://atarigamer.com/articles/introducing-lynx-sd-menu-loader-version-2), and decided I'd take advantage of it.  Seeing "FOOBAR~1.LNX" on the screen was a bit annoying and confusing and reminded me of the horrible days when I was using Windows in the late 1990s. :)

 

But rather than just sit down and create some those text files by hand (and have to update them by hand whenever I add new games, or shuffle/organize ROMs into subdirectories), I created a little Bash shell script for Linux that can create such a file, given a list of ".lnx" files on the command-line.

 

Usage would be something like "/path/to/make_romlist.sh *.lnx > romlist.txt"

 

It's not going to be perfect, but I struggled to find any kind of tool to help with this process.  The closest I found was "mshortname" from "mtools", but it's really focused on reading a floppy disk (A: drive aka /dev/fd0 ?).  For example, my regular expressions for valid characters may be off.  And while most disallowed characters convert to "_", spaces just go away. (So "Super Offroad.lnx" must become "SUPERO~1.LNX", not "SUPER ~1.LNX".)  And it assumes there'll be no clashes (how would we even figure which is which!?), e.g., "FILENA~1.LNX" vs "FILENA~2.LNX".

 

So, YMMV. Feel free to improve it, and post your updates to this thread!

 

Here's example output when I ran it on a directory of LNX files:

kendrick@gambit:~/Lynx/sdcard_files_20201127$ rm romlist.txt ; ../make_romlist.sh *.lnx > romlist.txt 
rm: remove regular file 'romlist.txt'? y
Shortening 'Assembloids' to 'Assemb~1'

Shortening 'BattleZone2000' to 'Battle~1'

Ignoring 'BlockOut'; it's already short...

Cleaning 'Electrocop (USA, Europe)' to 'Electrocop_USA_Europe_'...
...shortening to 'Electr~1'

Shortening 'GrowingTies' to 'Growin~1'

Cleaning 'Hard Drivin' (USA, Europe)' to 'HardDrivin'_USA_Europe_'...
...shortening to 'HardDr~1'

Cleaning 'Lemmings (USA, Europe)' to 'Lemmings_USA_Europe_'...
...shortening to 'Lemmin~1'

Shortening 'SuperMissileCommand' to 'SuperM~1'

kendrick@gambit:~/Lynx/sdcard_files_20201127$ cat romlist.txt 
[Assemb~1.lnx]Assembloids
[Battle~1.lnx]BattleZone2000
[Electr~1.lnx]Electrocop (USA, Europe)
[Growin~1.lnx]GrowingTies
[HardDr~1.lnx]Hard Drivin' (USA, Europe)
[Lemmin~1.lnx]Lemmings (USA, Europe)
[SuperM~1.lnx]SuperMissileCommand

 

And here's the script itself:

#!/bin/bash

# make_romlist.sh
#
# Output content you can place in a 'romlist.txt' file on
# an SD card used in a RetroHQ Lynx SD Cartridge (original
# model, using new Lynx SD Menu 2, from March 2019; see
# https://atarigamer.com/articles/introducing-lynx-sd-menu-loader-version-2)
#
# By Bill Kendrick <bill@newbreedsoftware.com>
# 2020-11-27 - 2020-11-27
#
# As seen in the README.md for Lynx SD Menu 2
# (the a menu system for loading Atari Lynx ROMs via the Lynx SD Cartridge.
# Redesigned and updated by Atari Gamer.):
#
#   [...]
#   By placing a file called romlist.txt in a directory you can specify long ROM
#   names for each of the 8.3 DOS file names. An example file is like so... 
#   [gateszen.lnx]Gates of Zendocon
#   [alien.lnx]Alien vs Predator
#   [apb.lnx]All Points Bulletin
#   [awegolf.lnx]Awesome Golf
#
#   Note that the short DOS (8.3) file name is in square brackets, followed by the long
#   ROM name. Maximum length for a ROM name is 45 characters. 
#   The DOS (8.3) names could be in the form romnam~1.lnx. [...]

OIFS="$IFS"
IFS='|'

vfat="A-Za-z0-9_'-"

for lfn in $@; do
  base=`basename $lfn .lnx`
  len=${#base}
  if [[ $base =~ ^[$vfat]+$ ]]; then
    if [ $len -gt 8 ]; then
      sfn=${base:0:6}~1
      echo "Shortening '$base' to '$sfn'" 1>&2
      echo "[$sfn.lnx]$base"
    else
      echo "Ignoring '$base'; it's already short..." 1>&2
    fi
  else
    clean=`echo "$base" | tr -d " " | sed -e "s/[^$vfat]/_/g"`
    echo "Cleaning '$base' to '$clean'..." 1>&2
    sfn=${clean:0:6}~1
    echo "...shortening to '$sfn'" 1>&2
    echo "[$sfn.lnx]$base"
  fi
  echo 1>&2
done

IFS="$OIFS"

Enjoy!

  • Like 1
Link to comment
Share on other sites

Very cool!  It is a pain to generate and update the rom list file thingey, and I've wondered myself what it would take to generate something like this.  However, I'm still mostly computer illiterate, so I wouldn't have the slightest clue how to use this.  But I'm sure plenty of others will benefit from it. 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...