From f4b0100c98c2c12988f64ffe44426fcdd5ae901b Mon Sep 17 00:00:00 2001 From: Will Scullin Date: Fri, 9 Jul 2021 17:53:30 -0700 Subject: [PATCH] touchups --- js/cards/disk2.ts | 1 - js/formats/format_utils.ts | 4 +++- js/formats/woz.ts | 27 ++++++++++++--------------- test/js/formats/po.spec.ts | 1 - 4 files changed, 15 insertions(+), 18 deletions(-) diff --git a/js/cards/disk2.ts b/js/cards/disk2.ts index bff49bb..b538a6b 100644 --- a/js/cards/disk2.ts +++ b/js/cards/disk2.ts @@ -67,7 +67,6 @@ const LOC = { DRIVEWRITEMODE: 0x8F // Q7H: Write } as const; - /** Logic state sequencer ROM */ // See Understanding the Apple IIe, Table 9.3 Logic State Sequencer Commands // CODE OPERATION BEFORE AFTER diff --git a/js/formats/format_utils.ts b/js/formats/format_utils.ts index 661d99e..9032771 100644 --- a/js/formats/format_utils.ts +++ b/js/formats/format_utils.ts @@ -564,10 +564,12 @@ export function analyseDisk(disk: NibbleDisk) { } /** + * Debugging utility to convert a bitstream into a nibble. Does not wrap. * * @param bits Bitstream containing nibbles * @param offset Offset into bitstream to start nibblizing - * @returns The next nibble in the bitstream + * @returns nibble, the next nibble in the bitstream, + * and offset, the end of that nibble in the bitstream */ export function grabNibble(bits: bit[], offset: number) { diff --git a/js/formats/woz.ts b/js/formats/woz.ts index d3f434e..12cee92 100644 --- a/js/formats/woz.ts +++ b/js/formats/woz.ts @@ -29,7 +29,6 @@ const WOZ_INTEGRITY_CHECK = 0x0a0d0aff; * @param end end index of string * @returns ASCII string */ - function stringFromBytes(data: DataView, start: number, end: number): string { return String.fromCharCode.apply( null, @@ -188,7 +187,6 @@ export class TrksChunk2 extends TrksChunk { } } - export class MetaChunk { values: Record @@ -213,20 +211,16 @@ interface Chunks { /** * Returns a `Disk` object from Woz image data. - * @param {*} options the disk image and options - * @returns {import('./format_utils').Disk} + * @param options the disk image and options + * @returns A bitstream disk */ -export default function createDiskFromWoz(options: DiskOptions) { +export default function createDiskFromWoz(options: DiskOptions): WozDisk { const { rawData } = options; if (!rawData) { throw new Error('Requires rawData'); } const dv = new DataView(rawData, 0); let dvOffset = 0; - const disk: Partial = { - encoding: ENCODING_BITSTREAM, - }; - let wozVersion; const chunks: Chunks = {}; @@ -303,11 +297,14 @@ export default function createDiskFromWoz(options: DiskOptions) { debug(chunks); - disk.trackMap = chunks.tmap?.trackMap || []; - disk.tracks = chunks.trks?.tracks || []; - disk.rawTracks = chunks.trks?.rawTracks || []; - disk.readOnly = true; //chunks.info.writeProtected === 1; - disk.name = chunks.meta?.values['title'] || options.name; + const disk: WozDisk = { + encoding: ENCODING_BITSTREAM, + trackMap: chunks.tmap?.trackMap || [], + tracks: chunks.trks?.tracks || [], + rawTracks: chunks.trks?.rawTracks || [], + readOnly: true, //chunks.info.writeProtected === 1; + name: chunks.meta?.values['title'] || options.name + }; - return disk as WozDisk; + return disk; } diff --git a/test/js/formats/po.spec.ts b/test/js/formats/po.spec.ts index 16aa02a..fa86d7a 100644 --- a/test/js/formats/po.spec.ts +++ b/test/js/formats/po.spec.ts @@ -246,7 +246,6 @@ describe('ProDOS format', () => { i = expectSequence(track, i, [0xDE, 0xAA, 0xEB]); }); - it('has correct Address Fields for all tracks', () => { // _Beneath Apple DOS_, TRACK FORMATTING, p. 3-12 const disk = ProDOS({