Skip to content

Commit

Permalink
add a couple disks
Browse files Browse the repository at this point in the history
  • Loading branch information
zellyn committed Jul 11, 2021
1 parent f09e8f4 commit 9c66e2c
Show file tree
Hide file tree
Showing 51 changed files with 1,474 additions and 1,218 deletions.
9 changes: 9 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"filewatcher.commands": [
{
"match": "\\.go",
"cmd": "echo '${file} changed'",
"event": "onFileChange",
},
]
}
57 changes: 53 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ Discussion/support is in
[#apple2 on the retrocomputing Slack](https://retrocomputing.slack.com/messages/apple2/)
(invites [here](https://retrocomputing.herokuapp.com)).

### Goals
# Goals

Eventually, it aims to be a comprehensive disk image manipulation
tool, but for now only some parts work.
Expand All @@ -59,7 +59,7 @@ Current disk operations supported:
| init ||||
| defrag ||||

### Installing/updating
# Installing/updating
Assuming you have Go installed, run `go get -u github.com/zellyn/diskii`

You can also download automatically-built binaries from the
Expand All @@ -68,7 +68,7 @@ page](https://github.com/zellyn/diskii/releases/latest). If you
need binaries for a different architecture, please send a pull
request or open an issue.

### Short-term TODOs/roadmap/easy ways to contribute
# Short-term TODOs/roadmap/easy ways to contribute

My rough TODO list (apart from anything marked (✗) in the disk
operations matrix is listed below. Anything that an actual user needs
Expand All @@ -86,7 +86,7 @@ will be likely to get priority.
- [ ] Add basic ProDOS structures
- [ ] Add ProDOS support

### Related tools
# Related tools

- http://a2ciderpress.com/ - the great grandaddy of them all. Windows only, unless you Wine
- http://retrocomputingaustralia.com/rca-downloads/ Michael Mulhern's MacOS package of CiderPress
Expand All @@ -107,3 +107,52 @@ will be likely to get priority.
- https://github.com/slotek/apple2-disk-util - ruby
- https://github.com/slotek/dsk2nib - C
- https://github.com/robmcmullen/atrcopy - dos3.3, python

# Notes

## Disk formats

- `.do`
- `.po`
- `.dsk` - could be DO or PO.

DOS 3.2.1: the 13 sectors are physically skewed on disk.

DOS 3.3+: the 16 physical sectors are stored in ascending order on disk, not physically skewed at all. The


| Logical Sector | DOS 3.3 Physical Sector | ProDOS Physical Sector |
| --------------- | -------------- | ------------- |
| 0 | 0 | x |
| 1 | D | x |
| 2 | B | x |
| 3 | 9 | x |
| 4 | 7 | x |
| 5 | 5 | x |
| 6 | 3 | x |
| 7 | 1 | x |
| 8 | E | x |
| 9 | C | x |
| A | A | x |
| B | 8 | x |
| C | 6 | x |
| D | 4 | x |
| E | 2 | x |
| F | F | x |

### RWTS - DOS

Sector mapping:
http://www.textfiles.com/apple/ANATOMY/rwts.s.txt and search for INTRLEAV

Mapping from specified sector to physical sector (the reverse of what the comment says):

`00 0D 0B 09 07 05 03 01 0E 0C 0A 08 06 04 02 0F`

So if you write to "T0S1" with DOS RWTS, it ends up in physical sector 0D.

## Commandline examples for thinking about how it should work

diskii ls dos33.dsk
diskii --order=do ls dos33.dsk
diskii --order=do --system=nakedos ls nakedos.dsk
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ package applesoft
import (
"testing"

"github.com/zellyn/diskii/lib/basic"
"github.com/zellyn/diskii/basic"
)

// helloBinary is a simple basic program used for testing. Listing
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ package integer
import (
"testing"

"github.com/zellyn/diskii/lib/basic"
"github.com/zellyn/diskii/basic"
)

// helloBinary is a simple basic program used for testing. Listing
Expand Down
57 changes: 57 additions & 0 deletions build
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
#!/usr/bin/env bash
set -euo pipefail
export ACME="$HOME/gh/acme/ACME_Lib"
ACME_BIN="$HOME/gh/acme/acme"


$ACME_BIN -o writetest.o -r writetest.lst writetest.asm

# cp data/disks/dos33mst.dsk writetest.dsk
# diskii put -f writetest.dsk writetest writetest.o

# Also run mame? (set MAMEDIR and MAMEBIN to your local variant)
[[ -z "${MAMEDIR-}" ]] && MAMEDIR="/Users/zellyn/Library/Application Support/Ample"
[[ -z "${MAMEBIN-}" ]] && MAMEBIN="/Applications/Ample.app/Contents/MacOS/mame64"

# Write audit.o into an OpenEmulator config?
[[ -z "${TMPLS-}" ]] && TMPLS=~/gh/OpenEmulator-OSX/modules/libemulation/res/templates

DSK=$(realpath ./audit.dsk)

case "${1-none}" in
"2ee")
# mame64 apple2ee -skip_gameinfo -nosamples -window -resolution 1120x840 -flop1 /Users/zellyn/gh/a2audit/audit/audit.dsk
(cd "$MAMEDIR"; "$MAMEBIN" apple2ee -window -flop1 "$DSK" -skip_gameinfo)
;;
"2e")
(cd "$MAMEDIR"; "$MAMEBIN" apple2e -window -flop1 "$DSK" -skip_gameinfo)
;;
"2p")
(cd "$MAMEDIR"; "$MAMEBIN" apple2p -window -flop1 "$DSK" -skip_gameinfo)
;;
"2")
(cd "$MAMEDIR"; "$MAMEBIN" apple2 -window -flop1 "$DSK" -skip_gameinfo)
;;
"2ee-d")
(cd "$MAMEDIR"; "$MAMEBIN" apple2ee -window -flop1 "$DSK" -skip_gameinfo -debug)
;;
"2e-d")
(cd "$MAMEDIR"; "$MAMEBIN" apple2e -window -flop1 "$DSK" -skip_gameinfo -debug)
;;
"2p-d")
(cd "$MAMEDIR"; "$MAMEBIN" apple2p -window -flop1 "$DSK" -skip_gameinfo -debug)
;;
"2-d")
(cd "$MAMEDIR"; "$MAMEBIN" apple2 -window -flop1 "$DSK" -skip_gameinfo -debug)
;;
"oe")
(head -c 24576 /dev/zero; cat audit.o; head -c 65536 /dev/zero) | head -c 65536 > $TMPLS/Apple\ II/Apple\ IIe-test.emulation/appleIIe.mainRam.bin
sed -e 's|<property name="pc" value="0x...."/>|<property name="pc" value="0x6000"/>|' $TMPLS/Apple\ II/Apple\ IIe.xml > $TMPLS/Apple\ II/Apple\ IIe-test.emulation/info.xml
;;
"none")
;;
*)
echo Options: 2ee, 2e, 2p, 2, 2ee-d, 2e-d, 2p-d, 2-d
esac

