Some code cleanup.

Fixed file length issue.
Cleaned up TMAP generation.
Fixed issue in TRKS output.
This commit is contained in:
John Morris 2018-06-06 13:42:40 -07:00
parent 4725ca3a58
commit 6a0fb9b4f1
8 changed files with 449 additions and 26 deletions

View File

@ -48,7 +48,7 @@ int main(int argc, char *argv[]) {
// Create a buffer for the portion of the WOZ image that comes after
// the 12-byte header. The header will house the CRC, which will be
// calculated later.
const size_t woz_image_size = 256 + 35*6656;
const size_t woz_image_size = 256 - 12 + 35*6656;
uint8_t woz[woz_image_size];
#define set_int32(location, value) \
woz[location] = (value) & 0xff; \
@ -98,23 +98,22 @@ int main(int argc, char *argv[]) {
//
// The remaining quarter-track position maps to nothing, which in
// WOZ is indicated with a value of 255.
// Let's start by filling the entire TMAP with empty tracks.
memset(&woz[76], 0xff, 160);
// Then we will add in the mappings.
for(int c = 0; c < 35; ++c) {
if (c > 0) woz[75 + (c << 2)] = c;
woz[76 + (c << 2)] = woz[77 + (c << 2)] = c;
woz[78 + (c << 2)] = woz[79 + (c << 2)] = 255;
int track_position = 76 + (c << 2);
if (c > 0) woz[track_position - 1] = c;
woz[track_position] = woz[track_position + 1] = c;
}
// So there are 20 track slots that a DSK doesn't reach; set them
// to no-track-mapped.
memset(&woz[76 + (35 << 2)], 20, 0xff);
/*
WOZ image item 3: a TRKS chunk.
*/
strcpy((char *)&woz[236], "TRKS"); // Chunk ID.
set_int32(240, 35*65536); // Chunk size.
set_int32(240, 35*6656); // Chunk size.
// The output pointer holds a byte position into the WOZ buffer.
size_t output_pointer = 244;
@ -366,17 +365,17 @@ static void serialise_track(uint8_t *dest, const uint8_t *src, uint8_t track_num
size_t track_position = 0; // This is the track position **in bits**.
memset(dest, 0, 6646);
// Write the gap 1.
for(int c = 0; c < 16; ++c) {
track_position = write_sync(dest, track_position);
}
// Step through the physical sector.
for(int sector = 0; sector < 16; ++sector) {
/*
Write the sector header.
*/
// Lead-in.
for(int c = 0; c < 10; ++c) {
track_position = write_sync(dest, track_position);
}
// Prologue.
track_position = write_byte(dest, track_position, 0xd5);
track_position = write_byte(dest, track_position, 0xaa);
@ -394,14 +393,14 @@ static void serialise_track(uint8_t *dest, const uint8_t *src, uint8_t track_num
track_position = write_byte(dest, track_position, 0xeb);
// Write the gap 2.
for(int c = 0; c < 7; ++c) {
track_position = write_sync(dest, track_position);
}
/*
Write the sector body.
*/
// Lead-in.
for(int c = 0; c < 10; ++c) {
track_position = write_sync(dest, track_position);
}
// Prologue.
track_position = write_byte(dest, track_position, 0xd5);
@ -422,17 +421,19 @@ static void serialise_track(uint8_t *dest, const uint8_t *src, uint8_t track_num
track_position = write_byte(dest, track_position, 0xde);
track_position = write_byte(dest, track_position, 0xaa);
track_position = write_byte(dest, track_position, 0xeb);
}
// Pad out to roughly 50,000 bits.
while(track_position < 50000) {
track_position = write_sync(dest, track_position);
}
// Write the gap 3.
for(int c = 0; c < 16; ++c) {
track_position = write_sync(dest, track_position);
}
}
// Add the track suffix.
dest[6646] = (track_position >> 3) & 0xff;
dest[6647] = (track_position >> 11) & 0xff; // Byte count.
dest[6648] = track_position & 0xff;
dest[6649] = (track_position >> 8) & 0xff; // Bit count.
dest[6650] = dest[6651] = 0xff; // Splice information: none.
dest[6650] = dest[6651] = 0x00; // Splice information.
dest[6652] = 0xff;
dest[6653] = 10;
}

View File

@ -0,0 +1,279 @@
// !$*UTF8*$!
{
archiveVersion = 1;
classes = {
};
objectVersion = 50;
objects = {
/* Begin PBXBuildFile section */
520B9CA520C86EE80055ADF8 /* dsk2woz.c in Sources */ = {isa = PBXBuildFile; fileRef = 520B9CA420C86EE80055ADF8 /* dsk2woz.c */; };
/* End PBXBuildFile section */
/* Begin PBXCopyFilesBuildPhase section */
520B9C9820C86ED40055ADF8 /* CopyFiles */ = {
isa = PBXCopyFilesBuildPhase;
buildActionMask = 2147483647;
dstPath = /usr/share/man/man1/;
dstSubfolderSpec = 0;
files = (
);
runOnlyForDeploymentPostprocessing = 1;
};
/* End PBXCopyFilesBuildPhase section */
/* Begin PBXFileReference section */
520B9C9A20C86ED40055ADF8 /* dsk2woz */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = dsk2woz; sourceTree = BUILT_PRODUCTS_DIR; };
520B9CA420C86EE80055ADF8 /* dsk2woz.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = dsk2woz.c; path = ../../dsk2woz.c; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
520B9C9720C86ED40055ADF8 /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXFrameworksBuildPhase section */
/* Begin PBXGroup section */
520B9C9120C86ED40055ADF8 = {
isa = PBXGroup;
children = (
520B9C9C20C86ED40055ADF8 /* dsk2woz */,
520B9C9B20C86ED40055ADF8 /* Products */,
);
sourceTree = "<group>";
};
520B9C9B20C86ED40055ADF8 /* Products */ = {
isa = PBXGroup;
children = (
520B9C9A20C86ED40055ADF8 /* dsk2woz */,
);
name = Products;
sourceTree = "<group>";
};
520B9C9C20C86ED40055ADF8 /* dsk2woz */ = {
isa = PBXGroup;
children = (
520B9CA420C86EE80055ADF8 /* dsk2woz.c */,
);
path = dsk2woz;
sourceTree = "<group>";
};
/* End PBXGroup section */
/* Begin PBXNativeTarget section */
520B9C9920C86ED40055ADF8 /* dsk2woz */ = {
isa = PBXNativeTarget;
buildConfigurationList = 520B9CA120C86ED40055ADF8 /* Build configuration list for PBXNativeTarget "dsk2woz" */;
buildPhases = (
520B9C9620C86ED40055ADF8 /* Sources */,
520B9C9720C86ED40055ADF8 /* Frameworks */,
520B9C9820C86ED40055ADF8 /* CopyFiles */,
);
buildRules = (
);
dependencies = (
);
name = dsk2woz;
productName = dsk2woz;
productReference = 520B9C9A20C86ED40055ADF8 /* dsk2woz */;
productType = "com.apple.product-type.tool";
};
/* End PBXNativeTarget section */
/* Begin PBXProject section */
520B9C9220C86ED40055ADF8 /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 0930;
ORGANIZATIONNAME = "Evolution Interactive";
TargetAttributes = {
520B9C9920C86ED40055ADF8 = {
CreatedOnToolsVersion = 9.3.1;
};
};
};
buildConfigurationList = 520B9C9520C86ED40055ADF8 /* Build configuration list for PBXProject "dsk2woz" */;
compatibilityVersion = "Xcode 9.3";
developmentRegion = en;
hasScannedForEncodings = 0;
knownRegions = (
en,
);
mainGroup = 520B9C9120C86ED40055ADF8;
productRefGroup = 520B9C9B20C86ED40055ADF8 /* Products */;
projectDirPath = "";
projectRoot = "";
targets = (
520B9C9920C86ED40055ADF8 /* dsk2woz */,
);
};
/* End PBXProject section */
/* Begin PBXSourcesBuildPhase section */
520B9C9620C86ED40055ADF8 /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
520B9CA520C86EE80055ADF8 /* dsk2woz.c in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXSourcesBuildPhase section */
/* Begin XCBuildConfiguration section */
520B9C9F20C86ED40055ADF8 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_NONNULL = YES;
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_ENABLE_OBJC_WEAK = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
CODE_SIGN_IDENTITY = "Mac Developer";
COPY_PHASE_STRIP = NO;
DEBUG_INFORMATION_FORMAT = dwarf;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES;
GCC_C_LANGUAGE_STANDARD = gnu11;
GCC_DYNAMIC_NO_PIC = NO;
GCC_NO_COMMON_BLOCKS = YES;
GCC_OPTIMIZATION_LEVEL = 0;
GCC_PREPROCESSOR_DEFINITIONS = (
"DEBUG=1",
"$(inherited)",
);
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
MACOSX_DEPLOYMENT_TARGET = 10.13;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = macosx;
};
name = Debug;
};
520B9CA020C86ED40055ADF8 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_NONNULL = YES;
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_ENABLE_OBJC_WEAK = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
CODE_SIGN_IDENTITY = "Mac Developer";
COPY_PHASE_STRIP = NO;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
ENABLE_NS_ASSERTIONS = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
GCC_C_LANGUAGE_STANDARD = gnu11;
GCC_NO_COMMON_BLOCKS = YES;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
MACOSX_DEPLOYMENT_TARGET = 10.13;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = macosx;
};
name = Release;
};
520B9CA220C86ED40055ADF8 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
CODE_SIGN_STYLE = Automatic;
DEVELOPMENT_TEAM = Z8VRXJGJ89;
PRODUCT_NAME = "$(TARGET_NAME)";
};
name = Debug;
};
520B9CA320C86ED40055ADF8 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
CODE_SIGN_STYLE = Automatic;
DEVELOPMENT_TEAM = Z8VRXJGJ89;
PRODUCT_NAME = "$(TARGET_NAME)";
};
name = Release;
};
/* End XCBuildConfiguration section */
/* Begin XCConfigurationList section */
520B9C9520C86ED40055ADF8 /* Build configuration list for PBXProject "dsk2woz" */ = {
isa = XCConfigurationList;
buildConfigurations = (
520B9C9F20C86ED40055ADF8 /* Debug */,
520B9CA020C86ED40055ADF8 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
520B9CA120C86ED40055ADF8 /* Build configuration list for PBXNativeTarget "dsk2woz" */ = {
isa = XCConfigurationList;
buildConfigurations = (
520B9CA220C86ED40055ADF8 /* Debug */,
520B9CA320C86ED40055ADF8 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */
};
rootObject = 520B9C9220C86ED40055ADF8 /* Project object */;
}

View File

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<Workspace
version = "1.0">
<FileRef
location = "self:dsk2woz.xcodeproj">
</FileRef>
</Workspace>

View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>

View File

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<Bucket
type = "1"
version = "2.0">
</Bucket>

View File

@ -0,0 +1,101 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0930"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "520B9C9920C86ED40055ADF8"
BuildableName = "dsk2woz"
BlueprintName = "dsk2woz"
ReferencedContainer = "container:dsk2woz.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
</Testables>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "520B9C9920C86ED40055ADF8"
BuildableName = "dsk2woz"
BlueprintName = "dsk2woz"
ReferencedContainer = "container:dsk2woz.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "520B9C9920C86ED40055ADF8"
BuildableName = "dsk2woz"
BlueprintName = "dsk2woz"
ReferencedContainer = "container:dsk2woz.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
<CommandLineArguments>
<CommandLineArgument
argument = "&quot;/Users/john/Desktop/Wavy Navy (4am crack).dsk&quot;"
isEnabled = "YES">
</CommandLineArgument>
<CommandLineArgument
argument = "&quot;/Users/john/Desktop/disk.woz&quot;"
isEnabled = "YES">
</CommandLineArgument>
</CommandLineArguments>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "520B9C9920C86ED40055ADF8"
BuildableName = "dsk2woz"
BlueprintName = "dsk2woz"
ReferencedContainer = "container:dsk2woz.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>

View File

@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>SchemeUserState</key>
<dict>
<key>dsk2woz.xcscheme</key>
<dict>
<key>orderHint</key>
<integer>0</integer>
</dict>
</dict>
<key>SuppressBuildableAutocreation</key>
<dict>
<key>520B9C9920C86ED40055ADF8</key>
<dict>
<key>primary</key>
<true/>
</dict>
</dict>
</dict>
</plist>