<< Previous Message Main Index Next Message >>
<< Previous Message in Thread This Month Next Message in Thread >>
Date   : Mon, 04 Feb 2013 23:11:51 +0000
From   : tom@... (Tom Seddon)
Subject: 6502 coding request

What I'd be inclined to try personally would be to hook the timer interrupt 
and update TIME at a rate of 1+2/3 per tick. An 8-bit fractional part is 
convenient, with 2/3 then being 170+2/3. So add 256+170 (&1AA) every 3rd 
tick and 256+171 (&1AB) on the other two, which will increment TIME by 5
for every 3 ticks (&1AA+&1AB+&1AB=&500). It looks like the vector at $0314
is the one to hook for this, as it just looks like the kernal assumes this
is called at 60Hz.

Then when returning the value of TIME, ignore the fractional part, and reset
it when TIME is set.

The advantage of doing it this way is of course that you don't need to actually
do any maths or divide anything by three :) - though obviously there's now
this bit of overhead for every program, whether it accesses TIME or not.

...once again I'm wondering why the world couldn't have standardized on 64Hz.
That would have made things much easier.

--Tom

On 3 Feb 2013, at 22:59, J.G.Harston wrote:

> Want a credit in the Host interface between BBC BASIC and the Commodore 
> 64 Kernal?
> 
> The C64 Kernal counts time in 1/60s of a second. I need to convert 
> between that and counts of 1/100s of a second when read and set by TIME. 
> Sub-second errors are acceptable, as long as multiples of 6 are 
> converted to the same multiples of 10 (eg jiffy=60 becomes time=100) and 
> vis versa.
> 
> \ Jiffy to Time
> \ In,  &YYXXAA = Timer1 in 1/60s of a second
> \ Out, Timer1 in 1/100s of a second
> \      Will then be stored in (ptr),0-4
> 
> \ Time to Jiffy
> \ In,  Timer1 in 1/100s of a second
> \      Stored at (ptr),0-4
> \ Out, &YYXXAA = Timer1 in 1/60s of a second
> 
> -- 
> J.G.Harston - jgh@... - mdfs.net
> BBC BASIC for the Commodore 64 - mdfs.net/bbcbasic/C64
> 
> 
> _______________________________________________
> bbc-micro mailing list
> bbc-micro@...
> http://lists.cloud9.co.uk/mailman/listinfo/bbc-micro
<< Previous Message Main Index Next Message >>
<< Previous Message in Thread This Month Next Message in Thread >>