• Updated 2023-07-12: Hello, Guest! Welcome back, and be sure to check out this follow-up post about our outage a week or so ago.

Calling Lisa gurus: Floppy Emu disk emulation

bigmessowires

Well-known member
Hi everyone,

As you probably all know, the Lisa was the precursor to the Macintosh and shared a lot of the same hardware and software. I'm going to look at adding Lisa support to the Floppy Emu emulator I previously developed for the Mac. This thread will document my progress. Please forgive my more-or-less verbatim cross-posting from my blog.

The Emu can already emulate a standard Sony 400K floppy drive, and the Lisa 2 aka Macintosh XL can use a standard Sony 400K floppy drive. (The relatively rare Lisa 1 used 5 1/4 inch Twiggy floppies.) So I *think* they should already be compatible at a low level, from an electrical and interface standpoint. That means the Lisa support could be added with just a firmware update, and no hardware changes necessary. My challenge is that I don't actually own a Lisa! But with the assistance of a few kind Floppy Emu fans who are also Lisa owners, I've started getting closer.

The first obvious task is that the Emu firmware must be modified to support tag bytes. On both the Lisa and the Macintosh, a floppy sector's data contains 12 bytes of tags, and 512 bytes of normal data. On the Mac, the tags aren't used for anything, and Floppy Emu just treats them as if they were always zero. Standard .dsk image files don't even store the tag bytes, although Disk Copy 4.2 images do. But unlike the Mac, the Lisa needs those tag bytes in order for Lisa-formatted disk images to work correctly. So at a minimum, the firmware will need to fetch the tag bytes for each sector from the DC42 image file, instead of just pretending they're zero.

But wait! Even without changing anything on the current Emu firmware, it should be possible to get it working on the Lisa under Macworks XL. Macworks is software for the Lisa 2 that basically turns the computer into an emulated Macintosh. After booting Macworks XL from a standard Lisa disk, you'll then see the familiar Macintosh blinking question mark as it awaits a Mac boot disk. At that point, it should be possible to use a standard Floppy Emu and a Macintosh disk image to boot the Mac OS on the Lisa. Or boot into Mac OS with another disk, then use Floppy Emu to mount  a second Macintosh disk. A helpful Lisa owner tried this exact experiment... and it didn't work. The Lisa-as-Mac recognized that a disk was inserted, but complained that it wasn't initialized, and offered to format it.

So why didn't it work? I need to find the answer to that question before I even start worrying about tag bytes and other changes. My Lisa helper sent a few interesting screenshots:

m7.jpg

When booted using Macworks, the Mac OS on the Lisa includes a floppy control panel for something called the PFG, which I learned is the programmable frequency generator. Those control panel options look intriguing, but I'm not sure what they do. He tried normal and desperate modes with the same results.

From what little I could piece together, the PFG is an extra piece of hardware that not all Lisa 2's have. If present, its purpose is to enable the Lisa to read floppies that were written in Macintosh II series computers that have three bit slip markers per sector. The bit slip marker is a special bit sequence on the floppy that helps the floppy controller get synchronized correctly. Apparently the Mac only needs 3 of them, although early Macs wrote 5 of them. The Lisa needs 5. With the Mac II series, the floppy logic was optimized to write only 3 bit slip markers, which made floppies written by those machines unreadable by the Lisa - hence the need for the PFG. I think.

The PFG shouldn't be necessary when using a Floppy Emu, because the Emu sends at least 10 bit slip markers, and possibly as many as 55. So maybe there are too many, and that creates a problem? It shouldn't be, given my knowledge of the Mac OS disk routines, if the Lisa is faithfully emulating a Mac.

To troubleshoot this, I need to find a way to get low-level floppy error data instead of just useless "this disk is not initialized" messages. Deep in the floppy routines, it knows if the read operation failed because it couldn't adjust the drive speed properly, or couldn't step to the desired track, or couldn't find the sector on the track, or the sector checksum was wrong, or any of about 10 other possible failure reasons. There are a couple of ways I could do that:

