[Coco] CoCo joystk() Routine
Joel Ewy
jcewy at swbell.net
Fri Dec 7 10:29:29 EST 2007
Thanks Robert, that's what I was looking for. Wouldn't tightening up
this routine also have a (linear) effect on overall runtime? Looks like
I'd better take a look at the 'Unravelled' book.
JCE
Robert Gault wrote:
> Joel Ewy wrote:
>> Hey all,
>>
>> I seem to remember something about the CoCo BASIC ROM sampling all
>> joystick axes when you use joystk() to read one of them. Is there a
>> relatively simple fix for that (assuming CoCo 3 or 64K CoCo 1/2 in
>> all-RAM mode of course)?
>>
>> JCE
>>
>
> With a caveat, what you want can be done. First, the only reason for
> doing this would be you can't sample fast enough for your purpose. If
> that is the case, you can only get a speed-up by a factor of 4 by
> sampling a single stick and axis. Second, the ROM routine samples 10
> times to make sure there is no "bounce" in the results. You might
> choose to sample all four sticks but fewer times to get a good value.
> Third, the ROM only samples the sticks when you request data for
> axis#0. otherwise it just reads stored values. Fresh values require
> all four axis to be read.
>
> The joystick routine is at $A9CA-$AA19. It can be separated into
> several parts. 1) Check for illegal axis #. 2) Check for axis#0 to
> select refresh or stored data read. 3) Sample an axis 10 times for a
> match. 4) Shift to next axis. You probably will want to keep 1) and 3)
> but discard 2) and 4), if I read your request correctly.
> So, at $A9D0 is a bne $A9D4 which needs to be changed to a brn or
> completely nop'd out to remove 1). For a single byte correction, POKE
> &HA9D0,&H21.
> At $A9E3 there is a ldb #3 which preselects the axis to be read and
> will later be decremented to get all axes. Here you must enter the
> specific axis you want read, 0, 1, 2, or 3; POKE &HA9E4,axis#. This
> must be changed each time you want to select a different axis. At
> $AA17, is a bpl $A9E5 if all axes have not been read. This needs to be
> a brn or nop'd so POKE &HAA17,&H21. Now 4) has been removed from the
> ROM routine.
>
> --
> Coco mailing list
> Coco at maltedmedia.com
> http://five.pairlist.net/mailman/listinfo/coco
>
More information about the Coco
mailing list