true # Signal success (since we had a bunch of conditionals that can return false status).
6 changes: 3 additions & 3 deletions cmd/applesoft.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ import (
"os"

"github.com/spf13/cobra"
"github.com/zellyn/diskii/lib/basic"
"github.com/zellyn/diskii/lib/basic/applesoft"
"github.com/zellyn/diskii/lib/helpers"
"github.com/zellyn/diskii/basic"
"github.com/zellyn/diskii/basic/applesoft"
"github.com/zellyn/diskii/helpers"
)

// applesoftCmd represents the applesoft command
Expand Down
46 changes: 13 additions & 33 deletions cmd/catalog.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,54 +6,34 @@ import (
"fmt"
"os"

"github.com/spf13/cobra"
"github.com/zellyn/diskii/lib/disk"
"github.com/zellyn/diskii/disk"
"github.com/zellyn/diskii/types"
)

var shortnames bool // flag for whether to print short filenames
var debug bool

// catalogCmd represents the cat command, used to catalog a disk or
// directory.
var catalogCmd = &cobra.Command{
Use: "catalog",
Aliases: []string{"cat", "ls"},
Short: "print a list of files",
Long: `Catalog a disk or subdirectory.`,
Run: func(cmd *cobra.Command, args []string) {
if err := runCat(args); err != nil {
fmt.Fprintln(os.Stderr, err.Error())
os.Exit(-1)
}
},
}

