Skip to content

Commit

Permalink
Add disk.Filetype, and move notes.org to lib
Browse files Browse the repository at this point in the history
  • Loading branch information
zellyn committed Nov 16, 2016
1 parent 2cf6d2d commit ff196d4
Show file tree
Hide file tree
Showing 4 changed files with 118 additions and 32 deletions.
22 changes: 0 additions & 22 deletions lib/applesoft/notes.org

This file was deleted.

50 changes: 50 additions & 0 deletions lib/disk/ops.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,62 @@ import (
"strings"
)

// Filetype describes the type of a file. It's byte-compatible with
// the ProDOS/SOS filetype byte definitions in the range 00-FF.
type Filetype int

const (
FiletypeTypeless Filetype = 0x00 // | both | Typeless file
FiletypeBadBlocks Filetype = 0x01 // | both | Bad blocks file
FiletypeSOSPascalCode Filetype = 0x02 // | SOS | PASCAL code file
FiletypeSOSPascalText Filetype = 0x03 // | SOS | PASCAL text file
FiletypeASCIIText Filetype = 0x04 // TXT | both | ASCII text fil
FiletypeSOSPascalText2 Filetype = 0x05 // | SOS | PASCAL text file
FiletypeBinary Filetype = 0x06 // BIN | both | Binary file
FiletypeFont Filetype = 0x07 // | SOS | Font file
FiletypeGraphicsScreen Filetype = 0x08 // | SOS | Graphics screen file
FiletypeBusinessBASIC Filetype = 0x09 // | SOS | Business BASIC program file
FiletypeBusinessBASICData Filetype = 0x0A // | SOS | Business BASIC data file
FiletypeSOSWordProcessor Filetype = 0x0B // | SOS | Word processor file
FiletypeSOSSystem Filetype = 0x0C // | SOS | SOS system file
FiletypeDirectory Filetype = 0x0F // DIR | both | Directory file
FiletypeRPSData Filetype = 0x10 // | SOS | RPS data file
FiletypeRPSIndex Filetype = 0x11 // | SOS | RPS index file
FiletypeAppleWorksDatabase Filetype = 0x19 // ADB | ProDOS | AppleWorks data base file
FiletypeAppleWorksWordProcessor Filetype = 0x1A // AWP | ProDOS | AppleWorks word processing file
FiletypeAppleWorksSpreadsheet Filetype = 0x1B // ASP | ProDOS | AppleWorks spreadsheet file
FiletypePascal Filetype = 0xEF // PAS | ProDOS | ProDOS PASCAL file
FiletypeCommand Filetype = 0xF0 // CMD | ProDOS | Added command file
FiletypeUserDefinedF1 Filetype = 0xF1 // | ProDOS | ProDOS user defined file types
FiletypeUserDefinedF2 Filetype = 0xF2 // | ProDOS | ProDOS user defined file types
FiletypeUserDefinedF3 Filetype = 0xF3 // | ProDOS | ProDOS user defined file types
FiletypeUserDefinedF4 Filetype = 0xF4 // | ProDOS | ProDOS user defined file types
FiletypeUserDefinedF5 Filetype = 0xF5 // | ProDOS | ProDOS user defined file types
FiletypeUserDefinedF6 Filetype = 0xF6 // | ProDOS | ProDOS user defined file types
FiletypeUserDefinedF7 Filetype = 0xF7 // | ProDOS | ProDOS user defined file types
FiletypeUserDefinedF8 Filetype = 0xF8 // | ProDOS | ProDOS user defined file types
FiletypeIntegerBASIC Filetype = 0xFA // INT | ProDOS | Integer BASIC program file
FiletypeIntegerBASICVariables Filetype = 0xFB // IVR | ProDOS | Integer BASIC variables file
FiletypeApplesoftBASIC Filetype = 0xFC // BAS | ProDOS | Applesoft BASIC program file
FiletypeApplesoftBASICVariables Filetype = 0xFD // VAR | ProDOS | Applesoft BASIC variables file
FiletypeRelocatable Filetype = 0xFE // REL | ProDOS | EDASM relocatable object module file
FiletypeSystem Filetype = 0xFF // SYS | ProDOS | System file
FiletypeS Filetype = 0x100 // DOS 3.3 Type "S"
FiletypeA Filetype = 0x101 // DOS 3.3 Type "A"
FiletypeB Filetype = 0x102 // DOS 3.3 Type "B"
// | 0D-0E | SOS | SOS reserved for future use
// | 12-18 | SOS | SOS reserved for future use
// | 1C-BF | SOS | SOS reserved for future use
// | C0-EE | ProDOS | ProDOS reserved for future use
)

