Date : Mon, 07 Oct 2002 18:52:52 +0100
From : Richard_Talbot-Watkins@...
Subject: Re: speed
james watson wrote:
> Is it possible to speed a BBC micro up. Perhaps by disabling certain
> events or by any other method?.
If your question is "how can I get the best performance out of a Beeb?"
rather than literally "how can I speed it up?" which'd only be possible
with hardware hackery or addition of a second processor, then...
...probably the best way to increase performance is to let the OS
intervene as little as possible, and implement everything yourself with
simple optimised code.
For example, in games I wrote in the past, I completely disabled the OS
interrupt handler (apart from the tiny OS resident fragment executed at
the very start of the IRQ handling), and implemented my own, which did
a minimal number of things, in this case flagging VSync, simple sound
processing and colour interrupt/vertical rupture related stuff.
I tended not to use any OS calls for anything whatsoever - there are
often easier ways to do things:
e.g. reading a keypress -
instead of:
\\ equivalent to INKEY-99
LDA#129:LDX#256-99:LDY#255:JSR&FFF4: \\ X now contains result
to return whether or not the spacebar is pressed (I think that's
correct), with the overhead of making the slow OSBYTE call, we can
simply set up the keyboard for reading at the very start of the code
with:
LDA#15:STA&FE42:LDA#3:STA&FE40:LDA#&7F:STA&FE43
...provided the OS IRQ handler is not given a chance to run...
and then read the spacebar with:
\\ read internal key number 98
LDA#98:STA&FE4F:LDA&FE4F: \\ result is in N flag
which is about 12 clock cycles, as opposed to errr I hate to think how
many!
There are of course other tricks - all comes down to how ingenious you
can be. For example I relocated my most-used character sprite routine
to the zero page as any self-modifying code within it (loads/stores to
memory) would be modifying a zero-page location, hence shaving off ONE
WHOLE CYCLE EACH!! (It also allowed me to write one often used (xx),Y
memory access as a straightforward self-modified xxxx,Y access, which
also shaved another cycle). All these things add up if they're in the
middle of a loop of a routine which is called many times.
Good luck!
--
Rich Talbot-Watkins
SCEE Cambridge
Richard_Talbot-Watkins@...
**********************************************************************
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. If you have received this email in error please notify
postmaster@...
This footnote also confirms that this email message has been checked
for all known viruses.
**********************************************************************
SCEE 2002