Path: utzoo!news-server.csri.toronto.edu!cs.utexas.edu!sun-barr!apple!portal!cup.portal.com!Radagast From: Radagast@cup.portal.com (sullivan - segall) Newsgroups: comp.sys.amiga.emulations Subject: Re: 8 methods to emulate a Z80 Message-ID: <40100@cup.portal.com> Date: 13 Mar 91 08:07:22 GMT References: <18847.27d80900@windy.dsir.govt.nz> <18850.27dbf20e@windy.dsir.govt.nz> Distribution: na Organization: The Portal System (TM) Lines: 50 >------------------------------------------------------------------------------ - >Note on hardware registers: > >Handling writes to hardware registers in the Spectrum isn't really very hard. >The z80 has a separate IO address space with a separate set of instructions fo r >handling it. (The same is true of the 8088.) The only thing to watch for is >writing to video RAM. It is fixed size and at a fixed place, so it takes 2 >tests. (There doesn't seem to be a faster way of doing a single bit test --- >the video RAM doesn't end on a power-of-2 boundary.) I have a separate task >(sort of) which uses the blitter to keep the screen up-to-date with the video >RAM. So when there is a write to video RAM, the emulator task doesn't have to >do much. It just flags the blitter task "Hey, there's something to update in >character row n, when you wake up". The blitter task doesn't slow the emulato r >down much, because it's mostly running on another processor, and it sleeps whe n >there's nothing to update. > >------------------------------------------------------------------------------ - If video writes are the more rare case (and I imagine they are) use the bit test even though the memory doesn't end on a bit boundary. If the bit test fails you can continue on with your important code quickly. If it doesn't fail, you only have the extra overhead of checking whether it is really a hit, or only a close call. There are many places in an emulator where two checks are faster than one. When it comes to decoding op-codes, it is usually a good idea to make the faster path the same as the manufacturers faster path. Not neccessarily because that is a better design so much as because many programs are optimized to use the faster paths more often. Worst case emulation time is increased, but over all performance is improved dramatically -Sullivan_-_Segall (a.k.a. Radagast) _______________________________________________________________ /V\ E-Credibility: (n -- ME) The unguaranteed likelyhood that ' the electronic mail you are reading is genuine rather than someone's made up crap. _______________________________________________________________ Mail to: ...sun!portal!cup.portal.com!radagast or radagast@cup.portal.com