bne try10
ldhx #msg02c
bra showit
;if $02
try10: cmp #$01
bne try0
ldhx #msg02b
bra showit
;if $01
try0: ldhx #msg02a
showit: jsr lcdstro
jsr del1s
;otherwise this one
;1s between pressure/altitude readings
brset 1,porta,contin ;exit only if SEL
brset 2,porta,contin ;and ENT pressed together
jmp MENU
contin: jmp LVLwarm
;__________________________________________________________
LfNx: sub N1
ldx UnitType
mul
;*** PX=f(NX,N2,N1) ***
;$A0=160 for cm, $3F=63 for in
sta NA
stx NB
clr NC
;NCNBNA:=(NX-N1)* (conversion value: 160 or 63)
;RBRA:=(NX-N1)*(conversion value)/(N2-N1)
lda N2
sub N1
sta DA
clr DB
clr DC
jsr NdivD
lda RA
cmp #$C8
bcs noovflw
ovflw: clr RA
noovflw: lda RA
rts
;check to see if result is negative
;if <$C8 we are OK
;otherwise force level to 0!
;__________________________________________________________
NdivD: clr RA
clr RB
;RBRA:=NCNBNA/DCDBDA
;destroys NCNBNA and DCDBDA
keepatit: lda RA
add #$01
sta RA
lda RB
adc #$00
sta RB
;increment RB:RA
lda NA
sub DA
sta NA
lda NB
sbc DB
sta NB
lda NC
sbc DC
sta NC
;NC:NB:NA:=NC:NB:NA-DC:DB:DA
bcc keepatit
lda RA
;keep counting how many times until overflow
sub #$01
sta RA
lda RB
sbc #$00
sta RB
;we counted once too many, so undo that
AN1950
Sensors
Freescale Semiconductor
15