Date : Thu, 30 Nov 1995 12:20:21 +0000 (GMT)
From : James Fidell <james@...>
Subject: Re: Some emulator problems
Tom Seddon wrote:
> I wasn't on the old BBC emulators mailing list, but I've decided now
> to plunge in and write myself an emulator. I'll be using 386
> assembler and C, although at the moment I've got a 'practice' version
> in 100% C up and running (slowly). I'm having a problem with my
> keyboard support though... would anyone be able to help?
>
> As I don't have 6522 support, I have a hack for OSRDCH which calls
> getch(). This is not especially brilliant, but it seems to work...
> except for the Esc key! My osrdch() hack is as follows:
>
> ('a' is the accumulator (unsigned char)
> 'c' is the carry flag (I use separate variables for each flag))
>
> void osrdch(void)
> {
> int k;
>
> k=getch();
> if(k==8) k=127; //check for backspace key
> c=(k==27); //set carry flag if ESC pressed
> a=k;
> }
>
> This routine is called using an illegal opcode, which I have poked
> into the start of the OSRDCH code at &DEC5. Unfortunately it doesn't
> work properly, or more specifically the Escape key doesn't work.
> Pressing Escape when at the > prompt just creates another prompt,
> but not a new line (so you end up with '>>>>>'). Something similar
> happens with AUTO as well.
I'm guessing slightly here, but possibly this might be due to the
way you're handling the BRK instruction rather than anything directly
to do with keyboard handling.
Does the same sort of problem occur when you generate a syntax error
from BASIC ? It's possible this could even completely crash the
emulator.
Escape causes an error which executes a BRK instruction to jump to the
OS error-handler.
James.
--
"Yield to temptation -- | Work: james@...
it may not pass your way again" | Play: james@...
| http://www.OiT.co.uk/~james/
- Lazarus Long | James Fidell