<!vMac Project Overview>
vMac, or the Virtual Macintosh Project is a project which aims to :
- Document Apple Macintosh Hardware
- Provide Apple Macintosh hardware emulations
- Provide Apple Macintosh software/OS emulations in some key areas
- Provide a framework for future development in emulation
The vMac project develops vMac, which is a semi-finished hardware emulation of an Apple Macintosh Plus. This is a test development to see how viable a hardware emulation is. So far, it is largely sucessful and is proving to be quite compatible despite the lack of some key hardware emulation sections and a lot of bugs.
Since a lot of the code is largely based on experiments done by Philip Cummins (PC) the architecture of the current vMac code is largely fixed and inflexible. The purpose of this document is to rectify the problem by providing information for developers to plan ahead and redesign vMac to be easily ported to other systems.
Major Sections to vMac
There are several sections to vMac. Mostly this is divided up into software representations of the actual hardware chips of the Mac Plus. The following areas are :
|UAE 68K|| Unix Amiga Emulator 68K engine|
|IWM||Integrated Woz Machine, the Apple floppy disk controller chip|
|Keyboard||A serial handshaking keyboard emulation section|
|Memory||Memory mapping, glue for other routines|
|Mouse||Mouse, quadrature based for SCC/VIA|
|Native||Native code interface, links compiled code to the emulation|
|RAM||Random Access Memory|
|ROM||Read Only Memory, stores the Mac ROM|
|RTC||Real Time Clock, also stores Parameter RAM|
|SCC||Serial Communications Chip, for mouse and serial communications|
|Screen||Handles screen display|
|SCSI||Small Computer Systems Interface, for peripheral devices|
|Sony||Sony driver replacement, implements floppy disk drives|
|VIA||Versatile Interface Adaptor, handles several things|
|VIA Interface||Interface between VIA code and other sections|
|VIA Interrupts||Handles interrupts (1 and 1/60th second interrupts, as well as timed ones)|
This is probably the murkiest section of vMac. We obtained this code off Bernd Schmidt and his UAE, it ties to the rest of the code via various routines (most notably, get_byte/word/long and put_byte/word/long, Exception, get_real_address and a few others). This will be looked into closely, as several problems/ambiguities exist in the code when ported to other systems.
This is a floppy disk interface for the Mac Plus. It works in conjunction with the VIA to operate 2 400 or 800K floppy disk drives and read/write to them. However, it's one of the most obscure chips in the entire Apple family (save the SWIM). It's essentially able to control the various lines to the custom floppy disk drives and read/write registers in them, as well as sync and read/write the GCR data from the drive. Since it's a very slow device (polling) it's use has been unimplemented, but it can pass startup hardware tests. The .Sony driver is used to manipulate this chip, but has been replaced with a faster rewrite of the .Sony driver.
The keyboard is effectively a hardware handshaking serial device that is connected to the Mac via the VIA's Shift Register. It only accepts key down or key up transitions, but due to lack of development, a routine can now directly insert events into the Mac's event queue which bypasses the keyboard. This however will mean that programs such as Macsbug will no longer work. This will be replaced with a true hardware emulation in subsequent releases. Emulation is at the point of where it can communicate with the computer and return null responses, but the Mac resets it frequently, disrupting typing.
This accepts the UAE's calls for get_real_address and get/put calls. It implements memory mapping via a large switch/if statement to call other hardware devices.
The mouse uses quadrature to interrupt the VIA and SCC with various signals in order to implement mouse movement. However, this is very heavily timing critical, so it's difficult to get it timed properly. In the case of an OS which has a visible mouse (Windows 3.1/95, MacOS, BeOS) it proves impossible to get the mouse to sync up with the host mouse. Therefore, there is a hardware method and a software method, which tricks the mouse driver to redraw the mouse at a set location.
The mouse button is implemented via a VIA line, and is directly linked. This should be replaced for speed reasons with a event instead, to improve response times.
This implements the native code interface. It's quite crude at the moment, but it's able to trap ILLEGAL instructions and pass them for comparisions with other code (notably, the Sony driver) to see if it's an intentional ILLEGAL and then execute code to handle it. It also provides mechanisms for patching A-Traps and also calling A-Traps from native code.
This is the Random Access Memory, it implements 1-4 MB of RAM in the Mac Plus.
Read Only Memory. This is loaded with a suitable ROM and is mapped to be in the same location as the Mac Plus's ROM for access via Mac programs and the MacOS.
The Real Time Clock is a serial handshaking device which is implemented via the VIA lines. It has several registers inside which keep track of the time, as well as storing 256 bytes of parameter RAM for the Mac Plus to utilize, which is still to be implemented. At the moment, it implements a 128k or 512k RTC without the XPRAM.
This is a Zilog 8530 SCC. It supports 2 high speed serial ports (without Data Carrier Detect) for communications upto 230.4 kBaud for LocalTalk communications. It has approximately 64 registers inside which are accessed through 2 registers and 2 data registers. At the moment, it is largely unimplemented except for some mouse emulation.
This is a host computer dependant module which copies the screen buffer (in the RAM) to be displayed on the host computer. The screen is 512x342 B&W data.
Small Computer Systems Interface. vMac will eventually emulate a 5380 SCSI peripherals chip by NCR (Symbios). It's primarily for hooking devices up such as hard drives, scanners, printers and CD-ROMs. At the moment, vMac has no SCSI emulation which means the computer is identified as a Mac 512ke. However, this will be designed to take advantage of host SCSI ports or IDE devices when programmed in.
Since the IWM's difficult to emulate effectively, vMac replaces the entire .Sony driver, which is what the Mac uses to communicate with the floppy drives. However, it's a good idea as it removes the need to do costly GCR conversions (ie, convert the data into side/track/sector information and then into magnetic signals on the disk) and allows us to read files quite easily and quickly.
As an added advantage, vMac supports 1.44 MB, 800K, 400K and other larger disk image files which can work through the .Sony driver (which people take full advantage of). This will probably be moved to a seperate driver and drive set to maintain compatibility with the Mac Plus by making drive 1 and 2 800K/400K drives only.
This is the Rockwell 6522 Versatile Interface Adaptor. It has 2 8 bit bi-directional ports, 2 timers, control/handshaking signals and a serial to parallel and vice versa converter. The Mac is mostly based around it as it utilizes the 2 ports to communicate with the mouse, RTC, floppy drive and other misc functions. It also uses the converter to run the keyboard as well as using the timers for precise (down to 1.2677 usec, nominally 20 usec) timings.
Since the VIA chip is used in all Macintoshes, I've made a module that lets me link up things between external modules and the VIA code (which remains the same) so no really costly code rewriting is required. This will be replaced with a function pointer array instead so it's possible to redesign how the VIA operates on the fly.
This handles counting of instructions, and approximates when 1/60th or 1 second interrupts occur, as well as when to execute timer interrupts. It's fairly buggy, but it works. This will probably be replaced with a host timing dependant and instruction timing independant module.
Since a lot of the code is very experimental, it's very inflexible and badly designed, but it will be gradually replaced with more flexible and efficient code which will support extra ROMs and alternative modules. This overview will be updated when more details are filled in.
vMac, and the vMac Site are copyright © 1996-1998, All rights reserved.