Short: Slow buggy PC emul. port w/src, A68k/PPC Author: Peter McGavin (p.mcgavin@irl.cri.nz) (originally by David Hedley) Uploader: Peter McGavin (p mcgavin irl cri nz) Type: misc/emu Architecture: m68k-amigaos; ppc-powerup PCEmuAmiga 0.0 30 Aug 1998 -------------- This archive contains an Amiga port of David Hedley's PC Emulator for Unix/X Windows. Written entirely in C, it emulates a standard text-only 8086 based PC with 640 kb memory. David Hedley did most of the work in 1993/1994 for a 3rd year university project. He took several months to do the hard work, writing and debugging the 8086 emulator, bios interface and hardware emulation code. For a full report of his activities, take a look at report.ps with a PostScript viewer. David's version of the emulator is available from sunsite as pcemu1.01alpha.tar.gz. It runs on Linux, Solaris, HP-UX, etc. The Amiga port took 2 days (so far), plus another 2 or 3 hours to write this document. I reckon that's a tribute to how well David made his code portable and separated the hardware independent from hardware dependent code. I replaced the X Windows module, xstuff.c, with an Amiga equivalent, astuff.c. It handles colour text video and the keyboard. Apart from that, I replaced the 100 Hz timer interrupt code (tricky for PPC), resolved various naming conflicts with the Amiga includes, and changed some Unix versus Amiga path naming conventions. Unfortunately the original emulator is far from complete. For example, there are no graphics modes, no mouse/joystick, no sound, incomplete bios emulation, no 80286 emulation, and so on. Indeed, these days it's quite hard to find compatible software for it. Also, it is quite slow, and there are bugs. No doubt there are more bugs and limitations in my Amiga version than in David's Unix/X Windows version. On the positive side, when things go wrong, pcemu generally exits cleanly and leaves the Amiga stable. If it freezes, a clean exit can be forced by sending pcemu a CTRL/C BREAK signal. I have yet to crash my Amiga with pcemu. See the other documentation files for David's description of the emulator. REQUIREMENTS ------------ A fast Amiga, preferably a 68060 or PPC, with at least KS3.0. The PPC version uses PowerUp, not WarpOS, sorry. Stack requirements are small, I think. INSTALLATION ------------ You should be able to run pcemu and/or pcemuppc directly from the distribution directory. To install to a hard disk: Copy pcemu and/or pcemuppc to a directory of your choice. Install the vga/16 font in your fonts directory or under the program directory. (The program directory is the directory containing pcemu and/or pcemuppc.) Copy .pcemurc to the program directory. Edit .pcemurc, look at the comments in the file and make changes if required. Here you can configure your keyboard and PPC bus speed, among other things. Copy DriveA to the program directory. DriveA is an image of a bootable floppy disk. The emulator loads it then boots to it. DOS --- PCs run operating systems such as MS-DOS. PC emulators do the same. A PC emulator is pretty useless without an OS. Unfortunately I can't give away MS-DOS with pcemu. It still belongs to Bill Gates. However there's a mostly MS-DOS compatible OS called FreeDOS that's governed by the GNU license. I can give it away provided I tell you how I got it and how you can get the source code. Well I downloaded it from "http://www.freedos.org/" and you can get it from there too. The file DriveA is an image of a 1.44 Mb bootable floppy disk containing some of the base components of FreeDOS --- just enough to boot the emulator and try a few things. It doesn't contain a single byte of Micro$oft code. Unfortunately FreeDOS has its share of bugs which, added to the bugs in pcemu, makes for a very unstable situation. You'll do much better if you get yourself a real bootable MS-DOS disk and make your own DriveA image from it. The program amidumpdisk in the programs directory can dump 720 kb and 1.44 Mb PC floppies to a disk image. Run it from a CLI to see how to use it. You'll need a high-density drive to make a 1.44 Mb image. Well, either that or use David Hedley's dumpdisk (also in the programs directory) on a PC. Or try "cp /dev/fd0 DriveA" on a Unix box. If you make a 720 kb image (or another size), you'll have to change a line in .pcemurc. It might be a good idea to make an image of a bootable MS-DOS disk with EDIT.EXE, QBASIC.EXE, some text Basic games like NIBBLES.BAS, Norton SysInfo, and so on. Something with colour makes a difference. WINDOWS ------- You must be kidding... LREDIR AND EMUFS ---------------- These are PC programs in the programs directory which allow the PC emulator to access the Unix file system behind the emulator. See ldir.readme in the programs directory for a full description. Please note that I made only minimal changes to the EMUFS support in the emulator to get the code to compile. In particular, I did not change any path naming conventions from Unix. You can try installing EMUFS.SYS in your config.sys to access Amiga files, but the result may not be what you expect. Absolute pathnames in Unix start with a slash "/". When the emulator passes a name beginning with a "/" to AmigaDOS, AmigaDOS looks in the parent directory, i.e, one up from where you are now. If you're very lucky, you might be able to access files in the parent directory from inside pcemu. Constructions like "../" probably won't work at all. In any case, MFS often seems to list files with the wrong sizes, or complete gibberish. MFS is the most bug-ridden part of PCEmuAmiga. TIMING ------ The original emulator uses setitimer() to generate 100 Hz regular interrupts. The interrupt routine sets a flag which the emulator checks before every 8086 instruction. If the flag is set, the emulator generates 8086 interrupts as required, checks for keyboard input, updates the display, and so on. SAS/C doesn't provide setitimer(). For the Amiga A68k version, I used timer.device and TR_ADDREQUEST to provide the same functionality. I couldn't see how to generate 100 Hz interrupts with PPC PowerUp without massive overheads with every 8086 instruction. Therefore I changed to a different method. Before every instruction, the emulator reads the PPC time base facility registers and checks to see whether 0.01 seconds has elapsed since the last interrupt. Calling a subroutine to read the time base registers and doing 64-bit comparisons is slower than checking a flag. Therefore I changed the emulator to execute a fixed number of instructions before checking the clock. You can set this number in .pcemurc. By default it is 100. Not checking for interrupts after every instruction my cause compatibility problems with some software. SPEED ----- Frankly, I'm disappointed in the speed, especially the PPC version. I compiled David Hedley's original version with egcs on APUS and it went several times faster on the same Amiga. And that was sending all the graphics across a network to another X-server too (because I haven't got an X-server working on APUS yet). I don't know whether the difference is egcs versus SAS/C or whether I did something silly when I ported it to the Amiga. Perhaps it's doing too many A68k/PPC context switches. Profiling the A68k version indicates it spends about 99% of its time in the 8086 emulator. FUTURE PLANS ------------ Sorry but I don't have any future plans for PCEmuAmiga really. It would be incredibly time-consuming to fix many of the bugs and limitations. I was only interested in seeing how easily it could be ported to the Amiga and how fast it would go. Perhaps if I see an easy fix that would make a big difference, and if I have enough spare time, I might do something. There are too many other things to do... However all the source code is there for anyone to modify for non-commercial purposes. Why don't you go for it? Peter McGavin (p.mcgavin@irl.cri.nz).