Date : Mon, 08 Aug 1994 10:09:50 EST
From : Stephen Quan <quan@...>
Subject: ideas on 6845 emulation.
This is another excerpt of 1-1 mail between me and Chris :
Chris Rae writes :
> Re screen mode handling - Great idea! How are you planning on handling
> this? I have a PC assembler program which will transfer a MODE 0 PC
> screen directly onto a PC VGA screen at >25 frames/second (using all of
> my processor power). I'm really not sure what the best way of handling
> the screen is. Are you trapping all screen writes or transferring the
> whole lot now and again? I'd be interested to see someone else's view on
> this. The only two I have heard about are both spectrum emulators and
> both the authors found it quicker to copy the whole screen. Any thoughts?
> I'm really open to either idea. Copying the whole screen slows down the
> machine a lot every so often; trapping writes slows it down a little for
> every write instruction.
What I have decided to do here is, I maintain a variable that counts the
number of simulated instruction cycles that have occured. e.g. I think
INX takes 2 cycles, so what I would have there is
/* INX */
add dl,2 (or whatever register you used for the clock)
With recent testing, I have found that 1 video scanline is drawn per
64 NOP instructions (or 128 cycles). A very convenient number. So
elsewhere in my code, I have (crudely approximated here)
/* 6845??? */
test dl,dl
js rom6845
(oops forgot to say this in the email). The rom6845 routine is
responsible for knowing what mode it is in, and which scanline it is
up to. Every time it is called it will draw only what scan line it is
up to and will clear the high bit in dl. When all the required scan
lines are drawn this routine will do nothing.
A palette change or a mode change can occur even when only part of
the screen is drawn, meaning that we can possibly cater for multiple
modes trick used in some games.
A video sync will just reset the scanline number so that the next
rom6845 will start at the top again.
Any comments? I have decided to use this technique because I believe
it has the best chance to implemenet weird BBC-modes such as that used
in elite. This technique attempts to synchronise the CPU emulation with
video emulation, thus my previous thread on developing a rule of thumb.
--
Stephen Quan (quan@... ), SysAdmin, Analyst/Programmer.
Centre for Spatial Information Studies, University of Tasmania, Hobart.
GPO BOX 252C, Australia, 7001. Local Tel: (002) 202898 Fax: (002) 240282
International Callers use +6102 instead of (002).