From 38266ee8a29a66a02e632512698ce6b8cb1bbf04 Mon Sep 17 00:00:00 2001 From: Greg Gauthier Date: Wed, 22 Jan 2025 19:39:44 +0000 Subject: [PATCH] add readme and floppy scripts --- README.md | 16 ++++++++++++ util/floppy-attach | 64 ++++++++++++++++++++++++++++++++++++++++++++++ util/floppy-burn | 11 ++++++++ util/floppy-make | 27 +++++++++++++++++++ 4 files changed, 118 insertions(+) create mode 100644 README.md create mode 100755 util/floppy-attach create mode 100755 util/floppy-burn create mode 100755 util/floppy-make diff --git a/README.md b/README.md new file mode 100644 index 0000000..53ad935 --- /dev/null +++ b/README.md @@ -0,0 +1,16 @@ +# My MartyPC Setup + +If you want to use this as your own, clone it into a location of your choosing, then edit the `martypc.toml` to change the base directory (on line 153), to the location where you cloned it: + +```toml +basedir = "/home/gmgauthier/Retro/marty" +``` + +Then, to run the emulator, enter: + +```bash +$ ./martypc --configfile ./martypc.toml +``` + +Virtual harddisk and floppy images are found in the `media/` directory. The `util/` directory contains some helpful shell scripts for creating floppy images. You will need to customize the scripts to point to the filepath where you want to store/read disks. + diff --git a/util/floppy-attach b/util/floppy-attach new file mode 100755 index 0000000..4ede53a --- /dev/null +++ b/util/floppy-attach @@ -0,0 +1,64 @@ +#!/usr/bin/env bash + +### +# This will mount an existing floppy disk image on a loop device +# Or, it will create a disk image, and then mount it on a loop device +### + +MEDIADIR="/media/gmgauthier" +format=0 # Don't format disk images that already exist + +# get name of freshly created blank disk, or create one +if [ $# -eq 0 ]; then + echo ">>> NEW 1.44MB DISK IS BEING CREATED..." + PREFIX="floppy" + RANDO=$(od -An -N4 -i < /dev/urandom|sed 's/[ -]//g') + DISK="$PREFIX$RANDO" + dd if=/dev/zero of=$DISK.img bs=1k count=1440 + format=1 +else + DISK=$1 + if [ $# -eq 1 ]; then + echo "Second argument should be disk size in kbytes: 360, 720, 1440" + exit 1 + fi + SIZE=$2 + if ! [ -f $DISK.img ]; then + dd if=/dev/zero of=$DISK.img bs=1k count=$SIZE + format=1 + fi +fi + +# Find the next available loop device on the system +echo ">>> LOOP DEVICE IS BEING IDENTIFIED..." +list=$(losetup -O name|sed 's/\/dev\/loop//g'|sed 's/NAME//g'|sort - --sort=human-numeric) +### listarr=(${(@s: :)list}) # zsh version of the array generator +listarr=($(echo $list | tr " " "\n")) #bash version of array generator +lastdev=${listarr[-1]} +lastdevnum=$((lastdev)) +nextdev=$((lastdevnum+1)) + +# allocate the next available loop device, format the disk, and mount it. +nextdevname="/dev/loop$nextdev" +echo ">>> LOOP DEVICE $nextdevname RESERVED FOR DISK: $DISK.img" + +sudo losetup $nextdevname $DISK.img + +if [ $format -eq 1 ]; then + echo ">>> DISK IMAGE IS RAW AND WILL BE FORMATTED" + sudo mkfs -t vfat $nextdevname +fi + +if ! [ -d $MEDIADIR/$DISK ]; then + echo ">>> MOUNT DIRECTORY NOT FOUND. CREATING DIRECTORY NOW." + sudo mkdir $MEDIADIR/$DISK +fi + +echo ">>> DISK $DISK.img MOUNTING AT LOCATION: $MEDIADIR/$DISK" +sudo mount $DISK.img $MEDIADIR/$DISK + +if [ $format -eq 1 ]; then + echo ">>> DISK INFORMATION BEING COPIED TO $DISK.img" + sudo fdisk -l $nextdevname >> $DISK-fdisk.txt + sudo cp $DISK-fdisk.txt $MEDIADIR/$DISK/$DISK.txt && rm $DISK-fdisk.txt +fi diff --git a/util/floppy-burn b/util/floppy-burn new file mode 100755 index 0000000..988d622 --- /dev/null +++ b/util/floppy-burn @@ -0,0 +1,11 @@ +#!/usr/bin/env bash + +### +# This will burn a floppy.img file to an actual physical 3.5" disk +### +if [[ $# -ne 1 ]]; then + echo "Supply the disk image filepath to burn to disk" + exit 1 +fi + +sudo dd if="$1" of=/dev/sda bs=512 conv=sync ; sync diff --git a/util/floppy-make b/util/floppy-make new file mode 100755 index 0000000..6d09eb9 --- /dev/null +++ b/util/floppy-make @@ -0,0 +1,27 @@ +#!/usr/bin/env bash + +### +# This will create a new 1.44mb floppy disk image +### + +DISKDIR="/home/gmgauthier/Retro/BLANKS" + +# get name of freshly created blank disk, or create one +if [ $# -eq 0 ]; then + echo ">>> NEW 1.44MB DISK IS BEING CREATED..." + PREFIX="floppy" + RANDO=$(od -An -N4 -i < /dev/urandom|sed 's/[ -]//g') + DISK="$PREFIX$RANDO" + dd if=/dev/zero of=$DISKDIR/$DISK.img bs=1k count=1440 +else + DISK=$1 + if [ $# -eq 1 ]; then + echo "Second argument should be disk size in kbytes: 360, 720, 1440" + exit 1 + fi + SIZE=$2 + if ! [ -f $DISK.img ]; then + dd if=/dev/zero of=$DISKDIR/$DISK.img bs=1k count=$SIZE + fi +fi +