WARNING: EXTCODE CODE AREA DO NOT CONTAIN RELOCATED ADDRESSES.
THIS WILL BE REMEDIED IN A LATER RELEASE.
                        .module putchar_dp256.c
                        .area text
                ;              c -> 3,x
 102A            _putchar::
 102A  3B                pshd
 102B  34                pshx
 102C  B775              tfr s,x
 102E            ; #include <stdio.h>
 102E            ; #define _SCI
 102E            ; #include <hcs12dp256.h>
 102E            ; extern int _textmode;
 102E            ; int putchar(char c)
 102E            ; {
 102E            ;      if (_textmode && c == '\n')
 102E  FC1969            ldd __textmode
 1031  270C              beq L7
 1033  E603              ldab 3,x
 1035  C10A              cmpb #10
 1037  2606              bne L7
 1039            ;       putchar('\r');
 1039  CC000D            ldd #13
 103C  16102A            jsr _putchar
 103F            L6:
 103F            L7:
 103F            ;      while ((SC0SR1 & TDRE) == 0)
 103F  1F00CC80FB        brclr 0xcc,#128,L6
 1044            ;        ;
 1044            ;      SC0DRL = c;
 1044  180D0300CF        movb 3,x,0xcf
 1049            ;      return c;
 1049  E603              ldab 3,x
 104B  87                clra
 104C            L3:
 104C  B757              tfr x,s
 104E  30                pulx
 104F  1B82              leas 2,sp
 1051                    .dbline 0 ; func end
 1051  3D                rts
                        .module mike_2.c
                        .area memory(abs)
                        .org 0x3e5e
 3E5E            _IRQ_TOF_vector::
 3E5E  12B2              .word _TOF_isr
                        .area data
                        .area memory(abs)
                        .org 0x3e52
 3E52            _IRQ_ATD0_vector::
 3E52  1418              .word _ATD0_Interrupt
                        .area data
                        .area memory(abs)
                        .org 0x3e50
 3E50            _IRQ_ATD1_vector::
 3E50  1465              .word _ATD1_Interrupt
                        .area data
                        .area memory(abs)
                        .org 0x3e64
 3E64            _IRQ_OC5_vector::
 3E64  15F4              .word _OC5_ISR
                        .area data
                        .area memory(abs)
                        .org 0x3e6e
 3E6E            _IRQ_IC0_vector::
 3E6E  16A1              .word _IC0_ISR
                        .area data
                        .area memory(abs)
                        .org 0x3e6c
 3E6C            _IRQ_IC1_vector::
 3E6C  16B6              .word _IC1_ISR
                        .area data
                        .area text
 1052            _line_threshold::
 1052  005A              .word 90
 1054            _Intersection_threshold::
 1054  003C              .word 60
 1056            _Backup_threshold::
 1056  005A              .word 90
 1058            ;              b -> -4,x
 1058            ;              a -> -2,x
 1058            _main::
 1058  34                pshx
 1059  B775              tfr s,x
 105B  1B9C              leas -4,sp
 105D            ; //*****************************************************************************
 105D            ; // Name:                              2007 Line Track code
 105D            ; // Vers:                          0.1
 105D            ; // Last Revised:              1/27/07 10:16pm
 105D            ; //*****************************************************************************                                       
 105D            ; 
 105D            ; #include<mc9S12dp256.h>
 105D            ; #include<stdio.h>
 105D            ; 
 105D            ; //define 16 bit PWM registers
 105D            ; #define PWMPERW1 _LP(0xB4) 
 105D            ; #define PWMPERW3 _LP(0xB6)
 105D            ; #define PWMPERW5 _LP(0xB8)
 105D            ; #define PWMPERW7 _LP(0xBA)
 105D            ; 
 105D            ; #define PWMDTYW1 _LP(0xBC)
 105D            ; #define PWMDTYW3 _LP(0xBE)
 105D            ; #define PWMDTYW5 _LP(0xC0)
 105D            ; #define PWMDTYW7 _LP(0xC2)
 105D            ; 
 105D            ; // Function Prototypes
 105D            ; void init_pwm(void);
 105D            ; void init_timer(void);
 105D            ; void ob_led(int);
 105D            ; void pause(int);
 105D            ; void s_pause(int);
 105D            ; void init_tof(void);
 105D            ; void init_atd0(void);
 105D            ; void init_atd1(void);
 105D            ; void Speaker(void);
 105D            ; void stop(void);
 105D            ; void forward(void);
 105D            ; void reverse(void);
 105D            ; void left(void);
 105D            ; void right(void);
 105D            ; void motorspeed(void);
 105D            ; void speedcontrol(void);
 105D            ; void linetrack(int);
 105D            ; 
 105D            ; //General 
 105D            ; #define CLI asm("CLI")
 105D            ; #define SEI asm("SEI")
 105D            ; 
 105D            ; //TOF Interrupt Setup
 105D            ; void TOF_isr(void); 
 105D            ; #pragma interrupt_handler TOF_isr
 105D            ; #pragma abs_address: 0x3e5e
 105D            ; void (*IRQ_TOF_vector[])()={TOF_isr};
 105D            ; #pragma end_abs_address
 105D            ; 
 105D            ; //ATD0 Interrupt Setup
 105D            ; void ATD0_Interrupt();
 105D            ; #pragma interrupt_handler ATD0_Interrupt()
 105D            ; #pragma abs_address: 0x3E52
 105D            ; void (*IRQ_ATD0_vector[])()={ATD0_Interrupt};
 105D            ; #pragma end_abs_address
 105D            ; 
 105D            ; //ATD1 Interrupt Setup
 105D            ; void ATD1_Interrupt();
 105D            ; #pragma interrupt_handler ATD1_Interrupt()
 105D            ; #pragma abs_address: 0x3E50
 105D            ; void (*IRQ_ATD1_vector[])()={ATD1_Interrupt};
 105D            ; #pragma end_abs_address
 105D            ; 
 105D            ; //OC5 Interrupt Setup
 105D            ; void OC5_ISR();
 105D            ; #pragma interrupt_handler OC5_ISR()
 105D            ; #pragma abs_address: 0x3E64
 105D            ; void (*IRQ_OC5_vector[])()={OC5_ISR};
 105D            ; #pragma end_abs_address
 105D            ; 
 105D            ; //IC0 Interrupt Setup
 105D            ; void IC0_ISR();
 105D            ; #pragma interrupt_handler IC0_ISR()
 105D            ; #pragma abs_address: 0x3E6E
 105D            ; void (*IRQ_IC0_vector[])()={IC0_ISR};
 105D            ; #pragma end_abs_address
 105D            ; 
 105D            ; //IC1 Interrupt Setup
 105D            ; void IC1_ISR();
 105D            ; #pragma interrupt_handler IC1_ISR()
 105D            ; #pragma abs_address: 0x3E6C
 105D            ; void (*IRQ_IC1_vector[])()={IC1_ISR};
 105D            ; #pragma end_abs_address
 105D            ; 
 105D            ; //declare global variable
 105D            ; long int t_counts;
 105D            ; long int t_tenths;
 105D            ; long int t_hundredths;
 105D            ; unsigned int atd0[8];
 105D            ; unsigned int atd1[8];
 105D            ; int dela;
 105D            ; int line;
 105D            ; const line_threshold = 90;
 105D            ; unsigned int IC0_last;
 105D            ; unsigned int IC1_last;
 105D            ; unsigned int IC0_speed;
 105D            ; unsigned int IC1_speed;
 105D            ; int Intersection;
 105D            ; const Intersection_threshold = 60; 
 105D            ; int Backup;
 105D            ; const Backup_threshold = 90;
 105D            ; 
 105D            ; void main(void)
 105D            ; {
 105D            ;    int a,b; 
 105D            ;    init_pwm();
 105D  1611E2            jsr _init_pwm
 1060            ;    init_tof();
 1060  16129E            jsr _init_tof
 1063            ;    init_atd0();
 1063  161404            jsr _init_atd0
 1066            ;    init_atd1();
 1066  161451            jsr _init_atd1
 1069            ; //   init_ic0_1();
 1069            ;    pause(1);
 1069  CC0001            ldd #1
 106C  16137E            jsr _pause
 106F            ;    
 106F            ;    ATD0CTL5 = 0x30;    //start atd's
 106F  C630              ldab #48
 1071  7B0085            stab 0x85
 1074            ;    ATD1CTL5 = 0x30;
 1074  C630              ldab #48
 1076  7B0125            stab 0x125
 1079            ;      
 1079            ;    pause(1);             //pause to allow atd to read first time;
 1079  CC0001            ldd #1
 107C  16137E            jsr _pause
 107F            ;    
 107F            ;    ob_led(15);
 107F  CC000F            ldd #15
 1082  1611A7            jsr _ob_led
 1085            L4:
 1085            L5:
 1085            ;    
 1085            ;    while(atd0[3] > 10);		   //wait for S2 switch to be pressed
 1085  FC1953            ldd _atd0+6
 1088  8C000A            cpd #10
 108B  22F8              bhi L4
 108D            ;    ob_led(14);
 108D  CC000E            ldd #14
 1090  1611A7            jsr _ob_led
 1093            ;    pause(50);
 1093  CC0032            ldd #50
 1096  16137E            jsr _pause
 1099            ;       
 1099            ;    forward(); 
 1099  16125F            jsr _forward
 109C            ;    pause(8);
 109C  CC0008            ldd #8
 109F  16137E            jsr _pause
 10A2  2027              bra L9
 10A4            L8:
 10A4  16124A            jsr _reverse
 10A7  CC000D            ldd #13
 10AA  1611A7            jsr _ob_led
 10AD  CC000A            ldd #10
 10B0  16137E            jsr _pause
 10B3  CC0001            ldd #1
 10B6  161603            jsr _linetrack
 10B9  CC000C            ldd #12
 10BC  1611A7            jsr _ob_led
 10BF  161235            jsr _stop
 10C2  CC0014            ldd #20
 10C5  16137E            jsr _pause
 10C8  161558            jsr _Speaker
 10CB            L9:
 10CB            ; 	 
 10CB            ; 	 
 10CB            ; while(1)
 10CB  20D7              bra L8
 10CD            L11:
 10CD            ; {
 10CD            ;  		reverse();
 10CD            ; 		ob_led(13);
 10CD            ; 		pause(10);
 10CD            ;  		linetrack(1);
 10CD            ; 		ob_led(12);
 10CD            ; 		stop();
 10CD            ; 		pause(20);
 10CD            ; 		Speaker();
 10CD            ; }
 10CD            ; 	 
 10CD            ;  
 10CD            ; 	 
 10CD            ; while(1)
 10CD            ; {	 
 10CD            ; 	 linetrack(0);  			   //linetrack to T
 10CD  CC0000            ldd #0
 10D0  161603            jsr _linetrack
 10D3            ;        
 10D3            ;        ob_led(11);
 10D3  CC000B            ldd #11
 10D6  1611A7            jsr _ob_led
 10D9            ;      forward();                                  //center robot on line         
 10D9  16125F            jsr _forward
 10DC            ;        pause(5);
 10DC  CC0005            ldd #5
 10DF  16137E            jsr _pause
 10E2            ;        //stop();        
 10E2            ;        //pause(5);
 10E2            ;        
 10E2            ;        left();                                   //turn till sensor on line
 10E2  161289            jsr _left
 10E5  2006              bra L15
 10E7            L14:
 10E7  FC1939            ldd _line
 10EA  1611A7            jsr _ob_led
 10ED            L15:
 10ED            ; 	 while(line==0)
 10ED  FC1939            ldd _line
 10F0  27F5              beq L14
 10F2            ;        {
 10F2            ;           ob_led(line);
 10F2            ;               
 10F2            ;        }
 10F2            ;        
 10F2            ;        linetrack(0);                     //linetrack to 4 way intersection
 10F2  CC0000            ldd #0
 10F5  161603            jsr _linetrack
 10F8            ; 
 10F8            ;        ob_led(10);
 10F8  CC000A            ldd #10
 10FB  1611A7            jsr _ob_led
 10FE            ;      forward();                                  //center robot on line         
 10FE  16125F            jsr _forward
 1101            ;        pause(7);
 1101  CC0007            ldd #7
 1104  16137E            jsr _pause
 1107            ;        stop();        
 1107  161235            jsr _stop
 110A            ;       left();                                    //turn till sensor on line heading towards
 110A  161289            jsr _left
 110D            ;        pause(10);
 110D  CC000A            ldd #10
 1110  16137E            jsr _pause
 1113            ;        //pause(8);
 1113            ;      //stop();          
 1113            ;       // pause(5);
 1113            ;        
 1113            ;        
 1113            ;                         //ball request zone
 1113            ;       
 1113            ;        stop();          //addendum
 1113  161235            jsr _stop
 1116            ;        pause(5);    //
 1116  CC0005            ldd #5
 1119  16137E            jsr _pause
 111C            ;        
 111C            ;        forward();   //
 111C  16125F            jsr _forward
 111F            ;        pause(1);   //
 111F  CC0001            ldd #1
 1122  16137E            jsr _pause
 1125  2006              bra L18
 1127            L17:
 1127  FC1939            ldd _line
 112A  1611A7            jsr _ob_led
 112D            L18:
 112D  FC1939            ldd _line
 1130  27F5              beq L17
 1132  161235            jsr _stop
 1135  CC0005            ldd #5
 1138  16137E            jsr _pause
 113B  CC0000            ldd #0
 113E  161603            jsr _linetrack
 1141  161235            jsr _stop
 1144  CC0005            ldd #5
 1147  16137E            jsr _pause
 114A  16124A            jsr _reverse
 114D  CC0005            ldd #5
 1150  16137E            jsr _pause
 1153  CC0001            ldd #1
 1156  161603            jsr _linetrack
 1159  161235            jsr _stop
 115C  CC0005            ldd #5
 115F  16137E            jsr _pause
 1162  16124A            jsr _reverse
 1165  CC000A            ldd #10
 1168  16137E            jsr _pause
 116B  CC0001            ldd #1
 116E  161603            jsr _linetrack
 1171  161235            jsr _stop
 1174  CC000A            ldd #10
 1177  16137E            jsr _pause
 117A  161558            jsr _Speaker
 117D            L12:
 117D  1820FF4C          lbra L11
 1181            L20:
 1181            L21:
 1181            ;    
 1181            ; 	 while(line==0)        
 1181            ; 	 {
 1181            ; 	    ob_led(line);
 1181            ; 		
 1181            ; 	 }  
 1181            ; 	 
 1181            ; 	 stop();
 1181            ; 	 pause(5);
 1181            ; 	 
 1181            ; 	 linetrack(0);	 		   // get to ball request zone
 1181            ; 	 
 1181            ; 
 1181            ; 	 stop();
 1181            ; 	 pause(5);
 1181            ; 	 reverse();				   // head back to 4 way intersection
 1181            ; 	 pause(5);
 1181            ; 	  
 1181            ; 	 linetrack(1);
 1181            ; 	 
 1181            ; 	 stop();	  			   // at 4 way
 1181            ; 	 pause(5);  
 1181            ; 	 
 1181            ; 	 reverse();	  			   
 1181            ; 	 pause(10);
 1181            ; 	 
 1181            ; 	 linetrack(1);			   //head to rebound zone and stop 
 1181            ; 	 
 1181            ; 	 stop();
 1181            ; 	 pause(10);
 1181            ; 	 
 1181            ;     Speaker();
 1181            ; 	// printf ("line = %d %d\n\r",atd1[7],atd1[6]);
 1181            ; }
 1181            ; while(1);
 1181  20FE              bra L20
 1183            X0:
 1183            ; }
 1183            L3:
 1183  B757              tfr x,s
 1185  30                pulx
 1186                    .dbline 0 ; func end
 1186  3D                rts
 1187            L24:
 1187  003F              .word 63
 1189  0006              .word 6
 118B  005B              .word 91
 118D  004F              .word 79
 118F  0066              .word 102
 1191  006D              .word 109
 1193  007D              .word 125
 1195  0007              .word 7
 1197  007F              .word 127
 1199  006F              .word 111
 119B  0077              .word 119
 119D  007C              .word 124
 119F  0039              .word 57
 11A1  005E              .word 94
 11A3  0079              .word 121
 11A5  0071              .word 113
 11A7            ;            out -> -32,x
 11A7            ;              t -> 2,x
 11A7            _ob_led::
 11A7  3B                pshd
 11A8  34                pshx
 11A9  B775              tfr s,x
 11AB  1BF1DE            leas -34,sp
 11AE            ; 
 11AE            ; 
 11AE            ; // Display value passed to function on on board 7-seg LED of MiniDragon Board
 11AE            ; void ob_led(int t)               
 11AE            ; {
 11AE            ; 
 11AE            ;   int out[16] = {0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f,0x77,0x7c,
 11AE  19E1E0            leay -32,x
 11B1  B7C6              xgdy
 11B3  CD1187            ldy #L24
 11B6  34                pshx
 11B7  B745              tfr d,x
 11B9  CC0010            ldd #16
 11BC            X1:
 11BC  18027131          movw 2,y+,2,x+
 11C0  0434F9            dbne d,X1
 11C3  30                pulx
 11C4            ;     0x39,0x5e,0x79,0x71};
 11C4            ;   
 11C4            ;   DDRH=0xff;
 11C4  C6FF              ldab #255
 11C6  7B0262            stab 0x262
 11C9            ;   
 11C9            ;   PTH=out[t];
 11C9  19E1E0            leay -32,x
 11CC  6DE1DE            sty -34,x
 11CF  EC02              ldd 2,x
 11D1  59                lsld
 11D2  E3E1DE            addd -34,x
 11D5  B7C6              xgdy
 11D7  EC40              ldd 0,y
 11D9  7B0260            stab 0x260
 11DC            ; 
 11DC            ;   
 11DC            ; }
 11DC            L23:
 11DC  B757              tfr x,s
 11DE  30                pulx
 11DF  1B82              leas 2,sp
 11E1                    .dbline 0 ; func end
 11E1  3D                rts
 11E2            _init_pwm::
 11E2            ; 
 11E2            ; // Set up 4-16bit PWM 
 11E2            ; void init_pwm()
 11E2            ; {
 11E2            ;   PWMTST = 0x00; 		   			  // turn off all PWM special Modes
 11E2  7900A6            clr 0xa6
 11E5            ;   PWMCAE = 0x00;                                        // PWM left aligned output mode 
 11E5  7900A4            clr 0xa4
 11E8            ;   PWMCTL = 0xf0;                                        // Use Concatenated Mode (16-bit)
 11E8  C6F0              ldab #240
 11EA  7B00A5            stab 0xa5
 11ED            ;   
 11ED            ;   
 11ED            ;   PWMPRCLK = 0x33;                                      // E/8 for A and B       
 11ED  C633              ldab #51
 11EF  7B00A3            stab 0xa3
 11F2            ;   
 11F2            ;   PWMCLK = 0x00;                                        // PW Chan 1, 5 clock A
 11F2  7900A2            clr 0xa2
 11F5            ;                                                                         // PW chan 3, 7 clock B
 11F5            ;                                                                         
 11F5            ;   PWMPOL= 0xaa;                                                 // High Polarity for all channels
 11F5  C6AA              ldab #170
 11F7  7B00A1            stab 0xa1
 11FA            ;   DDRP= 0xaa;                                           // Set Port P to output 
 11FA  C6AA              ldab #170
 11FC  7B025A            stab 0x25a
 11FF            ; 
 11FF            ;   PWMPERW1 = 60000;                                     //stop (7.5%) all motors
 11FF  CCEA60            ldd #0xea60
 1202  7C00B4            std 0xb4
 1205            ;   PWMDTYW1 = 4500;                                      //<- in theory this value should be 4500
 1205  CC1194            ldd #4500
 1208  7C00BC            std 0xbc
 120B            ;   
 120B            ;   PWMPERW3 = 60000;                                   
 120B  CCEA60            ldd #0xea60
 120E  7C00B6            std 0xb6
 1211            ;   PWMDTYW3 = 4500;                                      //<- in theory this value should be 4500
 1211  CC1194            ldd #4500
 1214  7C00BE            std 0xbe
 1217            ;   
 1217            ;   PWMPERW5 = 60000;                                   
 1217  CCEA60            ldd #0xea60
 121A  7C00B8            std 0xb8
 121D            ;   PWMDTYW5 = 4500;                    
 121D  CC1194            ldd #4500
 1220  7C00C0            std 0xc0
 1223            ; 
 1223            ;   PWMPERW7 = 60000;                                    
 1223  CCEA60            ldd #0xea60
 1226  7C00BA            std 0xba
 1229            ;   PWMDTYW7 = 4500;
 1229  CC1194            ldd #4500
 122C  7C00C2            std 0xc2
 122F            ;   PWME= 0xaa;                                           // Enable ALL PWM Channels
 122F  C6AA              ldab #170
 1231  7B00A0            stab 0xa0
 1234            ; 
 1234            ; }
 1234            L25:
 1234                    .dbline 0 ; func end
 1234  3D                rts
 1235            _stop::
 1235            ; 
 1235            ; // Stop
 1235            ; void stop()
 1235            ; {
 1235            ;    PWME = 0x00;
 1235  7900A0            clr 0xa0
 1238            ;    PWMDTYW1 = 4500;                                           //4400
 1238  CC1194            ldd #4500
 123B  7C00BC            std 0xbc
 123E            ;    PWMDTYW3 = 4500;                                           //4600
 123E  CC1194            ldd #4500
 1241  7C00BE            std 0xbe
 1244            ;    PWME = 0xaa;
 1244  C6AA              ldab #170
 1246  7B00A0            stab 0xa0
 1249            ; }
 1249            L26:
 1249                    .dbline 0 ; func end
 1249  3D                rts
 124A            _reverse::
 124A            ;    
 124A            ; // reverse
 124A            ; void reverse()
 124A            ; {
 124A            ;    PWME = 0x00;
 124A  7900A0            clr 0xa0
 124D            ;    PWMDTYW1 = 4000;                   //half full speed forward 4876//
 124D  CC0FA0            ldd #4000
 1250  7C00BC            std 0xbc
 1253            ;    PWMDTYW3 = 5000;                   //half full speed reverse 4125//
 1253  CC1388            ldd #5000
 1256  7C00BE            std 0xbe
 1259            ;    PWME = 0xaa;
 1259  C6AA              ldab #170
 125B  7B00A0            stab 0xa0
 125E            ; }
 125E            L27:
 125E                    .dbline 0 ; func end
 125E  3D                rts
 125F            _forward::
 125F            ; // forward
 125F            ; void forward()
 125F            ; {
 125F            ;    PWME = 0x00;
 125F  7900A0            clr 0xa0
 1262            ;    PWMDTYW1 = 5000;                                   //half full speed reverse//
 1262  CC1388            ldd #5000
 1265  7C00BC            std 0xbc
 1268            ;    PWMDTYW3 = 4000;                                   //half full speed forward//
 1268  CC0FA0            ldd #4000
 126B  7C00BE            std 0xbe
 126E            ;    PWME = 0xaa;
 126E  C6AA              ldab #170
 1270  7B00A0            stab 0xa0
 1273            ; }
 1273            L28:
 1273                    .dbline 0 ; func end
 1273  3D                rts
 1274            _right::
 1274            ;    
 1274            ; // right
 1274            ; void right()
 1274            ; {
 1274            ;    PWME = 0x00;
 1274  7900A0            clr 0xa0
 1277            ;    PWMDTYW1 = 5000;                           //orignal speed 5250//
 1277  CC1388            ldd #5000
 127A  7C00BC            std 0xbc
 127D            ;    PWMDTYW3 = 5000;                           //orignal speed 5250//
 127D  CC1388            ldd #5000
 1280  7C00BE            std 0xbe
 1283            ;    PWME = 0xaa;
 1283  C6AA              ldab #170
 1285  7B00A0            stab 0xa0
 1288            ; }
 1288            L29:
 1288                    .dbline 0 ; func end
 1288  3D                rts
 1289            _left::
 1289            ; 
 1289            ; // left
 1289            ; void left()
 1289            ; {
 1289            ;    PWME = 0x00;
 1289  7900A0            clr 0xa0
 128C            ;    PWMDTYW1 = 4000;                           //orignal speed 3750//
 128C  CC0FA0            ldd #4000
 128F  7C00BC            std 0xbc
 1292            ;    PWMDTYW3 = 4000;                           //orignal speed 3750//
 1292  CC0FA0            ldd #4000
 1295  7C00BE            std 0xbe
 1298            ;    PWME = 0xaa;
 1298  C6AA              ldab #170
 129A  7B00A0            stab 0xa0
 129D            ; }
 129D            L30:
 129D                    .dbline 0 ; func end
 129D  3D                rts
 129E            _init_tof::
 129E            ; 
 129E            ; //Initialize Timer Overflow 
 129E            ; void init_tof()
 129E            ; {
 129E            ;    SEI;
 129E  1410                      SEI
 12A0            
 12A0            ;    TSCR1 = 0x80;                                        //turn on Timer
 12A0  C680              ldab #128
 12A2  7B0046            stab 0x46
 12A5            ;    TFLG2 = 0x80;                                        //clear TOF flag
 12A5  C680              ldab #128
 12A7  7B004F            stab 0x4f
 12AA            ;    TSCR2 = 0x80;                                        //turn on TOF interrupt
 12AA  C680              ldab #128
 12AC  7B004D            stab 0x4d
 12AF            ;    CLI;
 12AF  10EF                      CLI
 12B1            
 12B1            ; }
 12B1            L31:
 12B1                    .dbline 0 ; func end
 12B1  3D                rts
 12B2            ;  lreg1 -> -4,x
 12B2            ;  lreg2 -> -8,x
 12B2            _TOF_isr::
 12B2  34                pshx
 12B3  B775              tfr s,x
 12B5  1B98              leas -8,sp
 12B7            ; 
 12B7            ; //Timer Overflow Counter (ISR)
 12B7            ; void TOF_isr()  
 12B7            ; {
 12B7            ;    t_counts++;
 12B7  CD1965            ldy #_t_counts
 12BA  1802401C          movw 0,y,-4,x
 12BE  1802421E          movw 2,y,-2,x
 12C2  CD16D7            ldy #L33
 12C5  18024018          movw 0,y,-8,x
 12C9  1802421A          movw 2,y,-6,x
 12CD  161767            jsr __ladd
 12D0  CD1965            ldy #_t_counts
 12D3  18021C40          movw -4,x,0,y
 12D7  18021E42          movw -2,x,2,y
 12DB            ;    if ((t_counts%38)==0)
 12DB  CD1965            ldy #_t_counts
 12DE  1802401C          movw 0,y,-4,x
 12E2  1802421E          movw 2,y,-2,x
 12E6  CD16D3            ldy #L36
 12E9  18024018          movw 0,y,-8,x
 12ED  1802421A          movw 2,y,-6,x
 12F1  161836            jsr __lmod
 12F4  CD16CF            ldy #L37
 12F7  18024018          movw 0,y,-8,x
 12FB  1802421A          movw 2,y,-6,x
 12FF  161908            jsr __lcmp
 1302  2624              bne L34
 1304            ;    {
 1304            ;         t_tenths++;
 1304  CD1961            ldy #_t_tenths
 1307  1802401C          movw 0,y,-4,x
 130B  1802421E          movw 2,y,-2,x
 130F  CD16D7            ldy #L33
 1312  18024018          movw 0,y,-8,x
 1316  1802421A          movw 2,y,-6,x
 131A  161767            jsr __ladd
 131D  CD1961            ldy #_t_tenths
 1320  18021C40          movw -4,x,0,y
 1324  18021E42          movw -2,x,2,y
 1328            ;    }
 1328            L34:
 1328            ;    if ((t_counts%4)==0)
 1328  CD1965            ldy #_t_counts
 132B  1802401C          movw 0,y,-4,x
 132F  1802421E          movw 2,y,-2,x
 1333  CD16CB            ldy #L40
 1336  18024018          movw 0,y,-8,x
 133A  1802421A          movw 2,y,-6,x
 133E  161836            jsr __lmod
 1341  CD16CF            ldy #L37
 1344  18024018          movw 0,y,-8,x
 1348  1802421A          movw 2,y,-6,x
 134C  161908            jsr __lcmp
 134F  2624              bne L38
 1351            ;    {
 1351            ;       t_hundredths++;
 1351  CD195D            ldy #_t_hundredths
 1354  1802401C          movw 0,y,-4,x
 1358  1802421E          movw 2,y,-2,x
 135C  CD16D7            ldy #L33
 135F  18024018          movw 0,y,-8,x
 1363  1802421A          movw 2,y,-6,x
 1367  161767            jsr __ladd
 136A  CD195D            ldy #_t_hundredths
 136D  18021C40          movw -4,x,0,y
 1371  18021E42          movw -2,x,2,y
 1375            ;    }
 1375            L38:
 1375            ;    
 1375            ;    TFLG2 = 0x80;
 1375  C680              ldab #128
 1377  7B004F            stab 0x4f
 137A            ; }
 137A            L32:
 137A  B757              tfr x,s
 137C  30                pulx
 137D                    .dbline 0 ; func end
 137D  0B                rti
 137E            ;  lreg1 -> -4,x
 137E            ;  lreg2 -> -8,x
 137E            ;       end_time -> -12,x
 137E            ;     pause_time -> 2,x
 137E            _pause::
 137E  3B                pshd
 137F  34                pshx
 1380  B775              tfr s,x
 1382  1B94              leas -12,sp
 1384            ; 
 1384            ; //pause for pause_time*0.1 sec
 1384            ; void pause(int pause_time)
 1384            ; {
 1384            ;    long int end_time;
 1384            ;    end_time = t_tenths + pause_time;
 1384  CD1961            ldy #_t_tenths
 1387  1802401C          movw 0,y,-4,x
 138B  1802421E          movw 2,y,-2,x
 138F  EC02              ldd 2,x
 1391  16171F            jsr __d2lreg2
 1394  161767            jsr __ladd
 1397  1914              leay -12,x
 1399  18021C40          movw -4,x,0,y
 139D  18021E42          movw -2,x,2,y
 13A1            L42:
 13A1            L43:
 13A1            ; //   printf ("%ld = %ld + %d\n\r",end_time,t_tenths,pause_time);
 13A1            ;    while(end_time>t_tenths)
 13A1  1914              leay -12,x
 13A3  1802401C          movw 0,y,-4,x
 13A7  1802421E          movw 2,y,-2,x
 13AB  CD1961            ldy #_t_tenths
 13AE  18024018          movw 0,y,-8,x
 13B2  1802421A          movw 2,y,-6,x
 13B6  161908            jsr __lcmp
 13B9  2EE6              bgt L42
 13BB            ;    {
 13BB            ;    }
 13BB            ; }
 13BB            L41:
 13BB  B757              tfr x,s
 13BD  30                pulx
 13BE  1B82              leas 2,sp
 13C0                    .dbline 0 ; func end
 13C0  3D                rts
 13C1            ;  lreg1 -> -4,x
 13C1            ;  lreg2 -> -8,x
 13C1            ;       end_time -> -12,x
 13C1            ;     pause_time -> 2,x
 13C1            _s_pause::
 13C1  3B                pshd
 13C2  34                pshx
 13C3  B775              tfr s,x
 13C5  1B94              leas -12,sp
 13C7            ; 
 13C7            ; //pause for pause_time*0.01 sec
 13C7            ; void s_pause(int pause_time)
 13C7            ; {
 13C7            ;    long int end_time;
 13C7            ;    end_time = t_hundredths + pause_time;
 13C7  CD195D            ldy #_t_hundredths
 13CA  1802401C          movw 0,y,-4,x
 13CE  1802421E          movw 2,y,-2,x
 13D2  EC02              ldd 2,x
 13D4  16171F            jsr __d2lreg2
 13D7  161767            jsr __ladd
 13DA  1914              leay -12,x
 13DC  18021C40          movw -4,x,0,y
 13E0  18021E42          movw -2,x,2,y
 13E4            L46:
 13E4            L47:
 13E4            ; //   printf ("%ld = %ld + %d\n\r",end_time,t_tenths,pause_time);
 13E4            ;    while(end_time>t_hundredths)
 13E4  1914              leay -12,x
 13E6  1802401C          movw 0,y,-4,x
 13EA  1802421E          movw 2,y,-2,x
 13EE  CD195D            ldy #_t_hundredths
 13F1  18024018          movw 0,y,-8,x
 13F5  1802421A          movw 2,y,-6,x
 13F9  161908            jsr __lcmp
 13FC  2EE6              bgt L46
 13FE            ;    {
 13FE            ;    }
 13FE            ; }
 13FE            L45:
 13FE  B757              tfr x,s
 1400  30                pulx
 1401  1B82              leas 2,sp
 1403                    .dbline 0 ; func end
 1403  3D                rts
 1404            _init_atd0::
 1404            ; 
 1404            ; // ******************* Initialize ATD *******************
 1404            ; void init_atd0()
 1404            ; {
 1404            ;    SEI;
 1404  1410                      SEI
 1406            
 1406            ;    ATD0CTL2 = 0xC2;
 1406  C6C2              ldab #194
 1408  7B0082            stab 0x82
 140B            ;    ATD0CTL3 = 0x40;
 140B  C640              ldab #64
 140D  7B0083            stab 0x83
 1410            ;    ATD0CTL4 = 0xE7;
 1410  C6E7              ldab #231
 1412  7B0084            stab 0x84
 1415            ;    CLI;
 1415  10EF                      CLI
 1417            
 1417            ; }
 1417            L49:
 1417                    .dbline 0 ; func end
 1417  3D                rts
 1418            _ATD0_Interrupt::
 1418            ; 
 1418            ; /********************************************************************/
 1418            ; /* This code is primarily taken from example 7.3.5 in the text      */
 1418            ; /* and then converted to act as an ISR                              */
 1418            ; /********************************************************************/
 1418            ;   	  
 1418            ; void ATD0_Interrupt()
 1418            ; {
 1418            ; /*print results to PC screen for testing             */
 1418            ;    atd0[0]= ATD0DR0H;	
 1418            	; vol
 1418  F60090            ldab 0x90
 141B  87                clra
 141C  7C194D            std _atd0
 141F            ;    atd0[1]= ATD0DR1H;
 141F                    ; vol
 141F  F60092            ldab 0x92
 1422  87                clra
 1423  7C194F            std _atd0+2
 1426            ;    atd0[2]= ATD0DR2H;
 1426                    ; vol
 1426  F60094            ldab 0x94
 1429  87                clra
 142A  7C1951            std _atd0+4
 142D            ;    atd0[3]= ATD0DR3H;
 142D                    ; vol
 142D  F60096            ldab 0x96
 1430  87                clra
 1431  7C1953            std _atd0+6
 1434            ;    atd0[4]= ATD0DR4H;
 1434                    ; vol
 1434  F60098            ldab 0x98
 1437  87                clra
 1438  7C1955            std _atd0+8
 143B            ;    atd0[5]= ATD0DR5H;
 143B                    ; vol
 143B  F6009A            ldab 0x9a
 143E  87                clra
 143F  7C1957            std _atd0+10
 1442            ;    atd0[6]= ATD0DR6H;
 1442                    ; vol
 1442  F6009C            ldab 0x9c
 1445  87                clra
 1446  7C1959            std _atd0+12
 1449            ;    atd0[7]= ATD0DR7H;         
 1449                    ; vol
 1449  F6009E            ldab 0x9e
 144C  87                clra
 144D  7C195B            std _atd0+14
 1450            ; 
 1450            ; }
 1450            L50:
 1450                    .dbline 0 ; func end
 1450  0B                rti
 1451            _init_atd1::
 1451            ; 
 1451            ; // ******************* Initialize ATD *******************
 1451            ; void init_atd1()
 1451            ; {
 1451            ;    SEI;
 1451  1410                      SEI
 1453            
 1453            ;    ATD1CTL2 = 0xC2;
 1453  C6C2              ldab #194
 1455  7B0122            stab 0x122
 1458            ;    ATD1CTL3 = 0x40;
 1458  C640              ldab #64
 145A  7B0123            stab 0x123
 145D            ;    ATD1CTL4 = 0xE7;
 145D  C6E7              ldab #231
 145F  7B0124            stab 0x124
 1462            ;    CLI;
 1462  10EF                      CLI
 1464            
 1464            ; }
 1464            L58:
 1464                    .dbline 0 ; func end
 1464  3D                rts
 1465            _ATD1_Interrupt::
 1465            ; 
 1465            ; /********************************************************************/
 1465            ; /* This code is primarily taken from example 7.3.5 in the text      */
 1465            ; /* and then converted to act as an ISR                              */
 1465            ; /********************************************************************/
 1465            ;   	  
 1465            ; void ATD1_Interrupt()
 1465            ; {
 1465            ; /*print results to PC screen for testing             */
 1465            ;    atd1[0]= ATD1DR0H;	
 1465            	; vol
 1465  F60130            ldab 0x130
 1468  87                clra
 1469  7C193D            std _atd1
 146C            ;    atd1[1]= ATD1DR1H;
 146C                    ; vol
 146C  F60132            ldab 0x132
 146F  87                clra
 1470  7C193F            std _atd1+2
 1473            ;    atd1[2]= ATD1DR2H;
 1473                    ; vol
 1473  F60134            ldab 0x134
 1476  87                clra
 1477  7C1941            std _atd1+4
 147A            ;    atd1[3]= ATD1DR3H;
 147A                    ; vol
 147A  F60136            ldab 0x136
 147D  87                clra
 147E  7C1943            std _atd1+6
 1481            ;    atd1[4]= ATD1DR4H;
 1481                    ; vol
 1481  F60138            ldab 0x138
 1484  87                clra
 1485  7C1945            std _atd1+8
 1488            ;    atd1[5]= ATD1DR5H;
 1488                    ; vol
 1488  F6013A            ldab 0x13a
 148B  87                clra
 148C  7C1947            std _atd1+10
 148F            ;    atd1[6]= ATD1DR6H;
 148F                    ; vol
 148F  F6013C            ldab 0x13c
 1492  87                clra
 1493  7C1949            std _atd1+12
 1496            ;    atd1[7]= ATD1DR7H;         
 1496                    ; vol
 1496  F6013E            ldab 0x13e
 1499  87                clra
 149A  7C194B            std _atd1+14
 149D            ;  
 149D            ; //Checking Line Track
 149D            ;   line = 0;
 149D  CC0000            ldd #0
 14A0  7C1939            std _line
 14A3            ;   
 14A3            ;   if (atd1[0] < line_threshold)
 14A3  FC193D            ldd _atd1
 14A6  BC1052            cpd _line_threshold
 14A9  2409              bhs L67
 14AB            ;   {
 14AB            ;     line += 0x1;
 14AB  FC1939            ldd _line
 14AE  C30001            addd #1
 14B1  7C1939            std _line
 14B4            ;   }
 14B4            L67:
 14B4            ;   if (atd1[1] < line_threshold)
 14B4  FC193F            ldd _atd1+2
 14B7  BC1052            cpd _line_threshold
 14BA  2409              bhs L69
 14BC            ;   {
 14BC            ;     line += 0x2;
 14BC  FC1939            ldd _line
 14BF  C30002            addd #2
 14C2  7C1939            std _line
 14C5            ;    }
 14C5            L69:
 14C5            ;   if (atd1[2] < line_threshold)
 14C5  FC1941            ldd _atd1+4
 14C8  BC1052            cpd _line_threshold
 14CB  2409              bhs L72
 14CD            ;    {
 14CD            ;     line += 0x4;
 14CD  FC1939            ldd _line
 14D0  C30004            addd #4
 14D3  7C1939            std _line
 14D6            ;    }
 14D6            L72:
 14D6            ; //Checking Intersection 
 14D6            ;   Intersection = 0;
 14D6  CC0000            ldd #0
 14D9  7C192F            std _Intersection
 14DC            ;   
 14DC            ;   if (atd1[6] < Intersection_threshold)
 14DC  FC1949            ldd _atd1+12
 14DF  BC1054            cpd _Intersection_threshold
 14E2  2409              bhs L75
 14E4            ;   {
 14E4            ;     Intersection += 0x1;
 14E4  FC192F            ldd _Intersection
 14E7  C30001            addd #1
 14EA  7C192F            std _Intersection
 14ED            ;   }
 14ED            L75:
 14ED            ;   if (atd1[7] < Intersection_threshold)
 14ED  FC194B            ldd _atd1+14
 14F0  BC1054            cpd _Intersection_threshold
 14F3  2409              bhs L78
 14F5            ;   {
 14F5            ;     Intersection += 0x2;
 14F5  FC192F            ldd _Intersection
 14F8  C30002            addd #2
 14FB  7C192F            std _Intersection
 14FE            ;    }
 14FE            L78:
 14FE            ; //Checking Backup 
 14FE            ;   Backup = 0;
 14FE  CC0000            ldd #0
 1501  7C192D            std _Backup
 1504            ;   
 1504            ;   if (atd1[3] < Backup_threshold)
 1504  FC1943            ldd _atd1+6
 1507  BC1056            cpd _Backup_threshold
 150A  2409              bhs L81
 150C            ;   {
 150C            ;     Backup += 0x1;
 150C  FC192D            ldd _Backup
 150F  C30001            addd #1
 1512  7C192D            std _Backup
 1515            ;   }
 1515            L81:
 1515            ;   if (atd1[4] < Backup_threshold)
 1515  FC1945            ldd _atd1+8
 1518  BC1056            cpd _Backup_threshold
 151B  2409              bhs L84
 151D            ;   {
 151D            ;     Backup += 0x2;
 151D  FC192D            ldd _Backup
 1520  C30002            addd #2
 1523  7C192D            std _Backup
 1526            ;    }
 1526            L84:
 1526            ;   if (atd1[5] < Backup_threshold)
 1526  FC1947            ldd _atd1+10
 1529  BC1056            cpd _Backup_threshold
 152C  2409              bhs L87
 152E            ;    {
 152E            ;     Backup += 0x4;
 152E  FC192D            ldd _Backup
 1531  C30004            addd #4
 1534  7C192D            std _Backup
 1537            ;    }
 1537            L87:
 1537            ;    
 1537            ;   // printf("%x %x %x %x\n\r", atd1[0], atd1[1], atd1[2], line); 	
 1537            ; }
 1537            L59:
 1537                    .dbline 0 ; func end
 1537  0B                rti
 1538            L91:
 1538  BAB9              .word 47801
 153A  A65D              .word 42589
 153C  9430              .word 37936
 153E  8BE9              .word 35817
 1540  7C90              .word 31888
 1542  6EF9              .word 28409
 1544  62D7              .word 25303
 1546  5D5C              .word 23900
 1548            L92:
 1548  0005              .word 5
 154A  0005              .word 5
 154C  0005              .word 5
 154E  0005              .word 5
 1550  0005              .word 5
 1552  0005              .word 5
 1554  0005              .word 5
 1556  0005              .word 5
 1558            ;              i -> -36,x
 1558            ;            dur -> -34,x
 1558            ;          score -> -18,x
 1558            ;              j -> -2,x
 1558            _Speaker::
 1558  34                pshx
 1559  B775              tfr s,x
 155B  1BF1DA            leas -38,sp
 155E            ; 
 155E            ; //*****************************************************************************
 155E            ; #define  C5  47801
 155E            ; #define  C5S 45126
 155E            ; #define  D5    42589
 155E            ; #define        D5S 40193
 155E            ; #define        E5  37936
 155E            ; #define  F5    35817
 155E            ; #define  F5S 33784
 155E            ; #define        G5      31888
 155E            ; #define  G5S 30084
 155E            ; #define  A5    28409
 155E            ; #define  A5S 26824
 155E            ; #define  B5    25303
 155E            ; #define  C6    23900
 155E            ; #define  C6S 22542
 155E            ; #define  D6  21276
 155E            ; #define  D6S 20096
 155E            ; #define  E6  18825
 155E            ; #define  F6  17895
 155E            ; #define  F6S 16892
 155E            ; #define  G6    15944
 155E            ; #define  G6S 15051
 155E            ; #define  A6  14204
 155E            ; #define  A6S 13404
 155E            ; #define  B6  12658
 155E            ; 
 155E            ; 
 155E            ; #define  notes  8
 155E            ; #define  toggle 0x04
 155E            ; 
 155E            ; void Speaker ()
 155E            ; {
 155E            ;    int j;
 155E            ;    int i;
 155E            ;    unsigned int score[notes] = {C5,D5,E5,F5,G5,A5,B5,C6};
 155E  19E1EE            leay -18,x
 1561  B7C6              xgdy
 1563  CD1538            ldy #L91
 1566  34                pshx
 1567  B745              tfr d,x
 1569  CC0008            ldd #8
 156C            X2:
 156C  18027131          movw 2,y+,2,x+
 1570  0434F9            dbne d,X2
 1573  30                pulx
 1574            ;    unsigned int dur[notes] = {5,5,5,5,5,5,5,5};
 1574  19E1DE            leay -34,x
 1577  B7C6              xgdy
 1579  CD1548            ldy #L92
 157C  34                pshx
 157D  B745              tfr d,x
 157F  CC0008            ldd #8
 1582            X3:
 1582  18027131          movw 2,y+,2,x+
 1586  0434F9            dbne d,X3
 1589  30                pulx
 158A            ; 
 158A            ; //   TSCR1 = 0x90;   //Enable TCNT, fast timer flag clear
 158A            ; //   TSCR2 = 0x83;   //Set TCNT prescaler to 8
 158A            ;    TFLG1 = 0x20;   //Clear all TxF flags
 158A  C620              ldab #32
 158C  7B004E            stab 0x4e
 158F            ;    TIE  |= 0x20;   //Enable TC5 interrupt
 158F  1C004C20          bset 0x4c,#32
 1593            ;    TIOS |= 0x20;   //Enable OC5 function
 1593  1C004020          bset 0x40,#32
 1597            ;    TCTL1 = toggle; //Select toggle option as OC5 pin action
 1597  C604              ldab #4
 1599  7B0048            stab 0x48
 159C            ;    j = 0;
 159C  CC0000            ldd #0
 159F  6C1E              std -2,x
 15A1            ;    dela = score[0];
 15A1  ECE1EE            ldd -18,x
 15A4  7C193B            std _dela
 15A7            ;    TC5 = TCNT + dela;      //Play the first note
 15A7                    ; vol
 15A7  FC0044            ldd 0x44
 15AA  F3193B            addd _dela
 15AD  7C005A            std 0x5a
 15B0  202D              bra L94
 15B2            L93:
 15B2  19E1EE            leay -18,x
 15B5  6DE1DA            sty -38,x
 15B8  EC1E              ldd -2,x
 15BA  59                lsld
 15BB  E3E1DA            addd -38,x
 15BE  B7C6              xgdy
 15C0  EC40              ldd 0,y
 15C2  7C193B            std _dela
 15C5  19E1DE            leay -34,x
 15C8  6DE1DA            sty -38,x
 15CB  EC1E              ldd -2,x
 15CD  59                lsld
 15CE  E3E1DA            addd -38,x
 15D1  B7C6              xgdy
 15D3  EC40              ldd 0,y
 15D5  1613C1            jsr _s_pause
 15D8  EC1E              ldd -2,x
 15DA  C30001            addd #1
 15DD  6C1E              std -2,x
 15DF            L94:
 15DF            ;    while(j < notes)
 15DF  EC1E              ldd -2,x
 15E1  8C0008            cpd #8
 15E4  2DCC              blt L93
 15E6            ;    {
 15E6            ;       dela = score[j];     //Play the jth note
 15E6            ;         s_pause(dur[j]);
 15E6            ;         j++;
 15E6            ;    }
 15E6            ; 
 15E6            ;    TIE  &= ~0x20;   //Disable TC5 interrupt
 15E6  1D004C20          bclr 0x4c,#0x20
 15EA            ; //   TSCR1 = 0x00;   //Turn off the Timer System
 15EA            ;    PTT = 0x00;     //Blank Port T
 15EA  790240            clr 0x240
 15ED            ;    TCTL1 = 0;
 15ED  790048            clr 0x48
 15F0            ; }
 15F0            L90:
 15F0  B757              tfr x,s
 15F2  30                pulx
 15F3                    .dbline 0 ; func end
 15F3  3D                rts
 15F4            _OC5_ISR::
 15F4            ; 
 15F4            ; //******************************** OC5_ISR *************************************
 15F4            ; 
 15F4            ; #pragma interrupt_handler OC5_ISR()
 15F4            ; void OC5_ISR ()
 15F4            ; {
 15F4            ;    TC5 += dela;
 15F4            	; vol
 15F4  FC005A            ldd 0x5a
 15F7  F3193B            addd _dela
 15FA  7C005A            std 0x5a
 15FD            ;    TFLG1 = 0x20;
 15FD  C620              ldab #32
 15FF  7B004E            stab 0x4e
 1602            ; }
 1602            L96:
 1602                    .dbline 0 ; func end
 1602  0B                rti
 1603            ;        fr_line -> -2,x
 1603            ;             fr -> 2,x
 1603            _linetrack::
 1603  3B                pshd
 1604  34                pshx
 1605  B775              tfr s,x
 1607  1B9E              leas -2,sp
 1609            ; //******************************************************************************
 1609            ; /*measure motor speed testing             */  
 1609            ; // void motorspeed()
 1609            ; //{
 1609            ; //   printf("%d %d\n\r",a,b); 
 1609            ;         
 1609            ;   //PWME = 0x00;
 1609            ;   // PWMDTYW1 = a;                                     //measure motor speed//
 1609            ;   // PWMDTYW3 = b;                                      //measure motor speed//
 1609            ;   // PWME = 0xaa;                                        //measure motor speed//
 1609            ;    
 1609            ;   // pause(50);                                                   //measure motor speed//
 1609            ;   // a = a+100;
 1609            ;   // b = b-100;
 1609            ; 
 1609            ; //}
 1609            ; //******************************************************************************
 1609            ; /*speedcontrol stepup testing                                         */
 1609            ;  /*
 1609            ;  void speedcontrol()
 1609            ;  
 1609            ;  {
 1609            ;       ob_led(8);
 1609            ; forward();             // set the speed control test//
 1609            ; pause(20);             // set the speed control test//
 1609            ;       
 1609            ; stop();                        // set the speed control test//
 1609            ; pause(20);             // set the speed control test//
 1609            ;        ob_led(9);      // set the speed control test//  
 1609            ; reverse();             // set the speed control test//
 1609            ; pause(20);             // set the speed control test//
 1609            ;    
 1609            ; stop();                        // set the speed control test//
 1609            ; pause(20);             // set the speed control test//
 1609            ;       
 1609            ;   } 
 1609            ; */
 1609            ; 
 1609            ; //******************************************************************************
 1609            ; /*linetrack  testing                                          */
 1609            ; void linetrack(int fr)
 1609            ; {
 1609  2060              bra L99
 160B            L98:
 160B            ;    int fr_line;
 160B            ;    while(((Intersection!=0x03)&&(fr==0))||((Backup!=0x07)&&(fr==1)))
 160B            ;    {
 160B            ; 
 160B            ;       if (fr==0)
 160B  EC02              ldd 2,x
 160D  2607              bne L101
 160F            ;       {
 160F            ;          fr_line=line;
 160F  18011E1939        movw _line,-2,x
 1614            ;       }
 1614  2005              bra L102
 1616            L101:
 1616            ;       else
 1616            ;       {
 1616            ;          fr_line=Backup;
 1616  18011E192D        movw _Backup,-2,x
 161B            ;       }
 161B            L102:
 161B            ; 
 161B            ;       ob_led(fr_line);
 161B  EC1E              ldd -2,x
 161D  1611A7            jsr _ob_led
 1620            ; 
 1620            ;       switch(fr_line)
 1620  EC1E              ldd -2,x
 1622  8C0001            cpd #1
 1625  2710              beq L105
 1627  EC1E              ldd -2,x
 1629  8C0002            cpd #2
 162C  270E              beq L106
 162E  EC1E              ldd -2,x
 1630  8C0004            cpd #4
 1633  2715              beq L109
 1635  2016              bra L103
 1637            X4:
 1637            ;       {
 1637            L105:
 1637            ; 	  case 1:
 1637            ;          left();
 1637  161289            jsr _left
 163A            ; //               printf ("left\n\r");
 163A            ;            break;
 163A  2011              bra L104
 163C            L106:
 163C            ; 	  case 2:	
 163C            ;          if (fr==0)
 163C  EC02              ldd 2,x
 163E  2605              bne L107
 1640            ;                {
 1640            ;                   forward();
 1640  16125F            jsr _forward
 1643            ;          }
 1643  2008              bra L104
 1645            L107:
 1645            ; 		 else
 1645            ; 		 {
 1645            ; 		    reverse();
 1645  16124A            jsr _reverse
 1648            ;          }
 1648            ; 
 1648            ;                break;
 1648  2003              bra L104
 164A            L109:
 164A            ;       case 4:		  
 164A            ; 		 right();
 164A  161274            jsr _right
 164D            ; //               printf ("right\n\r");
 164D            ;                break;
 164D            L103:
 164D            L104:
 164D            ; /*      default:
 164D            ;          if (fr==0)
 164D            ; 		 {
 164D            ; 		    forward();
 164D            ;          }
 164D            ; 		 else
 164D            ; 		 {
 164D            ; 		    reverse();
 164D            ;          }
 164D            ; */
 164D            ;       }
 164D            ; 	  
 164D            ; 	  pause(1);
 164D  CC0001            ldd #1
 1650  16137E            jsr _pause
 1653            ;          if (fr==0)
 1653  EC02              ldd 2,x
 1655  260B              bne L110
 1657            ;                {
 1657            ;                   forward();
 1657  16125F            jsr _forward
 165A            ;               s_pause(5);                             //original number 10
 165A  CC0005            ldd #5
 165D  1613C1            jsr _s_pause
 1660            ;            }
 1660  2009              bra L111
 1662            L110:
 1662            ; 		 else
 1662            ; 		 {
 1662            ; 		    reverse();
 1662  16124A            jsr _reverse
 1665            ;                   s_pause(8);                         //original number 25
 1665  CC0008            ldd #8
 1668  1613C1            jsr _s_pause
 166B            ;          }
 166B            L111:
 166B            L99:
 166B  FC192F            ldd _Intersection
 166E  8C0003            cpd #3
 1671  2704              beq L112
 1673  EC02              ldd 2,x
 1675  2794              beq L98
 1677            L112:
 1677  FC192D            ldd _Backup
 167A  8C0007            cpd #7
 167D  2709              beq L113
 167F  EC02              ldd 2,x
 1681  8C0001            cpd #1
 1684  1827FF83          lbeq L98
 1688            L113:
 1688            ;    }
 1688            ; }
 1688            L97:
 1688  B757              tfr x,s
 168A  30                pulx
 168B  1B82              leas 2,sp
 168D                    .dbline 0 ; func end
 168D  3D                rts
 168E            _init_ic0_1::
 168E            ; 
 168E            ; 
 168E            ; //******************************************************************************
 168E            ; // IC0-1 Init
 168E            ; 
 168E            ; void init_ic0_1(void)
 168E            ; {
 168E            ; //   TSCR2 = 0x81;	   //might interfear with SOUND!!!!!!!!!!!!!!!! but in for testing
 168E            ;    TFLG1 = 0x03;   //Clear flags
 168E  C603              ldab #3
 1690  7B004E            stab 0x4e
 1693            ;    TIE  |= 0x03;   //Enable IC0+1 interrupt
 1693  1C004C03          bset 0x4c,#3
 1697            ;    TIOS &= 0xfc;   //make 0+1 input capture
 1697  1D004003          bclr 0x40,#0x3
 169B            ;    TCTL4 = 0x05;   //capture 0+1 on rising edge
 169B  C605              ldab #5
 169D  7B004B            stab 0x4b
 16A0            ; }
 16A0            L114:
 16A0                    .dbline 0 ; func end
 16A0  3D                rts
 16A1            _IC0_ISR::
 16A1            ; 
 16A1            ; void IC0_ISR (void)
 16A1            ; {
 16A1            ;    TFLG1 = 0x01; 	// clear int flag
 16A1  C601              ldab #1
 16A3  7B004E            stab 0x4e
 16A6            ;    IC0_speed=TC0-IC0_last;
 16A6                    ; vol
 16A6  FC0050            ldd 0x50
 16A9  B31937            subd _IC0_last
 16AC  7C1933            std _IC0_speed
 16AF            ;    IC0_last=TC0;
 16AF                    ; vol
 16AF  FD0050            ldy 0x50
 16B2  7D1937            sty _IC0_last
 16B5            ; }
 16B5            L115:
 16B5                    .dbline 0 ; func end
 16B5  0B                rti
 16B6            _IC1_ISR::
 16B6            ; 
 16B6            ; 
 16B6            ; void IC1_ISR (void)
 16B6            ; {
 16B6            ;    TFLG1 = 0x02; 	// clear int flag
 16B6  C602              ldab #2
 16B8  7B004E            stab 0x4e
 16BB            ;    IC1_speed=TC1-IC1_last;
 16BB                    ; vol
 16BB  FC0052            ldd 0x52
 16BE  B31935            subd _IC1_last
 16C1  7C1931            std _IC1_speed
 16C4            ;    IC1_last=TC1;
 16C4                    ; vol
 16C4  FD0052            ldy 0x52
 16C7  7D1935            sty _IC1_last
 16CA            ; }
 16CA            L116:
 16CA                    .dbline 0 ; func end
 16CA  0B                rti
                        .area bss
 192D            _Backup::
 192D                    .blkb 2
 192F            _Intersection::
 192F                    .blkb 2
 1931            _IC1_speed::
 1931                    .blkb 2
 1933            _IC0_speed::
 1933                    .blkb 2
 1935            _IC1_last::
 1935                    .blkb 2
 1937            _IC0_last::
 1937                    .blkb 2
 1939            _line::
 1939                    .blkb 2
 193B            _dela::
 193B                    .blkb 2
 193D            _atd1::
 193D                    .blkb 16
 194D            _atd0::
 194D                    .blkb 16
 195D            _t_hundredths::
 195D                    .blkb 4
 1961            _t_tenths::
 1961                    .blkb 4
 1965            _t_counts::
 1965                    .blkb 4
                        .area text
--- 0679           L40:
--- 0679 00000004          .word 0,4
--- 067D           L37:
--- 067D 00000000          .word 0,0
--- 0681           L36:
--- 0681 00000026          .word 0,38
--- 0685           L33:
--- 0685 00000001          .word 0,1