1. I've already written a simple floppy testing program for the Mac. If I can get a Lisa with a hard drive and Macworks, I can copy the program onto the HD and run it from there. The trouble is, the generous soul who lives nearby and offered to lend me his Lisa doesn't have an HD for it.

2. There's a program called BLU (Basic Lisa Utility) that can be loaded from a floppy disk, and then used to run a variety of low-level tests, including floppy tests. The manual in appendix D shows the error info that's provided, and it's quite detailed. Unfortunately it's sent to the serial port and not the screen, so I'd have to rig up a serial connection to another machine in order to see the output.

Without a hard disk, option 2 is really my only choice. But there's another problem: I need a real floppy drive to load BLU from disk. But I need a Floppy Emu in order to test it. And the Lisa 2 only has a single floppy port. Hot swapping the drives is not an option. So I think what I'll have to do is build a custom cable similar to my previous daisy chain adapter. This cable/adapter will allow the connection of two floppies drives to the same port, with both of them powered at the same time, and an external switch to control which one is enabled.

Other questions I'm unsure about:

- Does the Lisa have a IWM controller chip, like the Mac? I think it does. But possibly it's clocked at a different speed.

- Is my understanding of the purpose of the PFG correct? Do all Lisas have one, or only some of them?

Assuming I can ever get this sorted under Macworks, then there are many other questions I'll need to answer about tag bytes, the Lisa filesystem, and probably the DART disk image format. But getting Mac disks to work on the Lisa under Macworks is the first step.

 
Last edited by a moderator:

uniserver

Well-known member
I have a LISA I/O board on my bench at work,  --- but no lisa, will that help you at all ?   :)

If i had a lisa i would trying to help you.

 

ScutBoy

Well-known member
Yes - Ray Arachlian at sunder.net wrote LisaEm. He would likely be a great resource and is an approachable guy.

There is also a fairly active Lisa  group at lisalist@googlegroups.com with a lot of knowledgeable "old-timers".

I have Lisas running both Macworks and LisaOS and Office 7/7 if I can render any assistance. I don't think I want to ship a whole machine, but I might be persuaded to ship my Sun Remarketing internal HD to populate your local machine. I'd have to check it's still running/bootable - it's been a while :)

I've never seen the PFG software you show. Perhaps I have a too early version of Macworks, or don't have the hardware.

I'm trying to think how I would use a Lisa-capable FloppyEmu. I can see the utility if a guy didn't have any access to a 400k drive to put into the machine. However, I think a ProFileEmu or WidgetEmu would be much more "useful" since Lisa really needs that mass-storage device to be usable, and working ProFiles and Widgets are much harder to find than a 400k disk drive. There are devices that do this - X/Profile and I think one other who's name escapes me. They use either IDE drives or CF cards.

From what I know the mass-storage interface for Widget/ProFile is it's own thing, and likely not related to floppy protocol (or hardware), but I definitely could be wrong. Ray A. would probably be able to tell you off the bat from writing the emulator. IF Lisa can deal with a "floppy" of size X - kind of like an HD20 is a "big floppy" to a Mac - then it might have more utility.

Not trying to put a damper on the project, but for me, I don't know if this would buy me much. I'm still happy to loan hardware or do testing if it will help.

 

bigmessowires

Well-known member
Thanks. I think I'm going to try working with this locally loaned Lisa for now, and see how far I can get. People are popping up everywhere offering to lend me stuff, which is really nice.

I totally agree a Lisa HD emulator (widget or profile) would be more exciting than a Lisa floppy emulator. I'm only looking at Lisa floppy emulation because of my hope that it will be "easy" to extend my existing design, requiring just some small firmware changes. And there's already the X/Profile, which sounds like it fills the emulation need for Lisa hard drives. I guess I'm just going where curiosity and expedience take me with this one.

I did stumble across LisaEm while I was searching for info, and I'll definitely take a closer look at it.

