<< Previous Message Main Index Next Message >>
<< Previous Message in Thread This Month Next Message in Thread >>
Date   : Thu, 16 May 2002 11:15:13 +0100
From   : Sprow <news@...>
Subject: Re: BBC joystick code

In article <020516110001@...>,
   Jonathan Graham Harston <jgh@...> wrote:
> > Message-ID: <Pine.GSO.4.05.10205011005220.676-100000@...>
>  
> On Tue, 30 Apr 2002, Nic Bwts wrote:
> > I have been searching the web for people who program BBC micros because
> > I am looking for an example of some assembley code that makes use of
> > joysticks. To be more precise I am looking for examples of code that
> > make use of the analogue to digital coverter interupt routine. I have
> > read the user guides but they give no examples of the code needed to do
> > this. I hope you can help as I have been searching for two months now
>  
> Why do you need the ADC interupt?  If polling will suffice, just call
> ADVAL:
>  
> LDA #&80
> LDX #adc_channel  :\ 1, 2, 3 or 4
> JSR OSBYTE
> \ Returns YX holding ADC value
>  
> If you wnt to use the ADC Conversion Finished event, something like the
> following would do it:

[snip]

> The following code will be called on any event:
>  
> .MyEvent
> PHP                              :\ Must save all registers
> CMP #3
> BEQ MyADCEvent                   :\ Is it event 3 - ADC?
> PLP                              :\ Restore status
> JMP (OldEvent)                   :\ Chain to next handler
> .MyADCEvent                      :\ Y holds channel just converted
> PHP                              :\ Save P register
> TXA:PHA                          :\ Save X register
> TYA:PHA:TAX                      :\ Save Y and transfer channel to X
> LDA #&80:JSR OSBYTE              :\ Read the ADC value

Though you can't call OSByte from within an event handler,incase the
foreground task was already threaded part way through it.You *may* be able
to get away with stacking &EF,F0,F1,if you're lucky,
Sprow.
<< Previous Message Main Index Next Message >>
<< Previous Message in Thread This Month Next Message in Thread >>