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  FC1B35            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  1427              .word _TOF_isr
                        .area data
                        .area memory(abs)
                        .org 0x3e52
 3E52            _IRQ_ATD0_vector::
 3E52  158D              .word _ATD0_Interrupt
                        .area data
                        .area memory(abs)
                        .org 0x3e50
 3E50            _IRQ_ATD1_vector::
 3E50  15DA              .word _ATD1_Interrupt
                        .area data
                        .area memory(abs)
                        .org 0x3e64
 3E64            _IRQ_OC5_vector::
 3E64  1769              .word _OC5_ISR
                        .area data
                        .area memory(abs)
                        .org 0x3e6e
 3E6E            _IRQ_IC0_vector::
 3E6E  1817              .word _IC0_ISR
                        .area data
                        .area memory(abs)
                        .org 0x3e6c
 3E6C            _IRQ_IC1_vector::
 3E6C  1849              .word _IC1_ISR
                        .area data
                        .area text
 1052            _line_threshold::
 1052  005A              .word 90
 1054            _Intersection_threshold::
 1054  0050              .word 80
 1056            _Backup_threshold::
 1056  005A              .word 90
 1058            ;  lreg1 -> -4,x
 1058            ;  lreg2 -> -8,x
 1058            ;              b -> -12,x
 1058            ;              a -> -10,x
 1058            _main::
 1058  34                pshx
 1059  B775              tfr s,x
 105B  1B94              leas -12,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 long int IC0_count;
 105D            ; unsigned long int IC1_count;
 105D            ; 
 105D            ; int Intersection;
 105D            ; const Intersection_threshold = 80;     //original = 60 
 105D            ; int Backup;
 105D            ; const Backup_threshold = 90;
 105D            ; 
 105D            ; 
 105D            ; void main(void)
 105D            ; {
 105D            ; 
 105D            ; 
 105D            ;    int a,b; 
 105D            ;    init_pwm();
 105D  161357            jsr _init_pwm
 1060            ;    init_tof();
 1060  161413            jsr _init_tof
 1063            ;    init_atd0();
 1063  161579            jsr _init_atd0
 1066            ;    init_atd1();
 1066  1615C6            jsr _init_atd1
 1069            ;    init_ic0_1();
 1069  161804            jsr _init_ic0_1
 106C            ;  
 106C            ;    pause(1);
 106C  CC0001            ldd #1
 106F  1614F3            jsr _pause
 1072            ;    
 1072            ;    ATD0CTL5 = 0x30;    //start atd's
 1072  C630              ldab #48
 1074  7B0085            stab 0x85
 1077            ;    ATD1CTL5 = 0x30;
 1077  C630              ldab #48
 1079  7B0125            stab 0x125
 107C            ;      
 107C            ;    pause(1);             //pause to allow atd to read first time;
 107C  CC0001            ldd #1
 107F  1614F3            jsr _pause
 1082  2030              bra L5
 1084            L4:
 1084  CC12C0            ldd #4800
 1087  7C00BE            std 0xbe
 108A  CC000A            ldd #10
 108D  1614F3            jsr _pause
 1090  CC1194            ldd #4500
 1093  7C00BE            std 0xbe
 1096  CC000A            ldd #10
 1099  1614F3            jsr _pause
 109C  CC12C0            ldd #4800
 109F  7C00BE            std 0xbe
 10A2  CC000A            ldd #10
 10A5  1614F3            jsr _pause
 10A8  CC1194            ldd #4500
 10AB  7C00BE            std 0xbe
 10AE  CC000A            ldd #10
 10B1  1614F3            jsr _pause
 10B4            L5:
 10B4            ;    
 10B4            ;    while(1)
 10B4  20CE              bra L4
 10B6            X0:
 10B6            ;    {
 10B6            ;     
 10B6            ;     PWMDTYW3 = 4800;
 10B6            ; 	pause(10);
 10B6            ;     PWMDTYW3 = 4500;
 10B6            ; 	pause(10);
 10B6            ;     PWMDTYW3 = 4800;
 10B6            ; 	pause(10);
 10B6            ;     PWMDTYW3 = 4500;
 10B6            ; 	pause(10);
 10B6            ; 	
 10B6            ; 	
 10B6            ; 	}
 10B6            ;    
 10B6            ;    ob_led(15);
 10B6  CC000F            ldd #15
 10B9  16131C            jsr _ob_led
 10BC            ;   // while(atd0[3] > 10);                //wait for switch 2 to be pressed
 10BC            ;   
 10BC            ;     pause(50);
 10BC  CC0032            ldd #50
 10BF  1614F3            jsr _pause
 10C2            ;   
 10C2            ;     ob_led(14);
 10C2  CC000E            ldd #14
 10C5  16131C            jsr _ob_led
 10C8            ;     pause(50);
 10C8  CC0032            ldd #50
 10CB  1614F3            jsr _pause
 10CE  1820021F          lbra L8
 10D2            L7:
 10D2            ; 	
 10D2            ; 	/*forward();
 10D2            ; 	
 10D2            ; 	 IC1_count=0;
 10D2            ; 	   while (IC1_count < 2700);	  
 10D2            ; 	   
 10D2            ; 	
 10D2            ; 	 linetrack(0);  			   //linetrack to T
 10D2            ; 	  // ob_led(11); 
 10D2            ; 	 
 10D2            ; 	  forward();
 10D2            ; 	  
 10D2            ; 	  IC1_count=0;
 10D2            ; 	   while (IC1_count < 2000);	  
 10D2            ; 	   stop();  			   //center robot on line
 10D2            ; 	   pause(10); 
 10D2            ; 	
 10D2            ; 	left();	
 10D2            ; 			   //turn till sensor on line
 10D2            ; 	
 10D2            ; 	while(line==0)
 10D2            ; 	 {
 10D2            ; 	    ob_led(line);
 10D2            ; 		
 10D2            ; 	 }
 10D2            ; 	linetrack(0);
 10D2            ; 	
 10D2            ; 	forward();
 10D2            ; 	IC1_count=0; 
 10D2            ; 	while (IC1_count < 2175);  // 860 * number
 10D2            ; 	
 10D2            ; 	 stop();
 10D2            ; 	 pause(20);
 10D2            ;      
 10D2            ; 	 			   //turn till sensor on line
 10D2            ; 	
 10D2            ; 	
 10D2            ; 	 left();		   		//turn till sensor on line heading towards
 10D2            ; 	 IC1_count=0;
 10D2            ; 	 while (IC1_count < 2700);
 10D2            ; 	 pause(5);            //ball request zone
 10D2            ; 	 
 10D2            ; 	/* while(line==0)        
 10D2            ; 	 {
 10D2            ; 	    ob_led(line);
 10D2            ; 	 }  */
 10D2            ; 	 /*stop();
 10D2            ; 	 pause(5);
 10D2            ; 	 
 10D2            ; 	 linetrack(0);	 		   // get to ball request zone
 10D2            ; 
 10D2            ; 	 /*stop();
 10D2            ; 	 pause(5);
 10D2            ; 	 forward();
 10D2            ; 	 
 10D2            ; 	 
 10D2            ; 	 pause(5);
 10D2            ; 	// forward(); */
 10D2            ; 	 
 10D2            ; 	 
 10D2            ; 	 /*
 10D2            ; 	 forward();
 10D2            ; 	 while(Backup != 7);
 10D2            ; 	
 10D2            ; 	 stop();
 10D2            ; 	 pause(5);
 10D2            ; 	 
 10D2            ; 	 IC1_count = 0;
 10D2            ; 	 
 10D2            ; 	 forward();
 10D2            ; 	 
 10D2            ; 	 
 10D2            ; 	 while (IC1_count < 920);
 10D2            ; 	 //linetrack(1);
 10D2            ; 	 
 10D2            ; 	 stop();
 10D2            ; 	 pause(5);
 10D2            ; 	 */
 10D2            ; 	 
 10D2            ; 	 while(1)
 10D2            ; 	 {
 10D2            ; 	 reverse();
 10D2  1613BF            jsr _reverse
 10D5            L10:
 10D5            L11:
 10D5            ; 	 while(Backup != 7);
 10D5  FC1AF9            ldd _Backup
 10D8  8C0007            cpd #7
 10DB  26F8              bne L10
 10DD            ;        
 10DD            ;        stop();
 10DD  1613AA            jsr _stop
 10E0            ;        pause(5);
 10E0  CC0005            ldd #5
 10E3  1614F3            jsr _pause
 10E6            ;        
 10E6            ;        left();                                
 10E6  1613FE            jsr _left
 10E9            ;        IC1_count=0;
 10E9  CD18A3            ldy #L13
 10EC  1802401C          movw 0,y,-4,x
 10F0  1802421E          movw 2,y,-2,x
 10F4  CD1AFD            ldy #_IC1_count
 10F7  18021C40          movw -4,x,0,y
 10FB  18021E42          movw -2,x,2,y
 10FF            L14:
 10FF            L15:
 10FF            ; 	 while (IC1_count < 17000);   	//180 turn in Request zone
 10FF  CD1AFD            ldy #_IC1_count
 1102  1802401C          movw 0,y,-4,x
 1106  1802421E          movw 2,y,-2,x
 110A  CD189F            ldy #L17
 110D  18024018          movw 0,y,-8,x
 1111  1802421A          movw 2,y,-6,x
 1115  161AD4            jsr __lcmp
 1118  25E5              blo L14
 111A            ;        
 111A            ;        stop();
 111A  1613AA            jsr _stop
 111D            ;        pause(10);
 111D  CC000A            ldd #10
 1120  1614F3            jsr _pause
 1123            ;        
 1123            ;        linetrack(0);                                  //line track to intersection
 1123  CC0000            ldd #0
 1126  161778            jsr _linetrack
 1129            ;        stop();
 1129  1613AA            jsr _stop
 112C            ;        pause(10);
 112C  CC000A            ldd #10
 112F  1614F3            jsr _pause
 1132            ;        
 1132            ;        forward();                                             //move off of intersection
 1132  1613D4            jsr _forward
 1135            ;        IC1_count=0;
 1135  CD18A3            ldy #L13
 1138  1802401C          movw 0,y,-4,x
 113C  1802421E          movw 2,y,-2,x
 1140  CD1AFD            ldy #_IC1_count
 1143  18021C40          movw -4,x,0,y
 1147  18021E42          movw -2,x,2,y
 114B            L18:
 114B            L19:
 114B            ; 	 while (IC1_count < 2700);	
 114B  CD1AFD            ldy #_IC1_count
 114E  1802401C          movw 0,y,-4,x
 1152  1802421E          movw 2,y,-2,x
 1156  CD189B            ldy #L21
 1159  18024018          movw 0,y,-8,x
 115D  1802421A          movw 2,y,-6,x
 1161  161AD4            jsr __lcmp
 1164  25E5              blo L18
 1166            ;        
 1166            ;        linetrack(0);            //linetrack to rebound zone, stop at front line track
 1166  CC0000            ldd #0
 1169  161778            jsr _linetrack
 116C            ;        stop();
 116C  1613AA            jsr _stop
 116F            ;        pause(10);
 116F  CC000A            ldd #10
 1172  1614F3            jsr _pause
 1175            ;        
 1175            ;        forward();
 1175  1613D4            jsr _forward
 1178            ;        pause(5);
 1178  CC0005            ldd #5
 117B  1614F3            jsr _pause
 117E            ;        
 117E            ;        forward();                                             //back linetrack into rebound zone
 117E  1613D4            jsr _forward
 1181            L22:
 1181            L23:
 1181            ; 	 while(Backup != 7);
 1181  FC1AF9            ldd _Backup
 1184  8C0007            cpd #7
 1187  26F8              bne L22
 1189            ;       
 1189            ;        stop();
 1189  1613AA            jsr _stop
 118C            ;        pause(5);
 118C  CC0005            ldd #5
 118F  1614F3            jsr _pause
 1192            ;        
 1192            ;        IC1_count = 0;
 1192  CD18A3            ldy #L13
 1195  1802401C          movw 0,y,-4,x
 1199  1802421E          movw 2,y,-2,x
 119D  CD1AFD            ldy #_IC1_count
 11A0  18021C40          movw -4,x,0,y
 11A4  18021E42          movw -2,x,2,y
 11A8            ;        
 11A8            ;        forward();                                     //move one approx. one inch into rebound zone
 11A8  1613D4            jsr _forward
 11AB            L25:
 11AB            L26:
 11AB            ; 	 
 11AB            ; 	 while (IC1_count < 920);
 11AB  CD1AFD            ldy #_IC1_count
 11AE  1802401C          movw 0,y,-4,x
 11B2  1802421E          movw 2,y,-2,x
 11B6  CD1897            ldy #L28
 11B9  18024018          movw 0,y,-8,x
 11BD  1802421A          movw 2,y,-6,x
 11C1  161AD4            jsr __lcmp
 11C4  25E5              blo L25
 11C6            ;        
 11C6            ;        stop();
 11C6  1613AA            jsr _stop
 11C9            ;        pause(10);
 11C9  CC000A            ldd #10
 11CC  1614F3            jsr _pause
 11CF            ;        
 11CF            ;        reverse();                                     //move one approx. one inch out of rebound zone
 11CF  1613BF            jsr _reverse
 11D2            L29:
 11D2            L30:
 11D2            ; 	 
 11D2            ; 	 while (IC1_count < 3000);
 11D2  CD1AFD            ldy #_IC1_count
 11D5  1802401C          movw 0,y,-4,x
 11D9  1802421E          movw 2,y,-2,x
 11DD  CD1893            ldy #L32
 11E0  18024018          movw 0,y,-8,x
 11E4  1802421A          movw 2,y,-6,x
 11E8  161AD4            jsr __lcmp
 11EB  25E5              blo L29
 11ED            ;        
 11ED            ;        stop();
 11ED  1613AA            jsr _stop
 11F0            ;        pause(5);
 11F0  CC0005            ldd #5
 11F3  1614F3            jsr _pause
 11F6            ;        
 11F6            ;        left();                                
 11F6  1613FE            jsr _left
 11F9            ;        IC1_count=0;
 11F9  CD18A3            ldy #L13
 11FC  1802401C          movw 0,y,-4,x
 1200  1802421E          movw 2,y,-2,x
 1204  CD1AFD            ldy #_IC1_count
 1207  18021C40          movw -4,x,0,y
 120B  18021E42          movw -2,x,2,y
 120F            L33:
 120F            L34:
 120F            ; 	 while (IC1_count < 19600);   	//180 turn in Rebound zone
 120F  CD1AFD            ldy #_IC1_count
 1212  1802401C          movw 0,y,-4,x
 1216  1802421E          movw 2,y,-2,x
 121A  CD188F            ldy #L36
 121D  18024018          movw 0,y,-8,x
 1221  1802421A          movw 2,y,-6,x
 1225  161AD4            jsr __lcmp
 1228  25E5              blo L33
 122A            ;        
 122A            ;        stop();
 122A  1613AA            jsr _stop
 122D            ;        pause(10);
 122D  CC000A            ldd #10
 1230  1614F3            jsr _pause
 1233            ;        
 1233            ;        forward();
 1233  1613D4            jsr _forward
 1236            ;        pause(7);
 1236  CC0007            ldd #7
 1239  1614F3            jsr _pause
 123C            ;        
 123C            ;        linetrack(0);                                  //line track to intersection
 123C  CC0000            ldd #0
 123F  161778            jsr _linetrack
 1242            ;        stop();
 1242  1613AA            jsr _stop
 1245            ;        pause(10);
 1245  CC000A            ldd #10
 1248  1614F3            jsr _pause
 124B            ;        
 124B            ;        forward();                                             //move off of intersection
 124B  1613D4            jsr _forward
 124E            ;        IC1_count=0;
 124E  CD18A3            ldy #L13
 1251  1802401C          movw 0,y,-4,x
 1255  1802421E          movw 2,y,-2,x
 1259  CD1AFD            ldy #_IC1_count
 125C  18021C40          movw -4,x,0,y
 1260  18021E42          movw -2,x,2,y
 1264            L37:
 1264            L38:
 1264            ; 	 while (IC1_count < 2700);	
 1264  CD1AFD            ldy #_IC1_count
 1267  1802401C          movw 0,y,-4,x
 126B  1802421E          movw 2,y,-2,x
 126F  CD189B            ldy #L21
 1272  18024018          movw 0,y,-8,x
 1276  1802421A          movw 2,y,-6,x
 127A  161AD4            jsr __lcmp
 127D  25E5              blo L37
 127F            ;        
 127F            ;        stop();
 127F  1613AA            jsr _stop
 1282            ;        pause(10);
 1282  CC000A            ldd #10
 1285  1614F3            jsr _pause
 1288            ;        
 1288            ;        linetrack(0);                     // go to ball request zone
 1288  CC0000            ldd #0
 128B  161778            jsr _linetrack
 128E            ; 
 128E            ;        stop();
 128E  1613AA            jsr _stop
 1291            ;        pause(5);
 1291  CC0005            ldd #5
 1294  1614F3            jsr _pause
 1297            ;        
 1297            ;        forward();
 1297  1613D4            jsr _forward
 129A            ;        pause(5);
 129A  CC0005            ldd #5
 129D  1614F3            jsr _pause
 12A0            ;       
 12A0            ;        forward();
 12A0  1613D4            jsr _forward
 12A3            L40:
 12A3            L41:
 12A3            ; 	 while(Backup != 7);
 12A3  FC1AF9            ldd _Backup
 12A6  8C0007            cpd #7
 12A9  26F8              bne L40
 12AB            ;       
 12AB            ;        stop();
 12AB  1613AA            jsr _stop
 12AE            ;        pause(5);
 12AE  CC0005            ldd #5
 12B1  1614F3            jsr _pause
 12B4            ;        
 12B4            ;        IC1_count = 0;
 12B4  CD18A3            ldy #L13
 12B7  1802401C          movw 0,y,-4,x
 12BB  1802421E          movw 2,y,-2,x
 12BF  CD1AFD            ldy #_IC1_count
 12C2  18021C40          movw -4,x,0,y
 12C6  18021E42          movw -2,x,2,y
 12CA            ;        
 12CA            ;        forward();
 12CA  1613D4            jsr _forward
 12CD            L43:
 12CD            L44:
 12CD  CD1AFD            ldy #_IC1_count
 12D0  1802401C          movw 0,y,-4,x
 12D4  1802421E          movw 2,y,-2,x
 12D8  CD1897            ldy #L28
 12DB  18024018          movw 0,y,-8,x
 12DF  1802421A          movw 2,y,-6,x
 12E3  161AD4            jsr __lcmp
 12E6  25E5              blo L43
 12E8  1613AA            jsr _stop
 12EB  CC0005            ldd #5
 12EE  1614F3            jsr _pause
 12F1            L8:
 12F1  1820FDDD          lbra L7
 12F5            X1:
 12F5            ; 	 
 12F5            ; 	 
 12F5            ; 	 while (IC1_count < 920);
 12F5            ; 	 stop();
 12F5            ; 	 pause(5);
 12F5            ; 	 
 12F5            ; 	 }  
 12F5            ; 	   
 12F5            ; 	/* reverse();				   // head back to 4 way intersection
 12F5            ; 	 IC1_count = 0;
 12F5            ; 	  
 12F5            ; 	 while (IC1_count < 2850);
 12F5            ; 	
 12F5            ; 	
 12F5            ; 	 linetrack(0);
 12F5            ; 	 
 12F5            ;  	 stop();	  			   // at 4 way
 12F5            ; 	 pause(10);  
 12F5            ; 	 
 12F5            ; 	 reverse();				   // head back to 4 way intersection
 12F5            ; 	 
 12F5            ; 	 IC1_count = 0;
 12F5            ; 	  
 12F5            ; 	 while (IC1_count < 1300);
 12F5            ; 
 12F5            ; 	  linetrack(1);
 12F5            ; 	 
 12F5            ; 	 stop();
 12F5            ; 	 pause(10);  */
 12F5            ; 	
 12F5            ; 	// forward();	   			   //leave start box 
 12F5            ; 	// pause(5); 
 12F5            ;  	
 12F5            ; 	 //linetrack(0);  			   //linetrack to T
 12F5            ; 	
 12F5            ; 	/* forward();	   			   
 12F5            ; 	 IC1_count=0;
 12F5            ; 	 while (IC1_count < 2177); 
 12F5            ; 	 ob_led(12);
 12F5            ; 	 stop();	  
 12F5            ; 	 pause(5);
 12F5            ; 	 ob_led(11);   */ 
 12F5            ; 	
 12F5            ; 	
 12F5            ; 	
 12F5            ;      Speaker();
 12F5  1616CD            jsr _Speaker
 12F8            ;       // printf ("line = %d %d\n\r",atd1[7],atd1[6]);
 12F8            ; 
 12F8            ; 
 12F8            ; }
 12F8            L3:
 12F8  B757              tfr x,s
 12FA  30                pulx
 12FB                    .dbline 0 ; func end
 12FB  3D                rts
 12FC            L47:
 12FC  003F              .word 63
 12FE  0006              .word 6
 1300  005B              .word 91
 1302  004F              .word 79
 1304  0066              .word 102
 1306  006D              .word 109
 1308  007D              .word 125
 130A  0007              .word 7
 130C  007F              .word 127
 130E  006F              .word 111
 1310  0077              .word 119
 1312  007C              .word 124
 1314  0039              .word 57
 1316  005E              .word 94
 1318  0079              .word 121
 131A  0071              .word 113
 131C            ;            out -> -32,x
 131C            ;              t -> 2,x
 131C            _ob_led::
 131C  3B                pshd
 131D  34                pshx
 131E  B775              tfr s,x
 1320  1BF1DE            leas -34,sp
 1323            ; 
 1323            ; 
 1323            ; // Display value passed to function on on board 7-seg LED of MiniDragon Board
 1323            ; void ob_led(int t)               
 1323            ; {
 1323            ; 
 1323            ;   int out[16] = {0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f,0x77,0x7c,
 1323  19E1E0            leay -32,x
 1326  B7C6              xgdy
 1328  CD12FC            ldy #L47
 132B  34                pshx
 132C  B745              tfr d,x
 132E  CC0010            ldd #16
 1331            X2:
 1331  18027131          movw 2,y+,2,x+
 1335  0434F9            dbne d,X2
 1338  30                pulx
 1339            ;     0x39,0x5e,0x79,0x71};
 1339            ;   
 1339            ;   DDRH=0xff;
 1339  C6FF              ldab #255
 133B  7B0262            stab 0x262
 133E            ;   
 133E            ;   PTH=out[t];
 133E  19E1E0            leay -32,x
 1341  6DE1DE            sty -34,x
 1344  EC02              ldd 2,x
 1346  59                lsld
 1347  E3E1DE            addd -34,x
 134A  B7C6              xgdy
 134C  EC40              ldd 0,y
 134E  7B0260            stab 0x260
 1351            ; 
 1351            ;   
 1351            ; }
 1351            L46:
 1351  B757              tfr x,s
 1353  30                pulx
 1354  1B82              leas 2,sp
 1356                    .dbline 0 ; func end
 1356  3D                rts
 1357            _init_pwm::
 1357            ; 
 1357            ; // Set up 4-16bit PWM 
 1357            ; void init_pwm()
 1357            ; {
 1357            ;   PWMTST = 0x00; 		   			  // turn off all PWM special Modes
 1357  7900A6            clr 0xa6
 135A            ;   PWMCAE = 0x00;                                        // PWM left aligned output mode 
 135A  7900A4            clr 0xa4
 135D            ;   PWMCTL = 0xf0;                                        // Use Concatenated Mode (16-bit)
 135D  C6F0              ldab #240
 135F  7B00A5            stab 0xa5
 1362            ;   
 1362            ;   
 1362            ;   PWMPRCLK = 0x33;                                      // E/8 for A and B       
 1362  C633              ldab #51
 1364  7B00A3            stab 0xa3
 1367            ;   
 1367            ;   PWMCLK = 0x00;                                        // PW Chan 1, 5 clock A
 1367  7900A2            clr 0xa2
 136A            ;                                                                         // PW chan 3, 7 clock B
 136A            ;                                                                         
 136A            ;   PWMPOL= 0xaa;                                                 // High Polarity for all channels
 136A  C6AA              ldab #170
 136C  7B00A1            stab 0xa1
 136F            ;   DDRP= 0xaa;                                           // Set Port P to output 
 136F  C6AA              ldab #170
 1371  7B025A            stab 0x25a
 1374            ; 
 1374            ;   PWMPERW1 = 60000;                                     //stop (7.5%) all motors
 1374  CCEA60            ldd #0xea60
 1377  7C00B4            std 0xb4
 137A            ;   PWMDTYW1 = 4500;                                      //<- in theory this value should be 4500
 137A  CC1194            ldd #4500
 137D  7C00BC            std 0xbc
 1380            ;   
 1380            ;   PWMPERW3 = 60000;                                   
 1380  CCEA60            ldd #0xea60
 1383  7C00B6            std 0xb6
 1386            ;   PWMDTYW3 = 4500;                                      //<- in theory this value should be 4500
 1386  CC1194            ldd #4500
 1389  7C00BE            std 0xbe
 138C            ;   
 138C            ;   PWMPERW5 = 60000;                                   //tyw5 pin 111
 138C  CCEA60            ldd #0xea60
 138F  7C00B8            std 0xb8
 1392            ;   PWMDTYW5 = 4500;                            // //tyw5 pin 111
 1392  CC1194            ldd #4500
 1395  7C00C0            std 0xc0
 1398            ; 
 1398            ;   PWMPERW7 = 60000;                           //tyw7 pin 109           
 1398  CCEA60            ldd #0xea60
 139B  7C00BA            std 0xba
 139E            ;   PWMDTYW7 = 4500;                                    //tyw7 pin 109
 139E  CC1194            ldd #4500
 13A1  7C00C2            std 0xc2
 13A4            ;   PWME= 0xaa;                                           // Enable ALL PWM Channels
 13A4  C6AA              ldab #170
 13A6  7B00A0            stab 0xa0
 13A9            ; 
 13A9            ; }
 13A9            L48:
 13A9                    .dbline 0 ; func end
 13A9  3D                rts
 13AA            _stop::
 13AA            ; 
 13AA            ; // Stop
 13AA            ; void stop()
 13AA            ; {
 13AA            ;    PWME = 0x00;
 13AA  7900A0            clr 0xa0
 13AD            ;    PWMDTYW5 = 4500;                       //4400 tyw5 pin 111
 13AD  CC1194            ldd #4500
 13B0  7C00C0            std 0xc0
 13B3            ;    PWMDTYW7 = 4500;                           //4600  tyw7 pin 109
 13B3  CC1194            ldd #4500
 13B6  7C00C2            std 0xc2
 13B9            ;    PWME = 0xaa;
 13B9  C6AA              ldab #170
 13BB  7B00A0            stab 0xa0
 13BE            ; }
 13BE            L49:
 13BE                    .dbline 0 ; func end
 13BE  3D                rts
 13BF            _reverse::
 13BF            ;    
 13BF            ; // reverse
 13BF            ; void reverse()
 13BF            ; {
 13BF            ;    PWME = 0x00;
 13BF  7900A0            clr 0xa0
 13C2            ;    PWMDTYW5 = 4100;           //half full speed forward 4876//tyw5 pin 111 4100
 13C2  CC1004            ldd #4100
 13C5  7C00C0            std 0xc0
 13C8            ;    PWMDTYW7 = 4900;           //half full speed reverse 4125// tyw7 pin 109 4900
 13C8  CC1324            ldd #4900
 13CB  7C00C2            std 0xc2
 13CE            ;    PWME = 0xaa;
 13CE  C6AA              ldab #170
 13D0  7B00A0            stab 0xa0
 13D3            ; }
 13D3            L50:
 13D3                    .dbline 0 ; func end
 13D3  3D                rts
 13D4            _forward::
 13D4            ; // forward
 13D4            ; void forward()
 13D4            ; {
 13D4            ;    PWME = 0x00;
 13D4  7900A0            clr 0xa0
 13D7            ;    PWMDTYW5 = 4900;                           //half full speed reverse//tyw5 pin 111 4900
 13D7  CC1324            ldd #4900
 13DA  7C00C0            std 0xc0
 13DD            ;    PWMDTYW7 = 4100;                           //half full speed forward//tyw7 pin 109 4100
 13DD  CC1004            ldd #4100
 13E0  7C00C2            std 0xc2
 13E3            ;    PWME = 0xaa;
 13E3  C6AA              ldab #170
 13E5  7B00A0            stab 0xa0
 13E8            ; }
 13E8            L51:
 13E8                    .dbline 0 ; func end
 13E8  3D                rts
 13E9            _right::
 13E9            ;    
 13E9            ; // right
 13E9            ; void right()
 13E9            ; {
 13E9            ;    PWME = 0x00;
 13E9  7900A0            clr 0xa0
 13EC            ;    PWMDTYW5 = 5000;                           //orignal speed 5250//tyw5 pin 111
 13EC  CC1388            ldd #5000
 13EF  7C00C0            std 0xc0
 13F2            ;    PWMDTYW7 = 5000;                           //orignal speed 5250//tyw7 pin 109
 13F2  CC1388            ldd #5000
 13F5  7C00C2            std 0xc2
 13F8            ;    PWME = 0xaa;
 13F8  C6AA              ldab #170
 13FA  7B00A0            stab 0xa0
 13FD            ; }
 13FD            L52:
 13FD                    .dbline 0 ; func end
 13FD  3D                rts
 13FE            _left::
 13FE            ; 
 13FE            ; // left
 13FE            ; void left()
 13FE            ; {
 13FE            ;    PWME = 0x00;
 13FE  7900A0            clr 0xa0
 1401            ;    PWMDTYW5 = 4000;                           //orignal speed 3750//tyw5 pin 111
 1401  CC0FA0            ldd #4000
 1404  7C00C0            std 0xc0
 1407            ;    PWMDTYW7 = 4000;                           //orignal speed 3750//tyw7 pin 109
 1407  CC0FA0            ldd #4000
 140A  7C00C2            std 0xc2
 140D            ;    PWME = 0xaa;
 140D  C6AA              ldab #170
 140F  7B00A0            stab 0xa0
 1412            ; }
 1412            L53:
 1412                    .dbline 0 ; func end
 1412  3D                rts
 1413            _init_tof::
 1413            ; 
 1413            ; //Initialize Timer Overflow 
 1413            ; void init_tof()
 1413            ; {
 1413            ;    SEI;
 1413  1410                      SEI
 1415            
 1415            ;    TSCR1 = 0x80;                                        //turn on Timer
 1415  C680              ldab #128
 1417  7B0046            stab 0x46
 141A            ;    TFLG2 = 0x80;                                        //clear TOF flag
 141A  C680              ldab #128
 141C  7B004F            stab 0x4f
 141F            ;    TSCR2 = 0x80;                                        //turn on TOF interrupt
 141F  C680              ldab #128
 1421  7B004D            stab 0x4d
 1424            ;    CLI;
 1424  10EF                      CLI
 1426            
 1426            ; }
 1426            L54:
 1426                    .dbline 0 ; func end
 1426  3D                rts
 1427            ;  lreg1 -> -4,x
 1427            ;  lreg2 -> -8,x
 1427            _TOF_isr::
 1427  34                pshx
 1428  B775              tfr s,x
 142A  1B98              leas -8,sp
 142C            ; 
 142C            ; //Timer Overflow Counter (ISR)
 142C            ; void TOF_isr()  
 142C            ; {
 142C            ;    t_counts++;
 142C  CD1B31            ldy #_t_counts
 142F  1802401C          movw 0,y,-4,x
 1433  1802421E          movw 2,y,-2,x
 1437  CD188B            ldy #L56
 143A  18024018          movw 0,y,-8,x
 143E  1802421A          movw 2,y,-6,x
 1442  161933            jsr __ladd
 1445  CD1B31            ldy #_t_counts
 1448  18021C40          movw -4,x,0,y
 144C  18021E42          movw -2,x,2,y
 1450            ;    if ((t_counts%38)==0)
 1450  CD1B31            ldy #_t_counts
 1453  1802401C          movw 0,y,-4,x
 1457  1802421E          movw 2,y,-2,x
 145B  CD1887            ldy #L59
 145E  18024018          movw 0,y,-8,x
 1462  1802421A          movw 2,y,-6,x
 1466  161A02            jsr __lmod
 1469  CD1883            ldy #L60
 146C  18024018          movw 0,y,-8,x
 1470  1802421A          movw 2,y,-6,x
 1474  161AD4            jsr __lcmp
 1477  2624              bne L57
 1479            ;    {
 1479            ;         t_tenths++;
 1479  CD1B2D            ldy #_t_tenths
 147C  1802401C          movw 0,y,-4,x
 1480  1802421E          movw 2,y,-2,x
 1484  CD188B            ldy #L56
 1487  18024018          movw 0,y,-8,x
 148B  1802421A          movw 2,y,-6,x
 148F  161933            jsr __ladd
 1492  CD1B2D            ldy #_t_tenths
 1495  18021C40          movw -4,x,0,y
 1499  18021E42          movw -2,x,2,y
 149D            ;    }
 149D            L57:
 149D            ;    if ((t_counts%4)==0)
 149D  CD1B31            ldy #_t_counts
 14A0  1802401C          movw 0,y,-4,x
 14A4  1802421E          movw 2,y,-2,x
 14A8  CD187F            ldy #L63
 14AB  18024018          movw 0,y,-8,x
 14AF  1802421A          movw 2,y,-6,x
 14B3  161A02            jsr __lmod
 14B6  CD1883            ldy #L60
 14B9  18024018          movw 0,y,-8,x
 14BD  1802421A          movw 2,y,-6,x
 14C1  161AD4            jsr __lcmp
 14C4  2624              bne L61
 14C6            ;    {
 14C6            ;       t_hundredths++;
 14C6  CD1B29            ldy #_t_hundredths
 14C9  1802401C          movw 0,y,-4,x
 14CD  1802421E          movw 2,y,-2,x
 14D1  CD188B            ldy #L56
 14D4  18024018          movw 0,y,-8,x
 14D8  1802421A          movw 2,y,-6,x
 14DC  161933            jsr __ladd
 14DF  CD1B29            ldy #_t_hundredths
 14E2  18021C40          movw -4,x,0,y
 14E6  18021E42          movw -2,x,2,y
 14EA            ;    }
 14EA            L61:
 14EA            ;    
 14EA            ;    TFLG2 = 0x80;
 14EA  C680              ldab #128
 14EC  7B004F            stab 0x4f
 14EF            ; }
 14EF            L55:
 14EF  B757              tfr x,s
 14F1  30                pulx
 14F2                    .dbline 0 ; func end
 14F2  0B                rti
 14F3            ;  lreg1 -> -4,x
 14F3            ;  lreg2 -> -8,x
 14F3            ;       end_time -> -12,x
 14F3            ;     pause_time -> 2,x
 14F3            _pause::
 14F3  3B                pshd
 14F4  34                pshx
 14F5  B775              tfr s,x
 14F7  1B94              leas -12,sp
 14F9            ; 
 14F9            ; //pause for pause_time*0.1 sec
 14F9            ; void pause(int pause_time)
 14F9            ; {
 14F9            ;    long int end_time;
 14F9            ;    end_time = t_tenths + pause_time;
 14F9  CD1B2D            ldy #_t_tenths
 14FC  1802401C          movw 0,y,-4,x
 1500  1802421E          movw 2,y,-2,x
 1504  EC02              ldd 2,x
 1506  1618EB            jsr __d2lreg2
 1509  161933            jsr __ladd
 150C  1914              leay -12,x
 150E  18021C40          movw -4,x,0,y
 1512  18021E42          movw -2,x,2,y
 1516            L65:
 1516            L66:
 1516            ; //   printf ("%ld = %ld + %d\n\r",end_time,t_tenths,pause_time);
 1516            ;    while(end_time>t_tenths)
 1516  1914              leay -12,x
 1518  1802401C          movw 0,y,-4,x
 151C  1802421E          movw 2,y,-2,x
 1520  CD1B2D            ldy #_t_tenths
 1523  18024018          movw 0,y,-8,x
 1527  1802421A          movw 2,y,-6,x
 152B  161AD4            jsr __lcmp
 152E  2EE6              bgt L65
 1530            ;    {
 1530            ;    }
 1530            ; }
 1530            L64:
 1530  B757              tfr x,s
 1532  30                pulx
 1533  1B82              leas 2,sp
 1535                    .dbline 0 ; func end
 1535  3D                rts
 1536            ;  lreg1 -> -4,x
 1536            ;  lreg2 -> -8,x
 1536            ;       end_time -> -12,x
 1536            ;     pause_time -> 2,x
 1536            _s_pause::
 1536  3B                pshd
 1537  34                pshx
 1538  B775              tfr s,x
 153A  1B94              leas -12,sp
 153C            ; 
 153C            ; //pause for pause_time*0.01 sec
 153C            ; void s_pause(int pause_time)
 153C            ; {
 153C            ;    long int end_time;
 153C            ;    end_time = t_hundredths + pause_time;
 153C  CD1B29            ldy #_t_hundredths
 153F  1802401C          movw 0,y,-4,x
 1543  1802421E          movw 2,y,-2,x
 1547  EC02              ldd 2,x
 1549  1618EB            jsr __d2lreg2
 154C  161933            jsr __ladd
 154F  1914              leay -12,x
 1551  18021C40          movw -4,x,0,y
 1555  18021E42          movw -2,x,2,y
 1559            L69:
 1559            L70:
 1559            ; //   printf ("%ld = %ld + %d\n\r",end_time,t_tenths,pause_time);
 1559            ;    while(end_time>t_hundredths)
 1559  1914              leay -12,x
 155B  1802401C          movw 0,y,-4,x
 155F  1802421E          movw 2,y,-2,x
 1563  CD1B29            ldy #_t_hundredths
 1566  18024018          movw 0,y,-8,x
 156A  1802421A          movw 2,y,-6,x
 156E  161AD4            jsr __lcmp
 1571  2EE6              bgt L69
 1573            ;    {
 1573            ;    }
 1573            ; }
 1573            L68:
 1573  B757              tfr x,s
 1575  30                pulx
 1576  1B82              leas 2,sp
 1578                    .dbline 0 ; func end
 1578  3D                rts
 1579            _init_atd0::
 1579            ; 
 1579            ; // ******************* Initialize ATD *******************
 1579            ; void init_atd0()
 1579            ; {
 1579            ;    SEI;
 1579  1410                      SEI
 157B            
 157B            ;    ATD0CTL2 = 0xC2;
 157B  C6C2              ldab #194
 157D  7B0082            stab 0x82
 1580            ;    ATD0CTL3 = 0x40;
 1580  C640              ldab #64
 1582  7B0083            stab 0x83
 1585            ;    ATD0CTL4 = 0xE7;
 1585  C6E7              ldab #231
 1587  7B0084            stab 0x84
 158A            ;    CLI;
 158A  10EF                      CLI
 158C            
 158C            ; }
 158C            L72:
 158C                    .dbline 0 ; func end
 158C  3D                rts
 158D            _ATD0_Interrupt::
 158D            ; 
 158D            ; /********************************************************************/
 158D            ; /* This code is primarily taken from example 7.3.5 in the text      */
 158D            ; /* and then converted to act as an ISR                              */
 158D            ; /********************************************************************/
 158D            ;   	  
 158D            ; void ATD0_Interrupt()
 158D            ; {
 158D            ; /*print results to PC screen for testing             */
 158D            ;    atd0[0]= ATD0DR0H;	
 158D            	; vol
 158D  F60090            ldab 0x90
 1590  87                clra
 1591  7C1B19            std _atd0
 1594            ;    atd0[1]= ATD0DR1H;
 1594                    ; vol
 1594  F60092            ldab 0x92
 1597  87                clra
 1598  7C1B1B            std _atd0+2
 159B            ;    atd0[2]= ATD0DR2H;
 159B                    ; vol
 159B  F60094            ldab 0x94
 159E  87                clra
 159F  7C1B1D            std _atd0+4
 15A2            ;    atd0[3]= ATD0DR3H;
 15A2                    ; vol
 15A2  F60096            ldab 0x96
 15A5  87                clra
 15A6  7C1B1F            std _atd0+6
 15A9            ;    atd0[4]= ATD0DR4H;
 15A9                    ; vol
 15A9  F60098            ldab 0x98
 15AC  87                clra
 15AD  7C1B21            std _atd0+8
 15B0            ;    atd0[5]= ATD0DR5H;
 15B0                    ; vol
 15B0  F6009A            ldab 0x9a
 15B3  87                clra
 15B4  7C1B23            std _atd0+10
 15B7            ;    atd0[6]= ATD0DR6H;
 15B7                    ; vol
 15B7  F6009C            ldab 0x9c
 15BA  87                clra
 15BB  7C1B25            std _atd0+12
 15BE            ;    atd0[7]= ATD0DR7H;         
 15BE                    ; vol
 15BE  F6009E            ldab 0x9e
 15C1  87                clra
 15C2  7C1B27            std _atd0+14
 15C5            ; 
 15C5            ; }
 15C5            L73:
 15C5                    .dbline 0 ; func end
 15C5  0B                rti
 15C6            _init_atd1::
 15C6            ; 
 15C6            ; // ******************* Initialize ATD *******************
 15C6            ; void init_atd1()
 15C6            ; {
 15C6            ;    SEI;
 15C6  1410                      SEI
 15C8            
 15C8            ;    ATD1CTL2 = 0xC2;
 15C8  C6C2              ldab #194
 15CA  7B0122            stab 0x122
 15CD            ;    ATD1CTL3 = 0x40;
 15CD  C640              ldab #64
 15CF  7B0123            stab 0x123
 15D2            ;    ATD1CTL4 = 0xE7;
 15D2  C6E7              ldab #231
 15D4  7B0124            stab 0x124
 15D7            ;    CLI;
 15D7  10EF                      CLI
 15D9            
 15D9            ; }
 15D9            L81:
 15D9                    .dbline 0 ; func end
 15D9  3D                rts
 15DA            _ATD1_Interrupt::
 15DA            ; 
 15DA            ; /********************************************************************/
 15DA            ; /* This code is primarily taken from example 7.3.5 in the text      */
 15DA            ; /* and then converted to act as an ISR                              */
 15DA            ; /********************************************************************/
 15DA            ;   	  
 15DA            ; void ATD1_Interrupt()
 15DA            ; {
 15DA            ; /*print results to PC screen for testing             */
 15DA            ;    atd1[0]= ATD1DR0H;	
 15DA            	; vol
 15DA  F60130            ldab 0x130
 15DD  87                clra
 15DE  7C1B09            std _atd1
 15E1            ;    atd1[1]= ATD1DR1H;
 15E1                    ; vol
 15E1  F60132            ldab 0x132
 15E4  87                clra
 15E5  7C1B0B            std _atd1+2
 15E8            ;    atd1[2]= ATD1DR2H;
 15E8                    ; vol
 15E8  F60134            ldab 0x134
 15EB  87                clra
 15EC  7C1B0D            std _atd1+4
 15EF            ;    atd1[3]= ATD1DR3H;
 15EF                    ; vol
 15EF  F60136            ldab 0x136
 15F2  87                clra
 15F3  7C1B0F            std _atd1+6
 15F6            ;    atd1[4]= ATD1DR4H;
 15F6                    ; vol
 15F6  F60138            ldab 0x138
 15F9  87                clra
 15FA  7C1B11            std _atd1+8
 15FD            ;    atd1[5]= ATD1DR5H;
 15FD                    ; vol
 15FD  F6013A            ldab 0x13a
 1600  87                clra
 1601  7C1B13            std _atd1+10
 1604            ;    atd1[6]= ATD1DR6H;
 1604                    ; vol
 1604  F6013C            ldab 0x13c
 1607  87                clra
 1608  7C1B15            std _atd1+12
 160B            ;    atd1[7]= ATD1DR7H;         
 160B                    ; vol
 160B  F6013E            ldab 0x13e
 160E  87                clra
 160F  7C1B17            std _atd1+14
 1612            ;  
 1612            ; //Checking Line Track
 1612            ;   line = 0;
 1612  CC0000            ldd #0
 1615  7C1B05            std _line
 1618            ;   
 1618            ;   if (atd1[0] < line_threshold)
 1618  FC1B09            ldd _atd1
 161B  BC1052            cpd _line_threshold
 161E  2409              bhs L90
 1620            ;   {
 1620            ;     line += 0x1;
 1620  FC1B05            ldd _line
 1623  C30001            addd #1
 1626  7C1B05            std _line
 1629            ;   }
 1629            L90:
 1629            ;   if (atd1[1] < line_threshold)
 1629  FC1B0B            ldd _atd1+2
 162C  BC1052            cpd _line_threshold
 162F  2409              bhs L92
 1631            ;   {
 1631            ;     line += 0x2;
 1631  FC1B05            ldd _line
 1634  C30002            addd #2
 1637  7C1B05            std _line
 163A            ;    }
 163A            L92:
 163A            ;   if (atd1[2] < line_threshold)
 163A  FC1B0D            ldd _atd1+4
 163D  BC1052            cpd _line_threshold
 1640  2409              bhs L95
 1642            ;    {
 1642            ;     line += 0x4;
 1642  FC1B05            ldd _line
 1645  C30004            addd #4
 1648  7C1B05            std _line
 164B            ;    }
 164B            L95:
 164B            ; //Checking Intersection 
 164B            ;   Intersection = 0;
 164B  CC0000            ldd #0
 164E  7C1AFB            std _Intersection
 1651            ;   
 1651            ;   if (atd1[6] < Intersection_threshold)
 1651  FC1B15            ldd _atd1+12
 1654  BC1054            cpd _Intersection_threshold
 1657  2409              bhs L98
 1659            ;   {
 1659            ;     Intersection += 0x1;
 1659  FC1AFB            ldd _Intersection
 165C  C30001            addd #1
 165F  7C1AFB            std _Intersection
 1662            ;   }
 1662            L98:
 1662            ;   if (atd1[7] < Intersection_threshold)
 1662  FC1B17            ldd _atd1+14
 1665  BC1054            cpd _Intersection_threshold
 1668  2409              bhs L101
 166A            ;   {
 166A            ;     Intersection += 0x2;
 166A  FC1AFB            ldd _Intersection
 166D  C30002            addd #2
 1670  7C1AFB            std _Intersection
 1673            ;    }
 1673            L101:
 1673            ; //Checking Backup 
 1673            ;   Backup = 0;
 1673  CC0000            ldd #0
 1676  7C1AF9            std _Backup
 1679            ;   
 1679            ;   if (atd1[3] < Backup_threshold)
 1679  FC1B0F            ldd _atd1+6
 167C  BC1056            cpd _Backup_threshold
 167F  2409              bhs L104
 1681            ;   {
 1681            ;     Backup += 0x1;
 1681  FC1AF9            ldd _Backup
 1684  C30001            addd #1
 1687  7C1AF9            std _Backup
 168A            ;   }
 168A            L104:
 168A            ;   if (atd1[4] < Backup_threshold)
 168A  FC1B11            ldd _atd1+8
 168D  BC1056            cpd _Backup_threshold
 1690  2409              bhs L107
 1692            ;   {
 1692            ;     Backup += 0x2;
 1692  FC1AF9            ldd _Backup
 1695  C30002            addd #2
 1698  7C1AF9            std _Backup
 169B            ;    }
 169B            L107:
 169B            ;   if (atd1[5] < Backup_threshold)
 169B  FC1B13            ldd _atd1+10
 169E  BC1056            cpd _Backup_threshold
 16A1  2409              bhs L110
 16A3            ;    {
 16A3            ;     Backup += 0x4;
 16A3  FC1AF9            ldd _Backup
 16A6  C30004            addd #4
 16A9  7C1AF9            std _Backup
 16AC            ;    }
 16AC            L110:
 16AC            ;    
 16AC            ;   // printf("%x %x %x %x\n\r", atd1[0], atd1[1], atd1[2], line); 	
 16AC            ; }
 16AC            L82:
 16AC                    .dbline 0 ; func end
 16AC  0B                rti
 16AD            L114:
 16AD  BAB9              .word 47801
 16AF  A65D              .word 42589
 16B1  9430              .word 37936
 16B3  8BE9              .word 35817
 16B5  7C90              .word 31888
 16B7  6EF9              .word 28409
 16B9  62D7              .word 25303
 16BB  5D5C              .word 23900
 16BD            L115:
 16BD  0005              .word 5
 16BF  0005              .word 5
 16C1  0005              .word 5
 16C3  0005              .word 5
 16C5  0005              .word 5
 16C7  0005              .word 5
 16C9  0005              .word 5
 16CB  0005              .word 5
 16CD            ;              i -> -36,x
 16CD            ;            dur -> -34,x
 16CD            ;          score -> -18,x
 16CD            ;              j -> -2,x
 16CD            _Speaker::
 16CD  34                pshx
 16CE  B775              tfr s,x
 16D0  1BF1DA            leas -38,sp
 16D3            ; 
 16D3            ; //*****************************************************************************
 16D3            ; #define  C5  47801
 16D3            ; #define  C5S 45126
 16D3            ; #define  D5    42589
 16D3            ; #define        D5S 40193
 16D3            ; #define        E5  37936
 16D3            ; #define  F5    35817
 16D3            ; #define  F5S 33784
 16D3            ; #define        G5      31888
 16D3            ; #define  G5S 30084
 16D3            ; #define  A5    28409
 16D3            ; #define  A5S 26824
 16D3            ; #define  B5    25303
 16D3            ; #define  C6    23900
 16D3            ; #define  C6S 22542
 16D3            ; #define  D6  21276
 16D3            ; #define  D6S 20096
 16D3            ; #define  E6  18825
 16D3            ; #define  F6  17895
 16D3            ; #define  F6S 16892
 16D3            ; #define  G6    15944
 16D3            ; #define  G6S 15051
 16D3            ; #define  A6  14204
 16D3            ; #define  A6S 13404
 16D3            ; #define  B6  12658
 16D3            ; 
 16D3            ; 
 16D3            ; #define  notes  8
 16D3            ; #define  toggle 0x04
 16D3            ; 
 16D3            ; void Speaker ()
 16D3            ; {
 16D3            ;    int j;
 16D3            ;    int i;
 16D3            ;    unsigned int score[notes] = {C5,D5,E5,F5,G5,A5,B5,C6};
 16D3  19E1EE            leay -18,x
 16D6  B7C6              xgdy
 16D8  CD16AD            ldy #L114
 16DB  34                pshx
 16DC  B745              tfr d,x
 16DE  CC0008            ldd #8
 16E1            X3:
 16E1  18027131          movw 2,y+,2,x+
 16E5  0434F9            dbne d,X3
 16E8  30                pulx
 16E9            ;    unsigned int dur[notes] = {5,5,5,5,5,5,5,5};
 16E9  19E1DE            leay -34,x
 16EC  B7C6              xgdy
 16EE  CD16BD            ldy #L115
 16F1  34                pshx
 16F2  B745              tfr d,x
 16F4  CC0008            ldd #8
 16F7            X4:
 16F7  18027131          movw 2,y+,2,x+
 16FB  0434F9            dbne d,X4
 16FE  30                pulx
 16FF            ; 
 16FF            ; //   TSCR1 = 0x90;   //Enable TCNT, fast timer flag clear
 16FF            ; //   TSCR2 = 0x83;   //Set TCNT prescaler to 8
 16FF            ;    TFLG1 = 0x20;   //Clear all TxF flags
 16FF  C620              ldab #32
 1701  7B004E            stab 0x4e
 1704            ;    TIE  |= 0x20;   //Enable TC5 interrupt
 1704  1C004C20          bset 0x4c,#32
 1708            ;    TIOS |= 0x20;   //Enable OC5 function
 1708  1C004020          bset 0x40,#32
 170C            ;    TCTL1 = toggle; //Select toggle option as OC5 pin action
 170C  C604              ldab #4
 170E  7B0048            stab 0x48
 1711            ;    j = 0;
 1711  CC0000            ldd #0
 1714  6C1E              std -2,x
 1716            ;    dela = score[0];
 1716  ECE1EE            ldd -18,x
 1719  7C1B07            std _dela
 171C            ;    TC5 = TCNT + dela;      //Play the first note
 171C                    ; vol
 171C  FC0044            ldd 0x44
 171F  F31B07            addd _dela
 1722  7C005A            std 0x5a
 1725  202D              bra L117
 1727            L116:
 1727  19E1EE            leay -18,x
 172A  6DE1DA            sty -38,x
 172D  EC1E              ldd -2,x
 172F  59                lsld
 1730  E3E1DA            addd -38,x
 1733  B7C6              xgdy
 1735  EC40              ldd 0,y
 1737  7C1B07            std _dela
 173A  19E1DE            leay -34,x
 173D  6DE1DA            sty -38,x
 1740  EC1E              ldd -2,x
 1742  59                lsld
 1743  E3E1DA            addd -38,x
 1746  B7C6              xgdy
 1748  EC40              ldd 0,y
 174A  161536            jsr _s_pause
 174D  EC1E              ldd -2,x
 174F  C30001            addd #1
 1752  6C1E              std -2,x
 1754            L117:
 1754            ;    while(j < notes)
 1754  EC1E              ldd -2,x
 1756  8C0008            cpd #8
 1759  2DCC              blt L116
 175B            ;    {
 175B            ;       dela = score[j];     //Play the jth note
 175B            ;         s_pause(dur[j]);
 175B            ;         j++;
 175B            ;    }
 175B            ; 
 175B            ;    TIE  &= ~0x20;   //Disable TC5 interrupt
 175B  1D004C20          bclr 0x4c,#0x20
 175F            ; //   TSCR1 = 0x00;   //Turn off the Timer System
 175F            ;    PTT = 0x00;     //Blank Port T
 175F  790240            clr 0x240
 1762            ;    TCTL1 = 0;
 1762  790048            clr 0x48
 1765            ; }
 1765            L113:
 1765  B757              tfr x,s
 1767  30                pulx
 1768                    .dbline 0 ; func end
 1768  3D                rts
 1769            _OC5_ISR::
 1769            ; 
 1769            ; //******************************** OC5_ISR *************************************
 1769            ; 
 1769            ; #pragma interrupt_handler OC5_ISR()
 1769            ; void OC5_ISR ()
 1769            ; {
 1769            ;    TC5 += dela;
 1769            	; vol
 1769  FC005A            ldd 0x5a
 176C  F31B07            addd _dela
 176F  7C005A            std 0x5a
 1772            ;    TFLG1 = 0x20;
 1772  C620              ldab #32
 1774  7B004E            stab 0x4e
 1777            ; }
 1777            L119:
 1777                    .dbline 0 ; func end
 1777  0B                rti
 1778            ;        fr_line -> -2,x
 1778            ;             fr -> 2,x
 1778            _linetrack::
 1778  3B                pshd
 1779  34                pshx
 177A  B775              tfr s,x
 177C  1B9E              leas -2,sp
 177E            ; //******************************************************************************
 177E            ; /*measure motor speed testing             */  
 177E            ; // void motorspeed();
 177E            ; //{
 177E            ; //   printf("%d %d\n\r",a,b); 
 177E            ;         
 177E            ;   //PWME = 0x00;
 177E            ;   // PWMDTYW1 = a;                                     //measure motor speed//
 177E            ;   // PWMDTYW3 = b;                                      //measure motor speed//
 177E            ;   // PWME = 0xaa;                                        //measure motor speed//
 177E            ;    
 177E            ;   // pause(50);                                                   //measure motor speed//
 177E            ;   // a = a+100;
 177E            ;   // b = b-100;
 177E            ; 
 177E            ; //}
 177E            ; //******************************************************************************
 177E            ; /*speedcontrol stepup testing                                         */
 177E            ;  /*
 177E            ;  void speedcontrol()
 177E            ;  
 177E            ;  {
 177E            ;       ob_led(8);
 177E            ; forward();             // set the speed control test//
 177E            ; pause(20);             // set the speed control test//
 177E            ;       
 177E            ; stop();                        // set the speed control test//
 177E            ; pause(20);             // set the speed control test//
 177E            ;        ob_led(9);      // set the speed control test//  
 177E            ; reverse();             // set the speed control test//
 177E            ; pause(20);             // set the speed control test//
 177E            ;    
 177E            ; stop();                        // set the speed control test//
 177E            ; pause(20);             // set the speed control test//
 177E            ;       
 177E            ;   } 
 177E            ; */
 177E            ; 
 177E            ; //******************************************************************************
 177E            ; /*linetrack  testing                                          */
 177E            ; void linetrack(int fr)
 177E            ; {
 177E  2061              bra L122
 1780            L121:
 1780            ;    int fr_line;
 1780            ;    while(((Intersection!=0x03)&&(fr==0))||((Backup!=0x07)&&(fr==1)))
 1780            ;    {
 1780            ;       if (fr==0)
 1780  EC02              ldd 2,x
 1782  2607              bne L124
 1784            ;       {
 1784            ;          fr_line=line;
 1784  18011E1B05        movw _line,-2,x
 1789            ;       }
 1789  2005              bra L125
 178B            L124:
 178B            ;       else
 178B            ;       {
 178B            ;          fr_line=Backup;
 178B  18011E1AF9        movw _Backup,-2,x
 1790            ;       }
 1790            L125:
 1790            ; 
 1790            ;       ob_led(line);     
 1790  FC1B05            ldd _line
 1793  16131C            jsr _ob_led
 1796            ; 
 1796            ;       switch(fr_line)
 1796  EC1E              ldd -2,x
 1798  8C0001            cpd #1
 179B  2710              beq L128
 179D  EC1E              ldd -2,x
 179F  8C0002            cpd #2
 17A2  270E              beq L129
 17A4  EC1E              ldd -2,x
 17A6  8C0004            cpd #4
 17A9  2715              beq L132
 17AB  2016              bra L126
 17AD            X5:
 17AD            ;       {
 17AD            L128:
 17AD            ; 	  case 1:
 17AD            ;          left();
 17AD  1613FE            jsr _left
 17B0            ; //               printf ("left\n\r");
 17B0            ;            break;
 17B0  2011              bra L127
 17B2            L129:
 17B2            ; 	  case 2:	
 17B2            ;          if (fr==0)
 17B2  EC02              ldd 2,x
 17B4  2605              bne L130
 17B6            ;                {
 17B6            ;                   forward();
 17B6  1613D4            jsr _forward
 17B9            ;          }
 17B9  2008              bra L127
 17BB            L130:
 17BB            ; 		 else
 17BB            ; 		 {
 17BB            ; 		    reverse();
 17BB  1613BF            jsr _reverse
 17BE            ;          }
 17BE            ; 
 17BE            ;                break;
 17BE  2003              bra L127
 17C0            L132:
 17C0            ;       case 4:		  
 17C0            ; 		 right();
 17C0  1613E9            jsr _right
 17C3            ; //               printf ("right\n\r");
 17C3            ;                break;
 17C3            L126:
 17C3            L127:
 17C3            ; /*      default:
 17C3            ;          if (fr==0)
 17C3            ; 		 {
 17C3            ; 		    forward();
 17C3            ;          }
 17C3            ; 		 else
 17C3            ; 		 {
 17C3            ; 		    reverse();
 17C3            ;          }
 17C3            ; */
 17C3            ;       }
 17C3            ; 	  
 17C3            ; 	  pause(1);
 17C3  CC0001            ldd #1
 17C6  1614F3            jsr _pause
 17C9            ;          if (fr==0)
 17C9  EC02              ldd 2,x
 17CB  260B              bne L133
 17CD            ;                {
 17CD            ;                   forward();
 17CD  1613D4            jsr _forward
 17D0            ;               s_pause(5);                             //original number 10
 17D0  CC0005            ldd #5
 17D3  161536            jsr _s_pause
 17D6            ;            }
 17D6  2009              bra L134
 17D8            L133:
 17D8            ; 		 else
 17D8            ; 		 {
 17D8            ; 		    reverse();
 17D8  1613BF            jsr _reverse
 17DB            ;                   s_pause(8);                         //original number 25
 17DB  CC0008            ldd #8
 17DE  161536            jsr _s_pause
 17E1            ;          }
 17E1            L134:
 17E1            L122:
 17E1  FC1AFB            ldd _Intersection
 17E4  8C0003            cpd #3
 17E7  2704              beq L135
 17E9  EC02              ldd 2,x
 17EB  2793              beq L121
 17ED            L135:
 17ED  FC1AF9            ldd _Backup
 17F0  8C0007            cpd #7
 17F3  2709              beq L136
 17F5  EC02              ldd 2,x
 17F7  8C0001            cpd #1
 17FA  1827FF82          lbeq L121
 17FE            L136:
 17FE            ;    }
 17FE            ; }
 17FE            L120:
 17FE  B757              tfr x,s
 1800  30                pulx
 1801  1B82              leas 2,sp
 1803                    .dbline 0 ; func end
 1803  3D                rts
 1804            _init_ic0_1::
 1804            ; 
 1804            ; //******************************************************************************
 1804            ; // IC0-1 Init
 1804            ; 
 1804            ; void init_ic0_1(void)
 1804            ; {
 1804            ; //   TSCR2 = 0x81;	   //might interfere with SOUND!!!!!!!!!!!!!!!! but in for testing
 1804            ;    TFLG1 = 0x03;   //Clear flags
 1804  C603              ldab #3
 1806  7B004E            stab 0x4e
 1809            ;    TIE  |= 0x03;   //Enable IC0+1 interrupt
 1809  1C004C03          bset 0x4c,#3
 180D            ;    TIOS &= 0xfc;   //make 0+1 input capture
 180D  1D004003          bclr 0x40,#0x3
 1811            ;    TCTL4 = 0x05;   //capture 0+1 on rising edge
 1811  C605              ldab #5
 1813  7B004B            stab 0x4b
 1816            ; }
 1816            L137:
 1816                    .dbline 0 ; func end
 1816  3D                rts
 1817            ;  lreg1 -> -4,x
 1817            ;  lreg2 -> -8,x
 1817            _IC0_ISR::
 1817  34                pshx
 1818  B775              tfr s,x
 181A  1B98              leas -8,sp
 181C            ; 
 181C            ; void IC0_ISR (void)
 181C            ; {
 181C            ;    TFLG1 = 0x01;      // clear int flag 
 181C  C601              ldab #1
 181E  7B004E            stab 0x4e
 1821            ;    IC0_count++;
 1821  CD1B01            ldy #_IC0_count
 1824  1802401C          movw 0,y,-4,x
 1828  1802421E          movw 2,y,-2,x
 182C  CD187B            ldy #L139
 182F  18024018          movw 0,y,-8,x
 1833  1802421A          movw 2,y,-6,x
 1837  161933            jsr __ladd
 183A  CD1B01            ldy #_IC0_count
 183D  18021C40          movw -4,x,0,y
 1841  18021E42          movw -2,x,2,y
 1845            ; }
 1845            L138:
 1845  B757              tfr x,s
 1847  30                pulx
 1848                    .dbline 0 ; func end
 1848  0B                rti
 1849            ;  lreg1 -> -4,x
 1849            ;  lreg2 -> -8,x
 1849            _IC1_ISR::
 1849  34                pshx
 184A  B775              tfr s,x
 184C  1B98              leas -8,sp
 184E            ; 
 184E            ; 
 184E            ; void IC1_ISR (void)
 184E            ; {
 184E            ;    TFLG1 = 0x02;      // clear int flag
 184E  C602              ldab #2
 1850  7B004E            stab 0x4e
 1853            ;    IC1_count++;
 1853  CD1AFD            ldy #_IC1_count
 1856  1802401C          movw 0,y,-4,x
 185A  1802421E          movw 2,y,-2,x
 185E  CD187B            ldy #L139
 1861  18024018          movw 0,y,-8,x
 1865  1802421A          movw 2,y,-6,x
 1869  161933            jsr __ladd
 186C  CD1AFD            ldy #_IC1_count
 186F  18021C40          movw -4,x,0,y
 1873  18021E42          movw -2,x,2,y
 1877            ; }
 1877            L140:
 1877  B757              tfr x,s
 1879  30                pulx
 187A                    .dbline 0 ; func end
 187A  0B                rti
                        .area bss
 1AF9            _Backup::
 1AF9                    .blkb 2
 1AFB            _Intersection::
 1AFB                    .blkb 2
 1AFD            _IC1_count::
 1AFD                    .blkb 4
 1B01            _IC0_count::
 1B01                    .blkb 4
 1B05            _line::
 1B05                    .blkb 2
 1B07            _dela::
 1B07                    .blkb 2
 1B09            _atd1::
 1B09                    .blkb 16
 1B19            _atd0::
 1B19                    .blkb 16
 1B29            _t_hundredths::
 1B29                    .blkb 4
 1B2D            _t_tenths::
 1B2D                    .blkb 4
 1B31            _t_counts::
 1B31                    .blkb 4
                        .area text
--- 0829           L139:
--- 0829 00000001          .word 0,1
--- 082D           L63:
--- 082D 00000004          .word 0,4
--- 0831           L60:
--- 0831 00000000          .word 0,0
--- 0835           L59:
--- 0835 00000026          .word 0,38
--- 0839           L56:
--- 0839 00000001          .word 0,1
--- 083D           L36:
--- 083D 00004C90          .word 0,19600
--- 0841           L32:
--- 0841 00000BB8          .word 0,3000
--- 0845           L28:
--- 0845 00000398          .word 0,920
--- 0849           L21:
--- 0849 00000A8C          .word 0,2700
--- 084D           L17:
--- 084D 00004268          .word 0,17000
--- 0851           L13:
--- 0851 00000000          .word 0,0
