Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Include support for .woz disk images #183

Open
st3fan opened this issue May 7, 2018 · 4 comments
Open

Include support for .woz disk images #183

st3fan opened this issue May 7, 2018 · 4 comments

Comments

@st3fan
Copy link
Owner

st3fan commented May 7, 2018

If the file format is publicly documented.

@kerthunk
Copy link

kerthunk commented May 7, 2018

The most recent version of the spec can always be found here: woz reference

Some test images are currently available here: images

Feel free to hit me up if you have any questions.

@st3fan
Copy link
Owner Author

st3fan commented Jun 1, 2018

@st3fan
Copy link
Owner Author

st3fan commented Jun 2, 2018

Some things I can already work on until I fully understand how all this fits together:

  • Add an EWM_DSK_TYPE_WOZ
  • Add a function to verify and load a .woz image
  • Convert track bitstream to a nibble stream

@kerthunk
Copy link

kerthunk commented Jun 3, 2018

This is the code that I use in Applesauce to convert from a DSK to a bitstream. The NibbleStream class that this is referencing is an abstraction layer that sits over the bitstream.

    static func makeNibbleStream(fromDSK: Data, trackNum: Int, useGap1Size: Int) -> NibbleStream {
        let sectorInterleave = [0x00, 0x07, 0x0e, 0x06, 0x0d, 0x05, 0x0c, 0x04, 0x0b, 0x03, 0x0a, 0x02, 0x09, 0x01, 0x08, 0x0f]
        let nibs = NibbleStream()
        // gap 1
        nibs.appendRepeating(value: 0xff, bitCount: 10, count: useGap1Size)
        for sector_num in 0..<16 {
            // write the address field prolog
            nibs.append(value: 0xd5, bitCount: 8)
            nibs.append(value: 0xaa, bitCount: 8)
            nibs.append(value: 0x96, bitCount: 8)
            // write the address field data
            var afd = Data()
            let vol = UInt8(254)
            afd.append(vol)
            let trk = UInt8(trackNum)
            afd.append(trk)
            let sec = UInt8(sector_num)
            afd.append(sec)
            let chk = vol ^ trk ^ sec
            afd.append(chk)
            if let encoded_afd = NibbleCodec.codec44.encode(data: afd, start: 0, length: 4).nibbles {
                nibs.appendData(data: encoded_afd, bitCount: 8)
            }
            // write the address field epilog
            nibs.append(value: 0xde, bitCount: 8)
            nibs.append(value: 0xaa, bitCount: 8)
            nibs.append(value: 0xeb, bitCount: 8)
            // write gap 2
            nibs.appendRepeating(value: 0xff, bitCount: 10, count: 7)
            // write the data field prolog
            nibs.append(value: 0xd5, bitCount: 8)
            nibs.append(value: 0xaa, bitCount: 8)
            nibs.append(value: 0xad, bitCount: 8)
            // write the data
            let sector_start = (trackNum * 4096) + (sectorInterleave[sector_num] * 256)
            if let encoded_data = NibbleCodec.codec62.encode(data: fromDSK, start: sector_start).nibbles {
                nibs.appendData(data: encoded_data, bitCount: 8)
            }
            // write the data field epilog
            nibs.append(value: 0xde, bitCount: 8)
            nibs.append(value: 0xaa, bitCount: 8)
            nibs.append(value: 0xeb, bitCount: 8)
            // write gap 3
            nibs.appendRepeating(value: 0xff, bitCount: 10, count: 16)
        }
        return nibs
    }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants