                         .module denise.c
 0000                   .dbfile denise.c
                         .area text
                       ;  IX -> 0,x
 0000                 _SCI_isr::
 0000                   .dbfile C:\ICCTK\include/isrtk.h
 0000                   .dbfunc SCI_isr
 0000                   .dbline 40
                       ; /************************************************************************
                       ;  * Title        smokeden.c                                                  
                       ;  * Programmer   Sean Justice                            
                       ;  * Date         July 17,1999                                        
                       ;  * Version  1                                   
                       ;  *                                      
                       ;  * Description
                       ;  * Start by hit the rear bumper and then Denise will not do 
                       ;  * anything until she has detected smoke.
                       ;  *  
                       ;  *  Functions:
                       ;  *      detectsmoke() used to detect if the smoke detector 
                       ;  *      has detected any smoke
                       ;  *                              
                       ;  * Use Hyperterm with the following settings:                           
                       ;  *                                      
                       ;  *      COM1, 9600 Baud, 8 bits, No Parity, 1 Stop bit, No Flow         
                       ;  *      of Control, VT100 Terminal, WrapLines.              
                       ;  *                                  
                       ;  *Usage: Verify functionality of TALRIK's sensors.
                       ;  ************************************************************************/
                       ;  
                       ; /**************************** Includes **********************************/
                       ; 
                       ; #include <tkbase.h>
                       ; 
                       ; 
                       ; /************************ End of includes *******************************/
                       ; 
                       ; 
                       ; /*************************** Constants **********************************/
                       ; 
                       ; /*IR emitter output port driver, the output latch at address 0xffb9 */
                       ; #define IRE_OUT   *(unsigned char *)(0xffb9) 
                       ; 
                       ; /*Constant for driving all the 40KHz modulated IR emitters on when loaded into IRE_OUT */
                       ; #define IRE_ALL_ON 0xff 
                       ; 
                       ; /*Constant for turning all the 40KHz modulated IR emitters off when loaded into IRE_OUT */
                       ; #define IRE_ALL_OFF 0x00
 0000                 L2:
 0000 3B                rti
                       ;  IX -> 0,x
 0001                 _SPI_isr::
 0001                   .dbfunc SPI_isr
 0001                   .dbline 46
                       ; 
                       ; #define BUMPER_FUZZY 10
                       ; #define NOSMOKE 40
                       ; #define IRTHRESHOLD 110
                       ; #define FIRE 45
                       ; #define FIRE2 40
 0001                 L3:
 0001 3B                rti
                       ;  IX -> 0,x
 0002                 _PAIE_isr::
 0002                   .dbfunc PAIE_isr
 0002                   .dbline 52
                       ; #define HEAT 45
                       ;  
                       ; /************************ End of Constants ******************************/
                       ; int rspeed = 0;
                       ; int lspeed = 0;
                       ; unsigned int temp_one = 0;
 0002                 L4:
 0002 3B                rti
                       ;  IX -> 0,x
 0003                 _PAV_isr::
 0003                   .dbfunc PAV_isr
 0003                   .dbline 58
                       ; unsigned int temp_two = 0;
                       ; unsigned int left = 0;
                       ; unsigned int right = 0;
                       ; /******************functions***********************************/
                       ; 
                       ; void detectsmoke(void);
 0003                 L5:
 0003 3B                rti
                       ;  IX -> 0,x
 0004                 _TOF_isr::
 0004                   .dbfunc TOF_isr
 0004                   .dbline 64
                       ; void avoidobject(void);
                       ; void righturn(void);
                       ; void lefturn(void);
                       ; void checkbumper(void);
                       ; void firecheck(void);
                       ; void intitemp(void);
 0004                 L6:
 0004 3B                rti
                       ;  IX -> 0,x
 0005                 _TOC4_isr::
 0005                   .dbfunc TOC4_isr
 0005                   .dbline 76
                       ; void lookright(void);
                       ; void lookleft(void);
                       ; void heatcheck(void);
                       ; void motorforward(void);
                       ; void heatsource(void);
                       ; void heatforward(void);
                       ; void firesignal(void);
                       ; 
                       ; 
                       ; 
                       ; void main(void)
                       ; /****************************** Main ***********************************/
 0005                 L7:
 0005 3B                rti
                       ;  IX -> 0,x
 0006                 _TOC1_isr::
 0006                   .dbfunc TOC1_isr
 0006                   .dbline 94
                       ; {
                       ;   init_analog();
                       ;   init_motortk();
                       ;   init_clocktk();
                       ;   init_serial();
                       ; 
                       ;   IRE_OUT = IRE_ALL_ON;    /* Turns on all the 40KHz modulated IR emitters */
                       ;   
                       ;   wait(300);
                       ;   
                       ;   while (rear_bumper() < BUMPER_FUZZY); /*To start press the rear bumper*/
                       ;   
                       ;   read_IR();
                       ;   wait(35);
                       ;   
                       ;   detectsmoke(); /*don't do anything unitl smoke is detected*/
                       ;   intitemp();   /*See what the temperature in the room is*/
                       ;   
 0006                 L8:
 0006 3B                rti
                       ;  IX -> 0,x
 0007                 _TIC3_isr::
 0007                   .dbfunc TIC3_isr
 0007                   .dbline 100
                       ;   
                       ;   
                       ;   while (1)
                       ;   {
                       ;     checkbumper();  /*See if bumper has been hit*/
                       ;           
 0007                 L9:
 0007 3B                rti
                       ;  IX -> 0,x
 0008                 _TIC2_isr::
 0008                   .dbfunc TIC2_isr
 0008                   .dbline 106
                       ;     firecheck();    /*checks if there is a flame*/
                       ;     
                       ;     lookright();    /*look to the right*/
                       ;     lookleft();     /*look to the left*/
                       ;     motorforward();
                       ;     heatcheck();    /*check for heat increase*/
 0008                 L10:
 0008 3B                rti
                       ;  IX -> 0,x
 0009                 _TIC1_isr::
 0009                   .dbfunc TIC1_isr
 0009                   .dbline 112
                       ;   }
                       ; }
                       ; /************************fucntions*************************************************/
                       ; 
                       ; /* function to detect the smoke, this function will alert Denise to the problem*/
                       ; void detectsmoke(void)
 0009                 L11:
 0009 3B                rti
                       ;  IX -> 0,x
 000A                 _RTI_isr::
 000A                   .dbfunc RTI_isr
 000A                   .dbline 118
                       ; {
                       ;     read_IR();
                       ;     wait(35);
                       ;     
                       ;     while (IRDT[IR5clk] < NOSMOKE)
                       ;         {
 000A                 L12:
 000A 3B                rti
                       ;  IX -> 0,x
 000B                 _IRQ_isr::
 000B                   .dbfunc IRQ_isr
 000B                   .dbline 124
                       ;             read_IR();
                       ;             
                       ;             wait(35);
                       ;         }
                       ;     
                       ; }
 000B                 L13:
 000B 3B                rti
                       ;  IX -> 0,x
 000C                 _XIRQ_isr::
 000C                   .dbfunc XIRQ_isr
 000C                   .dbline 130
                       ; /* function initize the heat sensors for the temp of the room */
                       ; 
                       ; void intitemp(void)
                       ; {
                       ;     
                       ;     read_IR();
 000C                 L14:
 000C 3B                rti
                       ;  IX -> 0,x
 000D                 _SWI_isr::
 000D                   .dbfunc SWI_isr
 000D                   .dbline 136
                       ;     wait(35);
                       ;     
                       ;     temp_one = IRDT[2];
                       ;     temp_two = IRDT[3];
                       ;     
                       ; }
 000D                 L15:
 000D 3B                rti
                       ;  IX -> 0,x
 000E                 _ILLOP_isr::
 000E                   .dbfunc ILLOP_isr
 000E                   .dbline 142
                       ; /* this program checks the bumper front and rear to see if anything has hit it*/
                       ; 
                       ; void checkbumper(void)
                       ; {
                       ;     if (rear_bumper() > BUMPER_FUZZY)
                       ;         {
 000E                 L16:
 000E 3B                rti
                       ;  IX -> 0,x
 000F                 _COP_isr::
 000F                   .dbfunc COP_isr
 000F                   .dbline 148
                       ;             
                       ;             rspeed = lspeed = 50;
                       ;             motortk(RIGHT_MOTOR, rspeed);
                       ;             motortk(LEFT_MOTOR, lspeed);
                       ;             wait(1000);
                       ;             rspeed = 100;
 000F                 L17:
 000F 3B                rti
                       ;  IX -> 0,x
 0010                 _CLMON_isr::
 0010                   .dbfunc CLMON_isr
 0010                   .dbline 154
                       ;             lspeed = -100;
                       ;             motortk(RIGHT_MOTOR, rspeed);
                       ;             motortk(LEFT_MOTOR, lspeed);
                       ;             wait(1000);
                       ;         }
                       ;     else if (front_bumper() > BUMPER_FUZZY)
 0010                 L18:
 0010 3B                rti
                         .area data
 0000                 _drew::
 0000                   .blkw 1
                         .area idata
 0000 0000              .word _interrupt_vectors
                         .area data
 0002                 _rspeed::
 0002                   .blkb 2
                         .area idata
 0002 0000              .word 0
                         .area data
 0004                 _lspeed::
 0004                   .blkb 2
                         .area idata
 0004 0000              .word 0
                         .area data
 0006                 _temp_one::
 0006                   .blkb 2
                         .area idata
 0006 0000              .word 0
                         .area data
 0008                 _temp_two::
 0008                   .blkb 2
                         .area idata
 0008 0000              .word 0
                         .area data
 000A                 _left::
 000A                   .blkb 2
                         .area idata
 000A 0000              .word 0
                         .area data
 000C                 _right::
 000C                   .blkb 2
                         .area idata
 000C 0000              .word 0
                         .area text
                       ;  IX -> 0,x
 0011                 _main::
 0011                   .dbfile denise.c
 0011                   .dbfunc main
 0011                   .dbline 78
 0011 BD0000            jsr _init_analog
 0014                   .dbline 79
 0014 BD0000            jsr _init_motortk
 0017                   .dbline 80
 0017 BD0000            jsr _init_clocktk
 001A                   .dbline 81
 001A BD0000            jsr _init_serial
 001D                   .dbline 83
 001D C6FF              ldab #255
 001F F7FFB9            stab 0xffb9
 0022                   .dbline 85
 0022 CC012C            ldd #300
 0025 BD0000            jsr _wait
 0028                 L20:
 0028                   .dbline 87
 0028                 L21:
 0028 BD0000            jsr _rear_bumper
 002B 1A83000A          cpd #10
 002F 25F7              blo L20
 0031                   .dbline 89
 0031 BD0000            jsr _read_IR
 0034                   .dbline 90
 0034 CC0023            ldd #35
 0037 BD0000            jsr _wait
 003A                   .dbline 92
 003A BD0057            jsr _detectsmoke
 003D                   .dbline 93
 003D BD0075            jsr _intitemp
 0040 2012              bra L24
 0042                 L23:
 0042                   .dbline 99
 0042 BD008B            jsr _checkbumper
 0045                   .dbline 101
 0045 BD0150            jsr _firecheck
 0048                   .dbline 103
 0048 BD0194            jsr _lookright
 004B                   .dbline 104
 004B BD01B9            jsr _lookleft
 004E                   .dbline 105
 004E BD028A            jsr _motorforward
 0051                   .dbline 106
 0051 BD02B1            jsr _heatcheck
 0054                   .dbline 107
 0054                 L24:
 0054                   .dbline 97
 0054 20EC              bra L23
 0056                 L19:
 0056 39                rts
                       ;  IX -> 0,x
 0057                 _detectsmoke::
 0057                   .dbfunc detectsmoke
 0057                   .dbline 114
 0057 BD0000            jsr _read_IR
 005A                   .dbline 115
 005A CC0023            ldd #35
 005D BD0000            jsr _wait
 0060 2009              bra L28
 0062                 L27:
 0062                   .dbline 119
 0062 BD0000            jsr _read_IR
 0065                   .dbline 121
 0065 CC0023            ldd #35
 0068 BD0000            jsr _wait
 006B                   .dbline 122
 006B                 L28:
 006B                   .dbline 117
 006B FC0010            ldd _IRDT+16
 006E 1A830028          cpd #40
 0072 25EE              blo L27
 0074                   .dbline 124
 0074                 L26:
 0074 39                rts
                       ;  IX -> 0,x
 0075                 _intitemp::
 0075                   .dbfunc intitemp
 0075                   .dbline 130
 0075 BD0000            jsr _read_IR
 0078                   .dbline 131
 0078 CC0023            ldd #35
 007B BD0000            jsr _wait
 007E                   .dbline 133
 007E FC0004            ldd _IRDT+4
 0081 FD0006            std _temp_one
 0084                   .dbline 134
 0084 FC0006            ldd _IRDT+6
 0087 FD0008            std _temp_two
 008A                   .dbline 136
 008A                 L31:
 008A 39                rts
                       ;  IX -> 0,x
 008B                 _checkbumper::
 008B                   .dbfunc checkbumper
 008B                   .dbline 141
 008B BD0000            jsr _rear_bumper
 008E 1A83000A          cpd #10
 0092 235A              bls L35
 0094                   .dbline 144
 0094 CC0032            ldd #50
 0097 FD0004            std _lspeed
 009A CC0032            ldd #50
 009D FD0002            std _rspeed
 00A0                   .dbline 145
 00A0 FC0002            ldd _rspeed
 00A3 37                pshb
 00A4 36                psha
 00A5 CC0001            ldd #1
 00A8 BD0000            jsr _motortk
 00AB 1838              puly
 00AD                   .dbline 146
 00AD FC0004            ldd _lspeed
 00B0 37                pshb
 00B1 36                psha
 00B2 CC0000            ldd #0
 00B5 BD0000            jsr _motortk
 00B8 1838              puly
 00BA                   .dbline 147
 00BA CC03E8            ldd #1000
 00BD BD0000            jsr _wait
 00C0                   .dbline 148
 00C0 CC0064            ldd #100
 00C3 FD0002            std _rspeed
 00C6                   .dbline 149
 00C6 CCFF9C            ldd #-100
 00C9 FD0004            std _lspeed
 00CC                   .dbline 150
 00CC FC0002            ldd _rspeed
 00CF 37                pshb
 00D0 36                psha
 00D1 CC0001            ldd #1
 00D4 BD0000            jsr _motortk
 00D7 1838              puly
 00D9                   .dbline 151
 00D9 FC0004            ldd _lspeed
 00DC 37                pshb
 00DD 36                psha
 00DE CC0000            ldd #0
 00E1 BD0000            jsr _motortk
 00E4 1838              puly
 00E6                   .dbline 152
 00E6 CC03E8            ldd #1000
 00E9 BD0000            jsr _wait
 00EC                   .dbline 153
 00EC 2061              bra L36
 00EE                 L35:
 00EE                   .dbline 154
 00EE BD0000            jsr _front_bumper
 00F1 1A83000A          cpd #10
 00F5 2358              bls L37
 00F7                   .dbline 157
                       ;         {
                       ;             
                       ;             rspeed = lspeed = -50;
 00F7 CCFFCE            ldd #-50
 00FA FD0004            std _lspeed
 00FD CCFFCE            ldd #-50
 0100 FD0002            std _rspeed
 0103                   .dbline 158
                       ;             motortk(RIGHT_MOTOR, rspeed);
 0103 FC0002            ldd _rspeed
 0106 37                pshb
 0107 36                psha
 0108 CC0001            ldd #1
 010B BD0000            jsr _motortk
 010E 1838              puly
 0110                   .dbline 159
                       ;             motortk(LEFT_MOTOR, lspeed);
 0110 FC0004            ldd _lspeed
 0113 37                pshb
 0114 36                psha
 0115 CC0000            ldd #0
 0118 BD0000            jsr _motortk
 011B 1838              puly
 011D                   .dbline 160
                       ;             wait(1000);
 011D CC03E8            ldd #1000
 0120 BD0000            jsr _wait
 0123                   .dbline 161
                       ;             rspeed = -100;
 0123 CCFF9C            ldd #-100
 0126 FD0002            std _rspeed
 0129                   .dbline 162
                       ;             lspeed = 100;
 0129 CC0064            ldd #100
 012C FD0004            std _lspeed
 012F                   .dbline 163
                       ;             motortk(RIGHT_MOTOR, rspeed);
 012F FC0002            ldd _rspeed
 0132 37                pshb
 0133 36                psha
 0134 CC0001            ldd #1
 0137 BD0000            jsr _motortk
 013A 1838              puly
 013C                   .dbline 164
                       ;             motortk(LEFT_MOTOR, lspeed);
 013C FC0004            ldd _lspeed
 013F 37                pshb
 0140 36                psha
 0141 CC0000            ldd #0
 0144 BD0000            jsr _motortk
 0147 1838              puly
 0149                   .dbline 165
                       ;             wait(1000);
 0149 CC03E8            ldd #1000
 014C BD0000            jsr _wait
 014F                   .dbline 167
                       ;             
                       ;         }
 014F                 L37:
 014F                 L36:
 014F                   .dbline 168
                       ; }
 014F                 L34:
 014F 39                rts
                       ;  IX -> 0,x
 0150                 _firecheck::
 0150                   .dbfunc firecheck
 0150                   .dbline 174
                       ; /* this funciton checks to see if there is a fire in front of the robot*/
                       ; 
                       ; 
                       ; void firecheck(void)
                       ; {
                       ;     read_IR();
 0150 BD0000            jsr _read_IR
 0153                   .dbline 175
                       ;     wait(35);
 0153 CC0023            ldd #35
 0156 BD0000            jsr _wait
 0159                   .dbline 177
                       ;     
                       ;     if ((IRDT[IR6clk] > FIRE) || (IRDT[IR7clk] > FIRE2))
 0159 FC000A            ldd _IRDT+10
 015C 1A83002D          cpd #45
 0160 2209              bhi L44
 0162 FC0012            ldd _IRDT+18
 0165 1A830028          cpd #40
 0169 2328              bls L40
 016B                 L44:
 016B                   .dbline 180
                       ;     {
                       ;         
                       ;         rspeed = -100;
 016B CCFF9C            ldd #-100
 016E FD0002            std _rspeed
 0171                   .dbline 181
                       ;         lspeed = 100;
 0171 CC0064            ldd #100
 0174 FD0004            std _lspeed
 0177                   .dbline 182
                       ;         motortk(RIGHT_MOTOR, rspeed);
 0177 FC0002            ldd _rspeed
 017A 37                pshb
 017B 36                psha
 017C CC0001            ldd #1
 017F BD0000            jsr _motortk
 0182 1838              puly
 0184                   .dbline 183
                       ;         motortk(LEFT_MOTOR, lspeed);
 0184 FC0004            ldd _lspeed
 0187 37                pshb
 0188 36                psha
 0189 CC0000            ldd #0
 018C BD0000            jsr _motortk
 018F 1838              puly
 0191                 L45:
 0191                   .dbline 184
                       ;         while (1);
 0191                 L46:
 0191 20FE              bra L45
 0193                 L40:
 0193                   .dbline 189
                       ;         /*firesignal();*/
                       ;          
                       ;          
                       ;     }
                       ; }
 0193                 L39:
 0193 39                rts
                       ;  IX -> 0,x
 0194                 _lookright::
 0194                   .dbfunc lookright
 0194                   .dbline 193
                       ; /*this functions looks to the right to see if there is an object*/
                       ; void lookright(void)
                       ; {
                       ;     read_IR();
 0194 BD0000            jsr _read_IR
 0197                   .dbline 194
                       ;     wait(35);
 0197 CC0023            ldd #35
 019A BD0000            jsr _wait
 019D                   .dbline 196
                       ;     
                       ;     if ((IRDT[IR4clk] > IRTHRESHOLD) || (IRDT[IR3clk] > IRTHRESHOLD))
 019D FC000E            ldd _IRDT+14
 01A0 1A83006E          cpd #110
 01A4 2209              bhi L53
 01A6 FC000C            ldd _IRDT+12
 01A9 1A83006E          cpd #110
 01AD 2309              bls L49
 01AF                 L53:
 01AF                   .dbline 199
                       ;      
                       ;             {
                       ;                 left = 1;
 01AF CC0001            ldd #1
 01B2 FD000A            std _left
 01B5                   .dbline 200
                       ;                 lefturn();
 01B5 BD0234            jsr _lefturn
 01B8                   .dbline 202
                       ;                     
                       ;             }   
 01B8                 L49:
 01B8                   .dbline 203
                       ; }
 01B8                 L48:
 01B8 39                rts
                       ;  IX -> 0,x
 01B9                 _lookleft::
 01B9                   .dbfunc lookleft
 01B9                   .dbline 207
                       ; void lookleft(void)
                       ; {
                       ; 
                       ;     read_IR();
 01B9 BD0000            jsr _read_IR
 01BC                   .dbline 208
                       ;     wait(35);
 01BC CC0023            ldd #35
 01BF BD0000            jsr _wait
 01C2                   .dbline 211
                       ;     
                       ;     
                       ;      if ((IRDT[IR1clk] > IRTHRESHOLD) || (IRDT[IR2clk] > IRTHRESHOLD))
 01C2 FC0008            ldd _IRDT+8
 01C5 1A83006E          cpd #110
 01C9 2209              bhi L58
 01CB FC0000            ldd _IRDT
 01CE 1A83006E          cpd #110
 01D2 2309              bls L55
 01D4                 L58:
 01D4                   .dbline 213
                       ;             {
                       ;                 right = 1;
 01D4 CC0001            ldd #1
 01D7 FD000C            std _right
 01DA                   .dbline 214
                       ;                 righturn();             
 01DA BD01DE            jsr _righturn
 01DD                   .dbline 215
                       ;             } 
 01DD                 L55:
 01DD                   .dbline 217
                       ;             
                       ; }
 01DD                 L54:
 01DD 39                rts
                       ;  IX -> 0,x
 01DE                 _righturn::
 01DE                   .dbfunc righturn
 01DE                   .dbline 220
                       ; void righturn(void)
                       ; {
                       ;     if (right == 1)
 01DE FC000C            ldd _right
 01E1 1A830001          cpd #1
 01E5 264C              bne L60
 01E7                   .dbline 222
                       ;     {
                       ;         rspeed = -100;
 01E7 CCFF9C            ldd #-100
 01EA FD0002            std _rspeed
 01ED                   .dbline 223
                       ;         lspeed = 100;
 01ED CC0064            ldd #100
 01F0 FD0004            std _lspeed
 01F3                   .dbline 224
                       ;         motortk(RIGHT_MOTOR, rspeed);
 01F3 FC0002            ldd _rspeed
 01F6 37                pshb
 01F7 36                psha
 01F8 CC0001            ldd #1
 01FB BD0000            jsr _motortk
 01FE 1838              puly
 0200                   .dbline 225
                       ;         motortk(LEFT_MOTOR, lspeed);
 0200 FC0004            ldd _lspeed
 0203 37                pshb
 0204 36                psha
 0205 CC0000            ldd #0
 0208 BD0000            jsr _motortk
 020B 1838              puly
 020D 200C              bra L63
 020F                 L62:
 020F                   .dbline 228
 020F BD0000            jsr _read_IR
 0212                   .dbline 229
 0212 CC0023            ldd #35
 0215 BD0000            jsr _wait
 0218                   .dbline 231
 0218 BD0150            jsr _firecheck
 021B                   .dbline 233
 021B                 L63:
 021B                   .dbline 226
                       ;         while ((IRDT[IR1clk] > IRTHRESHOLD) || (IRDT[IR2clk] > IRTHRESHOLD))
 021B FC0008            ldd _IRDT+8
 021E 1A83006E          cpd #110
 0222 22EB              bhi L62
 0224 FC0000            ldd _IRDT
 0227 1A83006E          cpd #110
 022B 22E2              bhi L62
 022D                   .dbline 234
                       ;         {
                       ;             read_IR();
                       ;             wait(35);
                       ;             
                       ;             firecheck();
                       ;             
                       ;         }
                       ;     wait(150);  
 022D CC0096            ldd #150
 0230 BD0000            jsr _wait
 0233                   .dbline 236
                       ;      
                       ;     }
 0233                 L60:
 0233                   .dbline 237
                       ; }
 0233                 L59:
 0233 39                rts
                       ;  IX -> 0,x
 0234                 _lefturn::
 0234                   .dbfunc lefturn
 0234                   .dbline 240
                       ; void lefturn(void)
                       ; {
                       ;     if (left == 1)
 0234 FC000A            ldd _left
 0237 1A830001          cpd #1
 023B 264C              bne L67
 023D                   .dbline 242
                       ;     {
                       ;         rspeed = 100;
 023D CC0064            ldd #100
 0240 FD0002            std _rspeed
 0243                   .dbline 243
                       ;         lspeed = -100;
 0243 CCFF9C            ldd #-100
 0246 FD0004            std _lspeed
 0249                   .dbline 244
                       ;         motortk(RIGHT_MOTOR, rspeed);
 0249 FC0002            ldd _rspeed
 024C 37                pshb
 024D 36                psha
 024E CC0001            ldd #1
 0251 BD0000            jsr _motortk
 0254 1838              puly
 0256                   .dbline 245
                       ;         motortk(LEFT_MOTOR, lspeed);
 0256 FC0004            ldd _lspeed
 0259 37                pshb
 025A 36                psha
 025B CC0000            ldd #0
 025E BD0000            jsr _motortk
 0261 1838              puly
 0263 200C              bra L70
 0265                 L69:
 0265                   .dbline 248
 0265 BD0000            jsr _read_IR
 0268                   .dbline 249
 0268 CC0023            ldd #35
 026B BD0000            jsr _wait
 026E                   .dbline 250
 026E BD0150            jsr _firecheck
 0271                   .dbline 253
 0271                 L70:
 0271                   .dbline 246
                       ;         while ((IRDT[IR3clk] > IRTHRESHOLD) || (IRDT[IR4clk] > IRTHRESHOLD))
 0271 FC000C            ldd _IRDT+12
 0274 1A83006E          cpd #110
 0278 22EB              bhi L69
 027A FC000E            ldd _IRDT+14
 027D 1A83006E          cpd #110
 0281 22E2              bhi L69
 0283                   .dbline 254
                       ;         {
                       ;             read_IR();
                       ;             wait(35);
                       ;             firecheck();
                       ;             
                       ;         
                       ;         }
                       ;     wait(150);  
 0283 CC0096            ldd #150
 0286 BD0000            jsr _wait
 0289                   .dbline 255
                       ;     }
 0289                 L67:
 0289                   .dbline 256
                       ; } 
 0289                 L66:
 0289 39                rts
                       ;  IX -> 0,x
 028A                 _motorforward::
 028A                   .dbfunc motorforward
 028A                   .dbline 259
                       ; void motorforward(void)
                       ; {
                       ;     rspeed = 100;
 028A CC0064            ldd #100
 028D FD0002            std _rspeed
 0290                   .dbline 260
                       ;     lspeed = 50;
 0290 CC0032            ldd #50
 0293 FD0004            std _lspeed
 0296                   .dbline 261
                       ;     motortk(RIGHT_MOTOR, rspeed);
 0296 FC0002            ldd _rspeed
 0299 37                pshb
 029A 36                psha
 029B CC0001            ldd #1
 029E BD0000            jsr _motortk
 02A1 1838              puly
 02A3                   .dbline 262
                       ;     motortk(LEFT_MOTOR, lspeed);
 02A3 FC0004            ldd _lspeed
 02A6 37                pshb
 02A7 36                psha
 02A8 CC0000            ldd #0
 02AB BD0000            jsr _motortk
 02AE 1838              puly
 02B0                   .dbline 263
                       ; }
 02B0                 L74:
 02B0 39                rts
                       ;  IX -> 0,x
 02B1                 _heatcheck::
 02B1                   .dbfunc heatcheck
 02B1                   .dbline 266
                       ; void heatcheck(void)
                       ; {
                       ;     read_IR();
 02B1 BD0000            jsr _read_IR
 02B4                   .dbline 267
                       ;     wait(35);
 02B4 CC0023            ldd #35
 02B7 BD0000            jsr _wait
 02BA 2038              bra L77
 02BC                 L76:
 02BC                   .dbline 271
 02BC BD0000            jsr _read_IR
 02BF                   .dbline 272
 02BF CC0023            ldd #35
 02C2 BD0000            jsr _wait
 02C5                   .dbline 273
 02C5 BD0194            jsr _lookright
 02C8                   .dbline 274
 02C8 BD01B9            jsr _lookleft
 02CB                   .dbline 275
 02CB CCFFC4            ldd #-60
 02CE FD0002            std _rspeed
 02D1                   .dbline 276
 02D1 CC001E            ldd #30
 02D4 FD0004            std _lspeed
 02D7                   .dbline 277
 02D7 FC0002            ldd _rspeed
 02DA 37                pshb
 02DB 36                psha
 02DC CC0001            ldd #1
 02DF BD0000            jsr _motortk
 02E2 1838              puly
 02E4                   .dbline 278
 02E4 FC0004            ldd _lspeed
 02E7 37                pshb
 02E8 36                psha
 02E9 CC0000            ldd #0
 02EC BD0000            jsr _motortk
 02EF 1838              puly
 02F1                   .dbline 280
 02F1 BD0307            jsr _heatsource
 02F4                   .dbline 282
 02F4                 L77:
 02F4                   .dbline 269
                       ;     
                       ;     while ((IRDT[2] > HEAT) || (IRDT[3] > HEAT))
 02F4 FC0004            ldd _IRDT+4
 02F7 1A83002D          cpd #45
 02FB 22BF              bhi L76
 02FD FC0006            ldd _IRDT+6
 0300 1A83002D          cpd #45
 0304 22B6              bhi L76
 0306                   .dbline 283
                       ;     {
                       ;         read_IR();
                       ;         wait(35);
                       ;         lookright();
                       ;         lookleft();
                       ;         rspeed = -60;
                       ;         lspeed = 30;
                       ;         motortk(RIGHT_MOTOR, rspeed);
                       ;         motortk(LEFT_MOTOR, lspeed);
                       ;                     
                       ;         heatsource();
                       ;         
                       ;     }
                       ; }
 0306                 L75:
 0306 39                rts
                       ;  IX -> 0,x
                       ;  rMEM -> 2,x
                       ;         search -> 4,x
 0307                 _heatsource::
 0307 BD0000            jsr __enterb
 030A 06                .byte 0x6
 030B                   .dbfunc heatsource
 030B                   .dbline 286
                       ; void heatsource(void)
                       ; {
                       ;     int search = 0;
 030B CC0000            ldd #0
 030E ED04              std 4,x
 0310                   .dbline 288
                       ;     
                       ;     read_IR();
 0310 BD0000            jsr _read_IR
 0313                   .dbline 289
                       ;     wait(35);
 0313 CC0023            ldd #35
 0316 BD0000            jsr _wait
 0319                   .dbline 291
                       ;     
                       ;     temp_one = IRDT[2];
 0319 FC0004            ldd _IRDT+4
 031C FD0006            std _temp_one
 031F                   .dbline 292
                       ;     temp_two = IRDT[3];
 031F FC0006            ldd _IRDT+6
 0322 FD0008            std _temp_two
 0325                   .dbline 294
                       ;         
                       ;     rspeed = 60;
 0325 CC003C            ldd #60
 0328 FD0002            std _rspeed
 032B                   .dbline 295
                       ;     lspeed = 30;  
 032B CC001E            ldd #30
 032E FD0004            std _lspeed
 0331                   .dbline 296
                       ;     motortk(RIGHT_MOTOR, rspeed);
 0331 FC0002            ldd _rspeed
 0334 37                pshb
 0335 36                psha
 0336 CC0001            ldd #1
 0339 BD0000            jsr _motortk
 033C 1838              puly
 033E                   .dbline 297
                       ;     motortk(LEFT_MOTOR, lspeed);
 033E FC0004            ldd _lspeed
 0341 37                pshb
 0342 36                psha
 0343 CC0000            ldd #0
 0346 BD0000            jsr _motortk
 0349 1838              puly
 034B 7E03E0            jmp L85
 034E                 L84:
 034E                   .dbline 301
                       ;     
                       ;     while (search == 0)
                       ;     {
                       ;         read_IR();
 034E BD0000            jsr _read_IR
 0351                   .dbline 302
                       ;         wait(35);
 0351 CC0023            ldd #35
 0354 BD0000            jsr _wait
 0357                   .dbline 305
                       ;         
                       ;         
                       ;         if ((IRDT[2] > (temp_one - 2)) || (IRDT[3] > (temp_two - 2)))
 0357 FC0006            ldd _temp_one
 035A 830002            subd #2
 035D ED02              std 2,x
 035F FC0004            ldd _IRDT+4
 0362 1AA302            cpd 2,x
 0365 2210              bhi L91
 0367 FC0008            ldd _temp_two
 036A 830002            subd #2
 036D ED02              std 2,x
 036F FC0006            ldd _IRDT+6
 0372 1AA302            cpd 2,x
 0375 230F              bls L87
 0377                 L91:
 0377                   .dbline 307
                       ;         {
                       ;             temp_one = IRDT[2];
 0377 FC0004            ldd _IRDT+4
 037A FD0006            std _temp_one
 037D                   .dbline 308
                       ;             temp_two = IRDT[3];
 037D FC0006            ldd _IRDT+6
 0380 FD0008            std _temp_two
 0383                   .dbline 309
                       ;             firecheck();
 0383 BD0150            jsr _firecheck
 0386                   .dbline 310
                       ;         }
 0386                 L87:
 0386                   .dbline 311
                       ;         if ((IRDT[2] < (temp_one + 2)) || (IRDT[3] < (temp_two + 2)))
 0386 FC0006            ldd _temp_one
 0389 C30002            addd #2
 038C ED02              std 2,x
 038E FC0004            ldd _IRDT+4
 0391 1AA302            cpd 2,x
 0394 2510              blo L98
 0396 FC0008            ldd _temp_two
 0399 C30002            addd #2
 039C ED02              std 2,x
 039E FC0006            ldd _IRDT+6
 03A1 1AA302            cpd 2,x
 03A4 243A              bhs L94
 03A6                 L98:
 03A6                   .dbline 313
                       ;         {
                       ;             search = 1;
 03A6 CC0001            ldd #1
 03A9 ED04              std 4,x
 03AB                   .dbline 314
                       ;             temp_one = IRDT[2];
 03AB FC0004            ldd _IRDT+4
 03AE FD0006            std _temp_one
 03B1                   .dbline 315
                       ;             temp_two = IRDT[3];
 03B1 FC0006            ldd _IRDT+6
 03B4 FD0008            std _temp_two
 03B7                   .dbline 316
                       ;             rspeed = lspeed = 0;
 03B7 CC0000            ldd #0
 03BA FD0004            std _lspeed
 03BD CC0000            ldd #0
 03C0 FD0002            std _rspeed
 03C3                   .dbline 317
                       ;             motortk(RIGHT_MOTOR, rspeed);
 03C3 FC0002            ldd _rspeed
 03C6 37                pshb
 03C7 36                psha
 03C8 CC0001            ldd #1
 03CB BD0000            jsr _motortk
 03CE 1838              puly
 03D0                   .dbline 318
                       ;             motortk(LEFT_MOTOR, lspeed);
 03D0 FC0004            ldd _lspeed
 03D3 37                pshb
 03D4 36                psha
 03D5 CC0000            ldd #0
 03D8 BD0000            jsr _motortk
 03DB 1838              puly
 03DD                   .dbline 319
                       ;             firecheck();
 03DD BD0150            jsr _firecheck
 03E0                   .dbline 320
                       ;         }
 03E0                 L94:
 03E0                   .dbline 321
 03E0                 L85:
 03E0                   .dbline 299
 03E0 EC04              ldd 4,x
 03E2 2603              bne X0
 03E4 7E034E            jmp L84
 03E7                 X0:
 03E7                   .dbline 337
                       ;     }
                       ;     
                       ;     /*while (search == 1)
                       ;     {
                       ;         read_IR();
                       ;         wait(35);
                       ;         
                       ;         rspeed = 40;
                       ;         lspeed = -40;
                       ;         motortk(RIGHT_MOTOR, rspeed);
                       ;         motortk(LEFT_MOTOR, lspeed);
                       ;         while ((IRDT[2] < (temp_one + 2)) || (IRDT[3] < (temp_two + 2)));
                       ;         search = 2;
                       ;         firecheck();
                       ;     }
                       ;     heatforward();*/
                       ; }   
 03E7                 L81:
 03E7 8F                xgdx
 03E8 C30006            addd #6
 03EB 8F                xgdx
 03EC 35                txs
 03ED 38                pulx
 03EE 39                rts
                       ;  IX -> 0,x
 03EF                 _heatforward::
 03EF                   .dbfunc heatforward
 03EF                   .dbline 340
                       ; void heatforward(void)
                       ; { 
                       ;     rspeed = lspeed = 50;
 03EF CC0032            ldd #50
 03F2 FD0004            std _lspeed
 03F5 CC0032            ldd #50
 03F8 FD0002            std _rspeed
 03FB                   .dbline 341
                       ;     motortk(RIGHT_MOTOR, rspeed);
 03FB FC0002            ldd _rspeed
 03FE 37                pshb
 03FF 36                psha
 0400 CC0001            ldd #1
 0403 BD0000            jsr _motortk
 0406 1838              puly
 0408                   .dbline 342
                       ;     motortk(LEFT_MOTOR, lspeed);
 0408 FC0004            ldd _lspeed
 040B 37                pshb
 040C 36                psha
 040D CC0000            ldd #0
 0410 BD0000            jsr _motortk
 0413 1838              puly
 0415 2009              bra L103
 0417                 L102:
 0417                   .dbline 345
 0417 BD0150            jsr _firecheck
 041A                   .dbline 346
 041A BD0194            jsr _lookright
 041D                   .dbline 347
 041D BD01B9            jsr _lookleft
 0420                   .dbline 348
 0420                 L103:
 0420                   .dbline 343
                       ;     while ((IRDT[2] > HEAT) || (IRDT[3] > HEAT))
 0420 FC0004            ldd _IRDT+4
 0423 1A83002D          cpd #45
 0427 22EE              bhi L102
 0429 FC0006            ldd _IRDT+6
 042C 1A83002D          cpd #45
 0430 22E5              bhi L102
 0432                   .dbline 349
                       ;     {
                       ;         firecheck();
                       ;         lookright();
                       ;         lookleft();
                       ;     }
                       ;     heatsource();
 0432 BD0307            jsr _heatsource
 0435                   .dbline 350
                       ; }
 0435                 L101:
 0435 39                rts
                       ;  IX -> 0,x
 0436                 _firesignal::
 0436                   .dbfunc firesignal
 0436                   .dbline 353
                       ; void firesignal(void)
                       ; {
                       ;     rspeed = -100;
 0436 CCFF9C            ldd #-100
 0439 FD0002            std _rspeed
 043C                   .dbline 354
                       ;     lspeed = 100;
 043C CC0064            ldd #100
 043F FD0004            std _lspeed
 0442                   .dbline 355
                       ;     motortk(RIGHT_MOTOR, rspeed);
 0442 FC0002            ldd _rspeed
 0445 37                pshb
 0446 36                psha
 0447 CC0001            ldd #1
 044A BD0000            jsr _motortk
 044D 1838              puly
 044F                   .dbline 356
                       ;     motortk(LEFT_MOTOR, lspeed);
 044F FC0004            ldd _lspeed
 0452 37                pshb
 0453 36                psha
 0454 CC0000            ldd #0
 0457 BD0000            jsr _motortk
 045A 1838              puly
 045C                   .dbline 357
                       ;     wait(1500);
 045C CC05DC            ldd #1500
 045F BD0000            jsr _wait
 0462                   .dbline 358
                       ;     rspeed = 100;
 0462 CC0064            ldd #100
 0465 FD0002            std _rspeed
 0468                   .dbline 359
                       ;     lspeed = -100;
 0468 CCFF9C            ldd #-100
 046B FD0004            std _lspeed
 046E                   .dbline 360
                       ;     motortk(RIGHT_MOTOR, rspeed);
 046E FC0002            ldd _rspeed
 0471 37                pshb
 0472 36                psha
 0473 CC0001            ldd #1
 0476 BD0000            jsr _motortk
 0479 1838              puly
 047B                   .dbline 361
                       ;     motortk(LEFT_MOTOR, lspeed);
 047B FC0004            ldd _lspeed
 047E 37                pshb
 047F 36                psha
 0480 CC0000            ldd #0
 0483 BD0000            jsr _motortk
 0486 1838              puly
 0488                   .dbline 362
                       ;     wait(1500);
 0488 CC05DC            ldd #1500
 048B BD0000            jsr _wait
 048E                 L108:
 048E                   .dbline 363
                       ;     while(1);
 048E                 L109:
 048E 20FE              bra L108
 0490                 L107:
 0490 39                rts