func init() {
RootCmd.AddCommand(catalogCmd)
catalogCmd.Flags().BoolVarP(&shortnames, "shortnames", "s", false, "whether to print short filenames (only makes a difference on Super-Mon disks)")
catalogCmd.Flags().BoolVarP(&debug, "debug", "d", false, "pring debug information")
type LsCmd struct {
ShortNames bool `kong:"short='s',help='Whether to print short filenames (only makes a difference on Super-Mon disks).'"`
Image *os.File `kong:"arg,required,help='Disk/device image to read.'"`
Directory string `kong:"arg,optional,help='Directory to list (ProDOS only).'"`
}

// runCat performs the actual catalog logic.
func runCat(args []string) error {
if len(args) < 1 || len(args) > 2 {
return fmt.Errorf("cat expects a disk image filename, and an optional subdirectory")
}
op, err := disk.Open(args[0])
func (l *LsCmd) Run(globals *types.Globals) error {
op, order, err := disk.OpenImage(l.Image, globals)
if err != nil {
return err
}
if debug {
fmt.Printf("Got disk of type %q with underlying sector/block order %q.\n", op.Name(), op.Order())
if globals.Debug {
fmt.Fprintf(os.Stderr, "Opened disk with order %q, system %q\n", order, op.Name())
}
subdir := ""
if len(args) == 2 {

if l.Directory != "" {
if !op.HasSubdirs() {
return fmt.Errorf("Disks of type %q cannot have subdirectories", op.Name())
}
subdir = args[1]
}
fds, err := op.Catalog(subdir)
fds, err := op.Catalog(l.Directory)
if err != nil {
return err
}
Expand Down
10 changes: 2 additions & 8 deletions cmd/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,7 @@

package cmd

import (
"fmt"
"os"

"github.com/spf13/cobra"
"github.com/zellyn/diskii/lib/disk"
)

/*
var missingok bool // flag for whether to consider deleting a nonexistent file okay
// deleteCmd represents the delete command, used to delete a file.
Expand Down Expand Up @@ -62,3 +55,4 @@ func runDelete(args []string) error {
}
return nil
}
*/
10 changes: 2 additions & 8 deletions cmd/dump.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,7 @@

package cmd

import (
"fmt"
"os"

"github.com/spf13/cobra"
"github.com/zellyn/diskii/lib/disk"
)

/*
// dumpCmd represents the dump command, used to dump the raw contents
// of a file.
var dumpCmd = &cobra.Command{
Expand Down Expand Up @@ -48,3 +41,4 @@ func runDump(args []string) error {
os.Stdout.Write(file.Data)
return nil
}
*/
4 changes: 2 additions & 2 deletions cmd/filetypes.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"os"

"github.com/spf13/cobra"
"github.com/zellyn/diskii/lib/disk"
"github.com/zellyn/diskii/types"
)

var all bool // flag for whether to show all filetypes
Expand Down Expand Up @@ -36,7 +36,7 @@ func runFiletypes(args []string) error {
if len(args) != 0 {
return fmt.Errorf("filetypes expects no arguments")
}
for _, typ := range disk.FiletypeNames(all) {
for _, typ := range types.FiletypeNames(all) {
fmt.Println(typ)
}
return nil
Expand Down
11 changes: 2 additions & 9 deletions cmd/nakedos.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,7 @@

package cmd

import (
"fmt"
"os"

"github.com/spf13/cobra"
"github.com/zellyn/diskii/lib/disk"
"github.com/zellyn/diskii/lib/supermon"
)

/*
// nakedosCmd represents the nakedos command
var nakedosCmd = &cobra.Command{
Use: "nakedos",
Expand Down Expand Up @@ -123,3 +115,4 @@ func runMkhello(args []string) error {
}
return nil
}
*/
11 changes: 2 additions & 9 deletions cmd/put.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,7 @@

package cmd

import (
"fmt"
"os"

"github.com/spf13/cobra"
"github.com/zellyn/diskii/lib/disk"
"github.com/zellyn/diskii/lib/helpers"
)

/*
var filetypeName string // flag for file type
var overwrite bool // flag for whether to overwrite
Expand Down Expand Up @@ -81,3 +73,4 @@ func runPut(args []string) error {
}
return nil
}
*/
Loading

0 comments on commit 9c66e2c

Please sign in to comment.