According to a commenter on my blog, the floppy hardware is different between the Lisa 2/5 and 2/10, and only the 2/10 has an IWM chip. So that might be something to begin my investigation with.

 

ScutBoy

Well-known member
Pertinent to this topic, there's currently a discussion on the LisaList regarding making Twiggy disk images. Some comments from James McPhail from SigmaSeven Systems, creator of X/Profile and BLU. The initial Lisa 2/MacXL conversions with 400k drives had a "LisaLite" board that sat between the Lisa I/O board and the 400K floppy, I assume to translate between the Twiggy implementation and the 400k drive protocol.

Later machines did away with the LisaLite board, but I'll admit I don't know how - perhaps that's the IWM in the Lisa 2/10 as referred to above.

--

Sorry for this late post, I have been away.

>how much can you read talking to the floppy controller, and
>how much is really stored in the disk.

The floppy disk controller in the Lisa is not an opaque black box as 
it is in some computers, it is a 6504 microprocessor with code in 
EPROM, and the commented source code is available online.

It is even less opaque than the Mac, as the Lisa 1/2 don't have an 
IWM, they use a relatively simple state machine built from an 
off-the-shelf shift register, hex flip-flop, and 256 byte PROM, which 
performs the serial/parallel conversion and "bitslip FF" 
synchronization with the bitstream.

The GCR translation is done entirely by the 6504 as well.

As a result, there are no mysteries about the flux transitions on the 
disk, the 6504 code controls it all.

However, I have 1 rare twiggy disk (Lisa Basic disk 2) that has a 
crucial bad sector, and it could be that being able to read the flux 
transitions would make it practical to recreate that sector.

>Free, opensource, http://github.com/claunia/DiscImageChef

Thanks for that contribution!

 

lisa2

Well-known member
bigmessowires,
This is great news, my sole purpose for obtaining my FloppyEmu device was to make it work with the Lisa.
I can confirm the FloppyEmu DOES work fine for me with the Lisa (at least for Macintosh disk images in the MacWorks Environment)!  Because of the lack to TAG byte support, I can't boot a Lisa disk (yet), but I have been able to boot and use the FloppyEmu with the MacOS proving the hardware is compatible with the Lisa.
My plan to was to add the TAG byte support myself (someday), but with your help I am sure we can get this done faster, as getting the time to put together the toolchain to reprogram the device was the main roadblock for me. 
I will make a video of the progress I have made so far as soon as I can.
Rick
lisa2.com

 

bigmessowires

Well-known member
I can confirm the FloppyEmu DOES work fine for me with the Lisa (at least for Macintosh disk images in the MacWorks Environment)!  Because of the lack to TAG byte support, I can't boot a Lisa disk (yet), but I have been able to boot and use the FloppyEmu with the MacOS proving the hardware is compatible with the Lisa.
Really??? Wow! What model of Lisa, of Macworks, and of the Mac OS did you use? 

The Lisa owner who sent me the screenshot in my original post tried exactly what you're describing: loading Macintosh disk images in the Macworks environment - and it didn't work. The Lisa just complained the disk was unreadable and offered to format it. Then just today, I finally got my hands on a Lisa for the first time, and repeated that test with the same result. It doesn't work. This was with a Lisa 2/10, running Macworks Plus, and with Mac system 3.2, and a Floppy Emu running firmware 1.0Q-F13. In the Finder, the computer acted like the disk wasn't initialized. I tried using a floppy testing program I'd written previously, and it showed that low-level calls to read a floppy sector were actually succeeding, but returning bogus data, rather than returning any kind of sensible error code. Bizarre.

If the Floppy Emu truly works on your Lisa, that is great news, and I'd really like to know how you did it! Adding the tag byte support should not be too difficult, I think, but I haven't looked at it yet since the Macworks test showed there was something more fundamentally broken that needed to be addressed first.

 
Last edited by a moderator:

bigmessowires

Well-known member
Correction: my test was actually using Floppy Emu firmware hd20-0.7A-F14.5, not floppy-emu-1.0Q-F13. Though it probably doesn't matter.

 

bigmessowires

Well-known member
Some progress: I actually got it working on the Lisa under Macworks, for both reading and writing. But for some reason it's super slow. I think it must be encountering tons of low-level errors, but it keeps trying, and eventually it succeeds. I'll keep at it.

What I found is that the method I'd been using to generate the special 10-bit bitslip markers was broken. This is one of those things where you wonder how it ever worked, and it must have been causing problems on the Macintosh too. I played around with it a little until I got something that worked (slowly) on the Lisa. Now I need to understand why it's so slow. It will also be interesting to see how this change affects floppy emulation on the Mac - maybe it will be a little faster, if there were resync errors happening before that I wasn't noticing.

 

techknight

Well-known member
The good thing that may come out of this is you'll discover bugs that you never even knew you had! (as youve noticed) and ultimately increase performance on the Macintosh. 

 

Gorgonops

Moderator
Staff member
One thing I'm curious about, based on that screenshot of the Lisa "PFG" control panel: is the data rate on the Lisa's drive interface slightly different than on the Mac? It talks about initializing the... whatever, at either "15.7mhz" or "16mhz"; I vaguely recall that that the IWM has clock inputs that are nominally either 7mhz or 8mhz depending on whether it's used in an Apple II or a Mac, but the clock signal actually supplied to it in the hardware was more like 7.85mhz. That's less than 5%, and of course the disk controller is supposed to be able to compensate for some degree of disk speed variation, but if the Lisa clocks its controller at a straight 8 mhz is it possible that the data stream coming from the FloppyEmu is just far enough out spec that the Lisa is having trouble locking onto it?

(Totally saying this out of ignorance; I haven't actually looked into what the Lisa hadware looks like at all beyond knowing it's not directly driven by the 6800, etc. It would seem this problem would affect real disks on the Lisa as well anyway... my thought there was that the PWM signal from the Lisa might spin the drive slightly faster than it does in the Mac to make it even, but then it occurred to me that the Lisa can supposedly work with 800k drives that ignore PWM with an upgrade so... yeah, never mind that idea.)

 

lisa2

Well-known member
So I have done testing to confirm what I had observed last year.

Using my Floppy Emu, SN#67, App FW 1.0 L, CLPD FW 11

Last night I was able to boot Mac System 6.0.8 from a 800K Raw disk image on a Lisa2/5 running the MacWorks+II environment.  Works fine, but the floppy emulation is very-very slow.

Tonight I was able to mount a 400K RAW image on a Lisa2/10 running System 7 under the MacWorks+II environment, again the floppy emulation was very slow.  

Earlier I did not have success booting the MacOS using the Floppy Emu on the Lisa2/10 system.

Thanks,

Rick

View attachment 5532

FloppyEmu.JPG

 

bigmessowires

Well-known member
I posted a longer progress update at http://www.bigmessowires.com/2015/02/23/lassoing-the-lisa/, as well as a link to the new firmware I'm using. If anyone else has a Lisa and a Floppy Emu and wants to try this out, please read that update and then grab the firmware from the link at the end.

The good thing that may come out of this is you'll discover bugs that you never even knew you had! (as youve noticed) and ultimately increase performance on the Macintosh. 
Yeah! I hope so. Normally the Floppy Emu seems well behaved, but I have noticed a few test cases with specific machine and OS combinations where it sometimes seems to do a LARGE number of retries. So maybe this is the explanation.

is the data rate on the Lisa's drive interface slightly different than on the Mac? It talks about initializing the... whatever, at either "15.7mhz" or "16mhz";...

