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.