Example #1
0
class D64_Description(DiskDescription):
    """Describe the 1541 disk geometry and related CBM-DOS version."""

    _SECTOR_COUNTS = (
        # (starting track, ending track, sectors in this track group)
        (0, 0, 0),
        (1, 17, 21),
        (18, 24, 19),
        (25, 30, 18),
        (31, 35, 17))

    DIRECTORY_HEADER = (18, 0)
    DIRECTORY_ENTRIES = (18, 1)

    STRUCT_HEADER = struct_doc('''
<       # Little-endian
xx      # Track/sector of first directory block; should always be 18/1 for normal disks
x       # 'A' (representing "4040 format".)
x       # 0 ("Null flag for future DOS use.")
140x    # Block Allocation Map (BAM)
16s     # Disk name, PET-ASCII, $A0 padded
xx      # Two shift-spaces
2s      # Disk ID
x       # $A0
xx      # '2A' (DOS version and format type.)
xxxx    # Shifted spaces ($A0)
85x     # Rest of sector is unused.
''')
Example #2
0
class D81_Description(DiskDescription):
    """Describe the 1541 disk geometry and related CBM-DOS version."""

    _SECTOR_COUNTS = (
        # (starting track, ending track, sectors in this track group)
        (0, 0, 0),
        (1, 80, 40))

    DIRECTORY_HEADER = (40, 0)
    DIRECTORY_ENTRIES = (40, 3)

    STRUCT_HEADER = struct_doc('''
<       # Little-endian
xx      # Track/sector of first directory block; 40/3 for normal disks
x       # 'D' (representing "4040 format".)
x       # 0 Null byte.
16s     # Disk name, PET-ASCII, $A0 padded
xx      # Two shift-spaces
2s      # Disk ID
x       # $A0
xx      # '3D' (DOS version and format type.)
xx      # Shifted spaces ($A0)
227x    # Rest of sector is unused.
''')
Example #3
0
"""This module provides support for reading "T64" tape images."""

from __future__ import with_statement
import struct
from c64 import struct_doc, blocks

class FileNotFoundError(Exception): pass
class FormatError(Exception): pass

TAPE_HEADER = struct_doc('''
<   # Little-endian
xx  # Tape version, unused
H   # Max no. of directory entries
xx  # Used directory entries; non-normative
xx  # Unused
24s # Tape name
''')

TAPE_ENTRY = struct_doc('''
<   # Little-endian
b   # C64s filetype
b   # CBM-DOS filetype
H   # Start address
H   # End address
xx  # Unused
L   # Byte-offset of start of file
xxxx # unused
16s # Filename, PET-ASCII, $20 padded
''')

Example #4
0
                  9 - Printer Driver
                 10 - Input Driver
         75-88: If a document, the name of the application that created it.
         89-9F: Available for applications, unreserved.
         A0-FF: Description (terminated with a $00)
"""

_STRUCT_GEOS_INFO_BLOCK = struct_doc('''
<       # Little-endian
xx      # $00,$FF (no next sector, all bytes in this sector are valid data.)
xxx     # ID bytes ($03 $15 $BF)
63b     # Icon bitmap in sprite format
b       # C64 filetype (same as in directory entry)
b       # GEOS filtetype (same as in directory entry)
b       # GEOS file structure (same as in directory entry)
H       # Program load address
H       # Program end address (for accessories)
H       # Program start address
20s     # Class text
20s     # Author
20s     # Document Application
20b     # Application specific
96s     # Description
''')

BYTES_PER_SECTOR = 256

class DiskDescription(object):
    def __init__(self):
        self.sectors_per_track = _make_sector_table(self._SECTOR_COUNTS)
Example #5
0
                  9 - Printer Driver
                 10 - Input Driver
         75-88: If a document, the name of the application that created it.
         89-9F: Available for applications, unreserved.
         A0-FF: Description (terminated with a $00)
"""

_STRUCT_GEOS_INFO_BLOCK = struct_doc('''
<       # Little-endian
xx      # $00,$FF (no next sector, all bytes in this sector are valid data.)
xxx     # ID bytes ($03 $15 $BF)
63b     # Icon bitmap in sprite format
b       # C64 filetype (same as in directory entry)
b       # GEOS filtetype (same as in directory entry)
b       # GEOS file structure (same as in directory entry)
H       # Program load address
H       # Program end address (for accessories)
H       # Program start address
20s     # Class text
20s     # Author
20s     # Document Application
20b     # Application specific
96s     # Description
''')

BYTES_PER_SECTOR = 256


class DiskDescription(object):
    def __init__(self):
        self.sectors_per_track = _make_sector_table(self._SECTOR_COUNTS)
Example #6
0
import struct
from c64 import struct_doc, blocks


class FileNotFoundError(Exception):
    pass


class FormatError(Exception):
    pass


TAPE_HEADER = struct_doc('''
<   # Little-endian
xx  # Tape version, unused
H   # Max no. of directory entries
xx  # Used directory entries; non-normative
xx  # Unused
24s # Tape name
''')

TAPE_ENTRY = struct_doc('''
<   # Little-endian
b   # C64s filetype
b   # CBM-DOS filetype
H   # Start address
H   # End address
xx  # Unused
L   # Byte-offset of start of file
xxxx # unused
16s # Filename, PET-ASCII, $20 padded
''')