<< Previous Message Main Index Next Message >>
<< Previous Message in Thread This Month Next Message in Thread >>
Date   : Fri, 31 Mar 2000 19:17:27 +0100 (BST)
From   : jim <jim@...>
Subject: YABBE (LONG)

Spent ages looking for the BBC emulators mailing list before remembering
it merged with this one many moons ago ... ho hum.

Anyway, I've just spent a few days at home with the 'flu ... "I'm ill,
what can I do? I know, I'll write a Beeb emulator, that'll cheer me up."
So, in case anyone's still interested in Beeb emulation, now I've got a
rudimentary emulator, running on X11 under Linux. It's got just about
enough hardware to run BASIC; here's the list.

&FE00-&FE07 (6845 CRTC)

  Implemented though most registers are ignored. (Some of them aren't
   relevant to an emulator anyway). Only checks them every vsync, I know
   I'll have to do better some day.

&FE20-&FE2F (Video ULA)

  Control register implemented, only the Teletext and Displayed horizontal
   fields are used though. Palette is fully implemented. If you don't set
   all the palette entries the way you're supposed to you get odd effects
   (whether it's the same odd effects as a real Beeb I don't know as I
   don't have one to play with). Mode 8 worked straight off, somewhat to
   my surprise.
  Teletext is emulated though not all of the control codes work because I
   don't know what they all do (wouldn't you know it, that page is missing
   from my User's Guide).

&FE08-&FE0F (ACIA)

  Not implemented at all.

&FE40-&FE5F (System VIA)

  Partly implemented. Timer 1 and the keyboard are implemented well enough
   for OS keyboard read to work unmodified (i.e. pretty damn well ... we 
   all know how much emulator writers love the Beeb keyboard, don't we?).
   VSYNC IRQ is not passed to the processor (more due to laziness than
   programming difficulty). Other stuff isn't implemented.

&FE60-&FE6F (User VIA)

  Not implemented at all (laziness again).

&FE80-&FE9F (8271 FDC)

  Partly implemented. DFS 0.98 unmodified can load stuff off a disc image
   OK. Commands &13 (read data), &29 (seek to track) implemented fully.
   Command &2C (read drive status) always reports heads loaded, never
   index. (Yes this is going to mean that the Beeb won't notice when a
   disc is changed, I'll worry about that when I write a disc changer).
   Command &35 (Specify) and &3A (Write special register) accepted but
   the actual values written are ignored.

&FEA0-&FEBF (68B54 ADLC)

  Not implemented at all.

&FEC0-&FEDF (ADC)

  Not implemented at all.

&FEE0-&FEFF (Tube ULA)

  Not implemented at all.


Emulator:

Is cycle-driven rather than instruction-driven, meaning that each cycle it
performs a memory operation and an ALU operation taken from a Bloody Huge
Jump Table(tm). Thus it actually does do some of the wacky things a real
6502 does like always reading 2 bytes even for a 1-byte instruction, and
performing instruction fetch on the same cycle as a previous ALU op and
register write-back. "64doc" which I imagine many of you will have come
across was incredibly useful here. Instruction timings follow on
naturally from this way of doing stuff. The C code is horrible (I did say
the whole thing was written in C, didn't I?) but c'est la vie.

Basic 6502 instructions are all implemented, apart from decimal mode which
I haven't quite got around to yet 8-). 65C12 / undocumented opcodes aren't
done yet, most of them shouldn't be a bother as they're just combinations
of existing operations. IRQ/NMI really do take 7 cycles because I do them
in exactly the same way as real instructions.  (Reset doesn't but I'm not
really bothered). 


Problems:

It is --V--E--R--Y-- --S--L--O--W-- . About half-a-Beeb on my 350MHz K6-2
which I think ought to get more than a Beeb without breaking a sweat. To
be honest I think a lot of that is video -- I can refresh a 640x512 X
window at 50Hz but it doesn't leave a lot of time for anything else. If
you drop the refresh and just run the core emulator flat out it goes at
about 6MHz which is getting towards more of a decent speed (and I know my
wacky emulation architecture slows it down somewhat). Then again, I
haven't done any serious profiling or code optimisation yet. Dropping the
X refresh rate ought to help ... 

Games don't work! 8-) Most of them rely on VIA timers I haven't
implemented yet, so no surprise there. Snapper helpfully gives me the
message "IC 69 missing / faulty", but doesn't consider the possibility
"not implemented" 8-)

X keyboard handling and Beeb keyboard handling don't work too well
together. I've got a mapping based on the PC keycaps rather than the
position of the keys, though I want to add the latter as an option for
games.

I think there's a bug in the emulator. If you let BASIC execute "FOR I%=0
TO 1000:P.I%:NEXT" occasionally the value printed out isn't quite an
integer. I'm wondering if it has something to do with interrupt handling.



How is everybody doing video? I think I've figured out how it's actually
done, why the Beeb uses such a weird format for colour pixels and what
strange effects you get if you set the palette wrong, but I'd like to have
it confirmed.

Oddly enough, most Beeb hardware seems to make sense if you bash your
brain against it hard enough ... or if you drink enough ...


Wishlist

More hardware!
A debugger. A good one, so I can interrupt the processor at any point and
see where it's going wrong.
Some kind of Unix filing system.
A disc changer for disc images.
Much much faster code.


Good Lord, that was long, wasn't it? I'll go away now. I have the code
with me but not on-line yet, I'll probably do that next week.

jim
-- 
http://madeira.physiol.ucl.ac.uk/people/jim/
  "Revenge is an integral part of forgiving and forgetting" -The BOFH



<< Previous Message Main Index Next Message >>
<< Previous Message in Thread This Month Next Message in Thread >>