// Descriptor describes a file's characteristics.
type Descriptor struct {
Name string
Sectors int
Length int
Locked bool
Type Filetype
}

// Operator is the interface that can operate on disks.
Expand Down
21 changes: 11 additions & 10 deletions lib/dos33/dos33.go
Original file line number Diff line number Diff line change
Expand Up @@ -249,21 +249,22 @@ func (cs *CatalogSector) FromSector(data []byte) error {
return nil
}

// Filetype is the type for dos 3.3 filetype+locked status byte.
type Filetype byte

const (
// Hex 80+file type - file is locked
// Hex 00+file type - file is not locked
// Hex 80+file type - file is locked,
// Hex 00+file type - file is not locked.
FiletypeLocked Filetype = 0x80

FileTypeText Filetype = 0x00 // Text file
FileTypeInteger Filetype = 0x01 // INTEGER BASIC file
FileTypeApplesoft Filetype = 0x02 // APPLESOFT BASIC file
FileTypeBinary Filetype = 0x04 // BINARY file
FileTypeS Filetype = 0x08 // S type file
FileTypeRelocatable Filetype = 0x10 // RELOCATABLE object module file
FileTypeA Filetype = 0x20 // A type file
FileTypeB Filetype = 0x40 // B type file
FiletypeText Filetype = 0x00 // Text file
FiletypeInteger Filetype = 0x01 // INTEGER BASIC file
FiletypeApplesoft Filetype = 0x02 // APPLESOFT BASIC file
FiletypeBinary Filetype = 0x04 // BINARY file
FiletypeS Filetype = 0x08 // S type file
FiletypeRelocatable Filetype = 0x10 // RELOCATABLE object module file
FiletypeA Filetype = 0x20 // A type file
FiletypeB Filetype = 0x40 // B type file
)

type FileDescStatus int
Expand Down
57 changes: 57 additions & 0 deletions lib/notes.org
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
** Program location
Defaults to $801 for ROM-based Applesoft. Locations $67/$68 point to
the start of the program, and the byte preceding it must be #0.

Details:
- http://www.atarimagazines.com/compute/issue11/36_1_THE_APPLE_GAZETTE_RESOLVING_APPLESOFT_AND_HIRES_GRAPHICS_MEMORY_CONFLICTS.php
- http://retrocomputing.stackexchange.com/questions/1604

** Format
DOS stores an additional byte on the end, which should be ignored.
** Parsing
See PARSE.INPUT.LINE at
http://www.txbobsc.com/scsc/scdocumentor/D52C.html

"AT" is ambiguous: it could also be "ATN" or "A TO". Applesoft checks
by seeing if the character directly after "AT" is "N" OR "O", and
forcing a non-match with "AT" if so. Note that this doesn't skip
blanks.

Data statements and REM statements seem to leave characters completely
intact (including storing the space, if any, after the "REM" or "DATA"
keyword).
** ProDOS and SOS File Types
Beneath Apple ProDOS Table E.1

| 00 | | both | Typeless file |
| 01 | | both | Bad blocks file |
| 02 | | SOS | PASCAL code file |
| 03 | | SOS | PASCAL text file |
| 04 | TXT | both | ASCII text fil |
| 05 | | SOS | PASCAL text file |
| 06 | BIN | both | Binary file |
| 07 | | SOS | Font file |
| 08 | | SOS | Graphics screen file |
| 09 | | SOS | Business BASIC program file |
| 0A | | SOS | Business BASIC data file |
| 0B | | SOS | Word processor file |
| 0C | | SOS | SOS system file |
| 0D-0E | | SOS | SOS reserved for future use |
| 0F | DIR | both | Directory file |
| 10 | | SOS | RPS data file |
| 11 | | SOS | RPS index file |
| 12-18 | | SOS | SOS reserved for future use |
| 19 | ADB | ProDOS | AppleWorks data base file |
| 1A | AWP | ProDOS | AppleWorks word processing file |
| 1B | ASP | ProDOS | AppleWorks spreadsheet file |
| 1C-BF | | SOS | SOS reserved for future use |
| C0-EE | | ProDOS | ProDOS reserved for future use |
| EF | PAS | ProDOS | ProDOS PASCAL file |
| F0 | CMD | ProDOS | Added command file |
| F1-F8 | | ProDOS | ProDOS user defined file types |
| FA | INT | ProDOS | Integer BASIC program file |
| FB | IVR | ProDOS | Integer BASIC variables file |
| FC | BAS | ProDOS | Applesoft BASIC program file |
| FD | VAR | ProDOS | Applesoft BASIC variables file |
| FE | REL | ProDOS | EDASM relocatable object module file |
| FF | SYS | ProDOS | System file |

0 comments on commit ff196d4

Please sign in to comment.