....Continued from above.

Code:
'---[TMR1 Gate - interrupt handler]--------------------------------------------------
disable   
CheckCount:
        T1CON.0 = 0   'stop timer1
        timercount[index] = TMR1L + TMR1H << 8   'stuff the contents of the timer register into a word    
        TMR1L = 0     'reset counter to 0...
        TMR1H = 0     'upper 1/2 too

        If delay < 1001 then    'delay user access to the buttons until the count "average" has stabilized.
            delay = delay +1        
        endif    
    
        If timercount[index] > timerave[index] +70 then  'Help provide a speedy recovery for released buttons
            timerave[index] = timercount[index]
        endif
             
        if (timercount[index] - timerave[index]) < AvgCount Then Close
        timerave[index] = timerave[index] - (timerave[index]/AvgCount)    'average the count so you have a reference to compare....
        timerave[index] = timerave[index] + (timercount[index]/AvgCount)  '...with timercount
        Goto checkscore
    
        Close:
            timerave[index] = timerave[index] - (timerave[index]/(AvgCount/16))   
            timerave[index] = timerave[index] + (timercount[index]/(AvgCount/16))    
    
        Checkscore:       'Determine if a button is pressed (count is less than average)        
            If timerave[index] - (timerave[index] /50) > timercount[index] and (delay > 1000) then 
               gosub ServiceHardw 'Signal that a button is pressed. 
            endif
        
        If index < 5 then     'Increment to the next touch sensor input
           index = index +1
        else
            index = 0
        Endif
        CPSCON1 = index
     
        TMR0 = 0       'reset timer 0              
        T1CON.0 = 1  'restart timer1
 
@ INT_RETURN
enable


'----------SUBROUTINES--------------------------------
'Subroutine for Button 1-----------------------------
Butt1:
        Digit4 = 1
        gosub sortdigits
        Pause 500
        digit4 = 0
        gosub sortdigits
Return


'Subroutine for Button 2-----------------------------
Butt2:
        Digit4 = 2
        gosub sortdigits
        Pause 500
        digit4 = 0
        gosub sortdigits
Return


'Subroutine for Button 3-----------------------------
Butt3:
        Digit4 = 3
        gosub sortdigits
        Pause 500
        digit4 = 0
        gosub sortdigits
Return


'Subroutine for Button 4-----------------------------
Butt4:
        Digit4 = 4
        gosub sortdigits
        Pause 500
        digit4 = 0
        gosub sortdigits

Return


'Subroutine for Button 5-----------------------------
Butt5:
        Digit4 = 5
        gosub sortdigits
        Pause 500
        digit4 = 0
        gosub sortdigits
Return


'Subroutine for Button 6-----------------------------
Butt6:
        Digit4 = 6
        gosub sortdigits
        Pause 500
        digit4 = 0
        gosub sortdigits
Return


'Subroutine to display numbers on 7-segment display-----------
display:
          shiftout S_in, LEDCLK, 1, [LEDData]
return


'Subroutine to map numbers to the correct LED segments------
getpattern:  
       lookup numeral,[$EE,$28,$CD,$6D,$2B,$67,$E7,$2C,$EF,$6F], LEDData 'MSBFirst / Right side up digits
return


'Subroutine to read time from RTC--------------------              
gettime:  
        RST = 1         ' Ready for transfer
        ' Read all 8 RTC registers in burst mode
        Shiftout IO, SCLK, LSBFIRST, [$bf]      
        Shiftin IO, SCLK, LSBPRE, [rtcsec, rtcmin, rtchr, rtcdate, rtcmonth, rtcday, rtcyear, rtccontrol]
        RST = 0         ' Reset RTC 
        mathtemp =(rtcsec>>4)*10+(rtcsec & $0F)  'convert BCD seconds into Decimal seconds 
        digit1 = mathtemp dig 0   'digit 1 = ones of seconds
        digit2 = mathtemp dig 1   'digit 2 = tens of seconds     
        mathtemp =(rtcmin>>4)*10+(rtcmin & $0F)  'convert BCD minutes into Decimal minutess 
        digit3 = mathtemp dig 0   'digit 3 = ones of minutes
'        digit4 = mathtemp dig 1
        gosub sortdigits              
Return


'Subroutine to sort out the buttons-------------------
ServiceHardw:
        branchl index, [Butt1,Butt2,Butt3,Butt4,Butt5,Butt6]
return


' Subroutine to write time to RTC------------------------        
settime: 
        RST = 1         ' Ready for transfer
        Shiftout IO, SCLK, LSBFIRST, [$8e, 0]  ' Enable write
        RST = 0         ' Reset RTC
        RST = 1         ' Ready for transfer
            ' Write all 8 RTC registers in burst mode
        Shiftout IO, SCLK, LSBFIRST, [$be, rtcsec, rtcmin, rtchr, rtcdate, rtcmonth, rtcday, rtcyear, 0]
        rst = 0        
Return 


'Subroutine to lookup numbers and put them in the correct LED digit-----------
sortdigits:  
        numeral = digit4   
        gosub getpattern
        swap LEDData.0, LEDdata.4   'Swap "DP" and "G" segments on upsidedown digits
        gosub display    
        numeral = digit3
        gosub getpattern
        LEDData.4 = 1       'Turn on lower DP in colon
        gosub display    
        numeral = digit2
        gosub getpattern
        swap LEDData.0, LEDdata.4   'Swap "DP" and "G" segments on upsidedown digits
        LEDData.0 = 1      'Turn on upper DP in colon
        gosub display    
        numeral = digit1
        gosub getpattern
        gosub display
       High Latch
       pause 1
       low Latch
return

      
'Main loop - Gets the time and displays it----------------------------------        
main:   
        gosub gettime
        gosub sortdigits
        pause 100              
        Goto main   ' repeat until nauseated...

End

Thanks!

Steve