Hi there,
I'm writing an Apple II Emulator.
[...]
Where I am stuck is: How do I get a "disk image" in my emulation? Which format must it have? Woz? DSK? Up to know I know "that these formats exist". How can I deal with these formats? What do I have to consider?
I'm writing an Apple II Emulator. It boots up perfectly and enters Applesoft. Basic Programs are working fine.
I found out during boot up the Disk II firmware makes heavy use of softswitches - so far, so good.
Where I am stuck is: How do I get a "disk image" in my emulation?
Which format must it have? Woz? DSK?
Up to know I know "that these formats exist". How can I deal with these formats? What do I have to consider?
How do I "read out" these images to satisfy the emulation and give it the bytes it wants to make the boot up complete?
I don't want just to look up someone else's source code - I want to understand at an more abstract level, what's really going on and start a conversation on this topic.
I've wondered how far those stepper motors could be pushed. Are we really only limited to quarter tracks? Fractional tracking anyone?
https://pages.cpsc.ucalgary.ca/~aycock/ra/disk2.html
The spiral disk protection used on Choplifter gives a neat effect.
I've wondered how far those stepper motors could be pushed. Are we really only limited to quarter tracks? Fractional tracking anyone?
On 2/20/23 1:52 AM, Jens Gaulke wrote:
Hi there,
I'm writing an Apple II Emulator.I would start with what your goals are and work backwards from that.
[...]
Where I am stuck is: How do I get a "disk image" in my emulation? Which format must it have? Woz? DSK? Up to know I know "that these formats exist". How can I deal with these formats? What do I have to consider?
The Disk II is an analog device at is core, and has various layers of hardware, firmware, and software to decode the analog signal into a
stream of bits. You can insert your emulation at any level along that spectrum, depending on the fidelity you are interested in achieving -
which will dictate the ultimate capabilities of your disk emulation (and
by extension, your emulator).
At one extreme is the ".dsk" which is only the bytes that the operating system would ever present to a user; the data within all tracks and
sectors. A layer beneath that is the nibble stream, represented by the decoded nibbles that are actually recorded on a disk; that affords you access to all the in-band data and enveloping headers and trailers. And beneath that is a ".woz" representation that defines lots more meta-information about the recorded signals and their environment which
are important for encapsulating and decoding the many copy protection schemes that were devised using the Disk II. That level of information
isn't available in any other encoding.
The place to start getting a complete understanding of the physical Disk
II ecosystem is Sather's seminal work, Understanding the Apple II (and
Apple IIe) - chapter 9, "The Disk Controller". That's every detail at
the bottom layer.
Sather's books (and more) are available here: https://mirrors.apple2.org.za/Apple%20II%20Documentation%20Project/Books/
The Woz specification is available here: https://applesaucefdc.com/woz/reference2/
Other nasty protection schemes come to mind, ultimately they be defeated but emulating edge cases is a challenge.
I've wondered how far those stepper motors could be pushed. Are we really only limited to quarter tracks? Fractional tracking anyone?
https://pages.cpsc.ucalgary.ca/~aycock/ra/disk2.html
The spiral disk protection used on Choplifter gives a neat effect.
On Sunday, February 19, 2023 at 10:52:24 PM UTC-8, Jens Gaulke wrote:
I'm writing an Apple II Emulator. It boots up perfectly and enters Applesoft. Basic Programs are working fine.Gratulations on your emulator working! You are (mostly) over the hard/tedious part!
Usually emulation questions are handled over in comp.emulators.apple2 but I'll answer here for convenience.
I found out during boot up the Disk II firmware makes heavy use of softswitches - so far, so good.Eventually you will probably need to emulate the Logic State Sequencer (P6/P6A) PROM but for now you can skip it.
i.e. http://mirrors.apple2.org.za/ground.icaen.uiowa.edu/Mirrors/uni-kl/hardware/diskIIcontroller_hardware
Where I am stuck is: How do I get a "disk image" in my emulation?First, the usual pre-requisite reading:
* Beneath Apple DOS (or the combined Beneath Apple DOS and Beneath Apple ProDOS 2020)
* Understanding the Apple II (or Understanding the Apple IIe)
* Tome of Copy Protection -- https://www.amazon.com/Copy-Protection-Bruce-Jones/dp/1387907271
* Be familiar with 4&4 encoding
* Be familiar with 6&2 encoding
* Know how to read nibbles from assembly language, i.e. https://stackoverflow.com/questions/69369122/apple-iie-6502-assembly-accessing-disk
* Optional: SWIM_Chip_Users_Ref_198801.pdf While this covers the IWM (Integrated Woz Machine in the IIgs) it has some useful diagrams.
I would start with:
* motor on/off
* track movement
* write sensor
* add .DSK reading support
* add .DSK writing support
* add .WOZ reading support
* add .WOZ writing support.
Which format must it have? Woz? DSK?You probably "need" .DSK and .WOZ since those will cover the majority of disk images. There are also .do and .po extensions but that only effects the logical <--> physical sector order.
You will need to keep track of a few things:
* motor on/off
* reading/writing state
* track number (eventually you need quarter track support but stick with integers for now)
* byte offset (eventually will be a bitstream offset)
For .DSK images when your emulator mounts a virtual image:
* Have a 35 tracks * 16 sector disk image buffer
* Whenever the disk head is moved to a new track build a virtual disk nibble trackr by denibblizing a track. This mean converting each 256 8-bit values back into the 342 6-bit values. This means filling in for each sector
* the FF sync byte gap, say 48 of them,
* the address field,
* another FF sync gap, say 6 bytes,
* the data field,
* the checksum, and
* another FF sync gap, say 27 bytes
* Then when $C0EC is accessed (assuming the motor is on and in read mode), return trackbuffer[ nibbleoffset++ & TRACK_BUFFER ]
This will fail most copy-protection since you aren't emulating any timing but this should let you boot most non-protected software.
Up to know I know "that these formats exist". How can I deal with these formats? What do I have to consider?Make sure your 6502 has accurate cycle emulation.
Eventually you will need to emulate the LSS, specifically at the microsecond level, for correctness. i.e. $C0ED will reset the LSS.
How do I "read out" these images to satisfy the emulation and give it the bytes it wants to make the boot up complete?See above.
I don't want just to look up someone else's source code - I want to understand at an more abstract level, what's really going on and start a conversation on this topic.Have you read the pre-requisite books?
Good luck!
m.
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 491 |
Nodes: | 16 (2 / 14) |
Uptime: | 88:26:49 |
Calls: | 9,679 |
Files: | 13,722 |
Messages: | 6,173,790 |