my thought there was that the PWM signal from the Lisa might spin the drive slightly faster than it does in the Mac to make it even, but then it occurred to me that the Lisa can supposedly work with 800k drives that ignore PWM with an upgrade so... yeah, never mind that idea.)
Great thought. Though I don't think that's a factor here, I could be wrong. On the Mac, the IWM works at one bit per 16 clock cycles, and with a 7.8336 MHz clock, that comes to one bit every 2.04 microseconds. On the Lisa, I think it's precisely 8 MHz (or 16 MHz???), so that comes to one bit every 2 microseconds. Floppy Emu already runs at exactly 2 microseconds per bit, so if anything it should be better on the Lisa than on a Mac. And Floppy Emu ignores the PWM signal, same as how an 800k drive does.

Using my Floppy Emu, SN#67, App FW 1.0 L, CLPD FW 11
That is awesome! And perplexing. 1.0L-FW11 is a slightly older firmware, so it's possible that some change I made afterwards actually broke the emulation from the point of view of a Lisa. Or maybe the firmware is immaterial, and there's some different about your Lisas. Do you know if they have an 800K ROM on the IO board?

But what's really strange is that 1.0L-FW11 still contains the bitslip generation bug that I mentioned. So if your tests worked (albeit slowly), it means that bitslip wasn't actually the source of the problems I was having. It might still be a bug, but probably not THE bug. Or maybe there are several bugs, all interacting with each other.

 

lisa2

Well-known member
>Do you know if they have an 800K ROM on the IO board?

Yes, I have the 800K ROMs in all my systems, also the MW+II PFG boards.

Rick

 

NJRoadfan

Well-known member
One thing I'm curious about, based on that screenshot of the Lisa "PFG" control panel: is the data rate on the Lisa's drive interface slightly different than on the Mac? It talks about initializing the... whatever, at either "15.7mhz" or "16mhz"; I vaguely recall that that the IWM has clock inputs that are nominally either 7mhz or 8mhz depending on whether it's used in an Apple II or a Mac, but the clock signal actually supplied to it in the hardware was more like 7.85mhz. That's less than 5%, and of course the disk controller is supposed to be able to compensate for some degree of disk speed variation, but if the Lisa clocks its controller at a straight 8 mhz is it possible that the data stream coming from the FloppyEmu is just far enough out spec that the Lisa is having trouble locking onto it?
The Apple IIgs runs the IWM at 7.159 MHz (on pin 24 FCLK). Testing with the daisy chain board from an Apple 3.5" Drive indicates the FloppyEmu works on that platform despite the timing difference.

Also dug this ancient bit of text up, the IWM apparently existed in some form in 1982, although this version is likely pre-3.5" disk: http://www.applelogic.org/files/IWM.pdf

 
Last edited by a moderator:

Gorgonops

Moderator
Staff member
Yeah, I didn't seriously think the mismatched clock rate would be the problem, the thought just crossed my mind and I tossed it out there. There's a table in the IWM's datasheet that suggests the mismatching clocks should be well within the IWM's tolerances, so, yeah, never mind. (It is *slightly* interesting in that the clocking suggests there would be a reliably detectable difference in bit density between disks written on an Apple IIgs and a Mac Plus, but again, not enough to worry about.)

As for the origin of the IWM the "Twiggy" drive project supposedly goes back to around 1979, and the IWM was specifically designed (IE, with its "fast" mode) to drive the Twiggy... which does make it interesting/ironic that the part wasn't actually ready in time for the original Lisas.

 

bigmessowires

Well-known member
I have Floppy Emu pretty much working on the Lisa now, at least on my borrowed Lisa 2/10, for Macintosh disk images under Macworks. The current version of the "Lisa Emu" firmware doesn't seem to work on the Lisa 2/5, which has a different floppy drive controller. I'm not sure why. I still need to get confirmation from a few more Lisa owners that the new firmware works OK on their machines, but it's looking good.

Assuming no new problems pop up, I'll move on to emulation of native Lisa floppies next. Then you'll be able to boot the Lisa from Floppy Emu, and use emulated disk images under Lisa Office System.

A short video of the current state of Lisa floppy emulation: 

 
Last edited by a moderator:
Top