Delving inside a RiscPC emulatorBy Chris Williams. Published: 20th Jan 2006, 23:09:36 | Permalink | Printable
If emulation upsets you, look away nowOf all the various Acorn hardware emulators out there, two in particular are supplied with source code: ArcEm and Arculator, plus its new cousin RPCemu. Created by university undergraduate Tom Walker, Arculator emulates a generic early Archimedes-class computer with either an ARM2 or ARM3 processor. RPCemu is a recent development effort and features ARM610 and ARM710 emulation along with A7000-class chipset and IDE hard disc support. Both programs are available for Microsoft Windows users, bringing the RISC OS platform into a window on a PC desktop.
Being a RiscPC emulator with source code gives an interesting insight into the task of reverse engineering the legacy Acorn computer, which Tom had to go through and without access to the various relevant datasheets. Although VirtualRiscPC successfully emulates a RiscPC environment on PCs, its internals are rightfully protected as being commercially sensitive.
Over a decade old, the technology inside the RiscPC is now old hat enough to the point where it can be more or less emulated with a handful of C source files. At the heart of the application is the ARM emulation engine that works as an interpreter, analysing each machine code instruction in the RISC OS software running on the imaginary RiscPC and deciding what action needs to be taken. As much of the RiscPC hardware is controlled and monitored through memory accesses, the emulator has to obviously be aware of the organisation of the Acorn computer's memory and perform the roles of the keyboard controller, 82C711, IOMD and VIDC20 chips to trick the operating system and application software into believing they are running on real hardware. The emulator also appears to simulate the ARM processor's pipeline and some of the finer points of the way in which the hardware manages and caches memory.
To a seasoned programmer, Tom's source code will appear to be particularly hairy in places, but it certainly gets the job done: his Athlon 2400 powered PC, RPCemu manages without optimisation to achieve up to some 20 MIPS, at which RISC OS 3 is said to be usable. Early Arculator source even includes a crude simulation of the operating system's software interface, implementing basic functions used by application software.
"Thinking about it I can't remember why I started Arculator," said Tom.
"It was probably a logical progression from my BBC emulator, and I thought at the time that emulating a RISC chip such as the ARM would be easier than emulating a 68k machine - which it was. Certainly I wanted to run Lemmings properly, at the time Archie had awful sound and didn't emulate video properly, and RedSquirrel was becoming less and less accurate in terms of video timing with each release, so I wanted to create an accurate emulator to run these sorts of games."
After copying the contents of his RISC OS 3.6 ROMs from his RiscPC to a PC, Tom spent three days getting the beginnings of his emulator working.
He continued: "RPCemu was designed totally differently to Arculator - rather than aim for accuracy, speed was the main agenda, simply because to emulate the system at a good speed with an interpretive emulator required a lot of shortcuts. This has led to issues - what memory protection exists in RISC OS isn't emulated at all, and it's probably the reason why RISC OS 3.x has problems starting up sometimes. On the other hand, these shortcuts allow RPCemu to be around twice the speed of Arculator."
When it began life four years ago, Arculator's development eventually lead to bringing classic old school games back to life. Tom says he had plenty of help along the way from RedSquirrel and VirtualRiscPC author Graeme Barnes, and found many odd bugs in his emulation engine that, through knock on effects, stopped systems such as disc handling from working. Born late last year, RPCemu turned into an endeavour to provide a working RISC OS desktop.
"The Acorn chipset actually turned out to be fairly dull - there's nothing particularly special about VIDC, IOC and MEMC, the most interesting thing was trying to figure out why Acorn designed the MEMC's page table as they did," commented Tom.
"There are few fun tricks unlike say the Amiga or ST chipsets - not even a blitter. I still remember being totally shocked when I figured out how sound worked. The RiscPC chipset is even more basic as no programs attempt to access it directly. The few tricks that worked on VIDC, such as the scrolling hack used in many games, don't work on VIDC20 and were never implemented as such.
"Certainly I don't intend to emulate the Iyonix or the A9home. What would probably be a better method towards emulating these newer machines is just to implement a new HAL for RISC OS 5, writing specific drivers to access the Windows DirectX interface, and get hardware acceleration into the bargain, much in the same way that Acorn wrote Windows drivers for the 486 second processor card. Such an implementation would be suitable possibly for a commercial emulator, which RPCemu isn't at the moment."
He added: "As for the future, I'd like to get FDI support working better in Arculator, to allow for more copy protected games to run. I'd like to implement a filesystem similar to HostFS in RedSquirrel and VirtualAcorn, I actually started one a while ago but ran into problems. A dynamically recompiling CPU core in RPCemu would be very useful, hopefully boosting the speed to StrongARM levels on my machine. I wouldn't rule out a commercial version of RPCemu, since I'm a penniless undergraduate, but there would be a lot of issues to overcome before that would be possible."
Meanwhile, ArcEm continues to improve with, amongst other details, the addition of preliminary sound support and code to allow programs running within ArcEm to access the filesystem of the host platform. There has been the suggestion that the Archimedes-class hardware emulator should incorporate Nick Burret's work on QEMU, which has enabled simple RISC OS command line applications to run on GNU/Linux. Another tabled idea is to somehow bundle or distribute ArcEm with a set of RISC OS 3.10 ROM files, allowing non-RISC OS users to download and try out the operating system for themselves rather than, say, just looking at screenshots or reading a features list. Leaving aside the issue of how one gets distribution permission from the merchant bank holding RISC OS 3.10, whether or not the 13 year old operating system is a great advert and how much make up it will require to make it presentable is still a matter of debate.
Arculator and RPCemu website (downloads include source code)
Previous: Castle rattles licensing sabre at 32bit RISC OS 4
Next: PCI serial port card driver available
DiscussionViewing threaded comments | View comments unthreaded, listed by date | Skip to the end
Please login before posting a comment. Use the form on the right to do so or create a free account.
Search the archives
Today's featured article
Interview with a ROS Open shareholder
Andrew Hodgkinson talks of his time at Tematic
27 comments, latest by markee174 on 22/7/06 7:27PM. Published: 16 Jul 2006
Firefox first beta published
Get it while it's hot
69 comments, latest by RickCB on 28/07/05 12:37AM. Published: 20 Jun 2005
News and media:
RISCOS Ltd •
RISC OS Open •
MW Software •
Advantage Six •
CJE Micros •
Liquid Silicon •
Chris Why's Acorn/RISC OS collection •
The Register •
The Inquirer •
Apple Insider •
BBC News •
Sky News •
Google News •