[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: The Perfect Emulator?
On Tue, 30 Sep 2003 01:32:23 +0000, Michael J. Mahon wrote:
> Sheldon Simms replied:
>
>>On Mon, 29 Sep 2003 20:24:29 +0000, Michael J. Mahon wrote:
>>
>>Many emulators accurately emulate the video refresh without counting
>>every CPU cycle. My emulator does this by clocking through the appropriate
>>number of 14Mhz video cycles after every instruction. I have written
>>some test software that uses refresh-synchronized video mode switching
>>to display various patterns on a real IIe, and it works on my emulator
>>as well.
>
> This is interesting. So you accurately model the extra two 14MHz
> cycles at the end of each line (the "stretched" cycle)?
Yes. The emulator keeps track of the position of the raster beam
and thus is able to do this.
> You must
> employ some optimizations so as not to have to re-scan the "screen"
> on each refresh--or maybe your objective was extreme accuracy, not
> speed.
Basically, writes to video memory cause the appropriate pixels to be
written into offscreen buffers. After every instruction, the amount
of raster beam advance (in units of 14Mhz cycles) is calculated and
that number of dots (what you might consider DHGR pixels) is copied
into the output window at appropriate locations from the offscreen
buffer corresponding to the current video mode.
This process is sped up considerably by skipping as much of the work
described above as possible when the result would look the same as
whatever was already in the output window. It ends up being quite
a bit faster than a real Apple II on my PC** even when the screen
is being changed a lot.
** Athlon XP 1800+ / Linux 2.4.18