                         .module dendenis.c
 0000                   .dbfile dendenis.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 50
                       ;  
 0001                 L3:
 0001 3B                rti
                       ;  IX -> 0,x
 0002                 _PAIE_isr::
 0002                   .dbfunc PAIE_isr
 0002                   .dbline 52
                       ; /************************ End of Constants ******************************/
                       ; int rspeed = 0;
                       ; int lspeed = 0;
                       ; 
                       ; void detectsmoke(void);
                       ; void avoidobject(void);
 0002                 L4:
 0002 3B                rti
                       ;  IX -> 0,x
 0003                 _PAV_isr::
 0003                   .dbfunc PAV_isr
 0003                   .dbline 58
                       ; void righturn(void);
                       ; void lefturn(void);
                       ; void checkbump(void);
                       ; void firecheck(void);
                       ; 
                       ; void main(void)
 0003                 L5:
 0003 3B                rti
                       ;  IX -> 0,x
 0004                 _TOF_isr::
 0004                   .dbfunc TOF_isr
 0004                   .dbline 64
                       ; /****************************** Main ***********************************/
                       ; {
                       ;   unsigned int bl, cv, fb, rb;
                       ;   char clear[]= "\x1b\x5B\x32\x4A\x04";  /* clear screen */ 
                       ;   char place[]= "\x1b[1;1H";        /* Home cursor */
                       ; 
 0004                 L6:
 0004 3B                rti
                       ;  IX -> 0,x
 0005                 _TOC4_isr::
 0005                   .dbfunc TOC4_isr
 0005                   .dbline 76
                       ; 
                       ;   init_analog();
                       ;   init_motortk();
                       ;   init_clocktk();
                       ;   init_serial();
                       ; 
                       ;   IRE_OUT = IRE_ALL_ON;    /* Turns on all the 40KHz modulated IR emitters */
                       ; 
                       ;   /*printf("%s", clear);  
                       ;   printf("%s", place);  
                       ;   printf("Hit my ass to start me\n\n");*/
                       ;   
 0005                 L7:
 0005 3B                rti
                       ;  IX -> 0,x
 0006                 _TOC1_isr::
 0006                   .dbfunc TOC1_isr
 0006                   .dbline 94
                       ;   while (rear_bumper() < BUMPER_FUZZY);
                       ;   
                       ;   read_IR();
                       ;   
                       ;     
                       ;   /*printf("starting to look for smoke\n\n");*/
                       ;     
                       ;   
                       ;   
                       ;   detectsmoke();
                       ;   
                       ;   rspeed = lspeed = 100;
                       ;   motortk(RIGHT_MOTOR, rspeed);
                       ;   motortk(LEFT_MOTOR, lspeed);
                       ;   
                       ;   /*printf("Will start to look for the fire\n\n");*/
                       ;     
                       ;     wait(500);
 0006                 L8:
 0006 3B                rti
                       ;  IX -> 0,x
 0007                 _TIC3_isr::
 0007                   .dbfunc TIC3_isr
 0007                   .dbline 100
                       ; 
                       ;   /*printf("Starting to avoid objects\n");*/
                       ;   
                       ;   avoidobject();
                       ;   
                       ; 
 0007                 L9:
 0007 3B                rti
                       ;  IX -> 0,x
 0008                 _TIC2_isr::
 0008                   .dbfunc TIC2_isr
 0008                   .dbline 106
                       ; }
                       ; 
                       ; /**************************** End of Main ******************************/
                       ; 
                       ; void detectsmoke(void)
                       ; {
 0008                 L10:
 0008 3B                rti
                       ;  IX -> 0,x
 0009                 _TIC1_isr::
 0009                   .dbfunc TIC1_isr
 0009                   .dbline 112
                       ;     read_IR();
                       ;     
                       ;     while (IRDT[IR5clk] < NOSMOKE)
                       ;         {
                       ;             read_IR();
                       ;             wait(10);
 0009                 L11:
 0009 3B                rti
                       ;  IX -> 0,x
 000A                 _RTI_isr::
 000A                   .dbfunc RTI_isr
 000A                   .dbline 118
                       ;         }
                       ;     /*printf("I have found smoke\n");*/
                       ; }
                       ; 
                       ; void avoidobject(void)
                       ; {
 000A                 L12:
 000A 3B                rti
                       ;  IX -> 0,x
 000B                 _IRQ_isr::
 000B                   .dbfunc IRQ_isr
 000B                   .dbline 124
                       ;     /*printf("Starting motors at full speed\n");*/
                       ;     
                       ;     
                       ;      
                       ;      while (1)
                       ;      {
 000B                 L13:
 000B 3B                rti
                       ;  IX -> 0,x
 000C                 _XIRQ_isr::
 000C                   .dbfunc XIRQ_isr
 000C                   .dbline 130
                       ;         checkbump();
                       ;         
                       ;                 
                       ;         read_IR();
                       ;         firecheck();
                       ;         
 000C                 L14:
 000C 3B                rti
                       ;  IX -> 0,x
 000D                 _SWI_isr::
 000D                   .dbfunc SWI_isr
 000D                   .dbline 136
                       ;         rspeed = lspeed = 100;
                       ;         motortk(RIGHT_MOTOR, rspeed);
                       ;         motortk(LEFT_MOTOR, lspeed);
                       ;         
                       ;         if ((IRDT[IR1clk] > IRTHRESHOLD) || (IRDT[IR2clk] > IRTHRESHOLD))
                       ;             {
 000D                 L15:
 000D 3B                rti
                       ;  IX -> 0,x
 000E                 _ILLOP_isr::
 000E                   .dbfunc ILLOP_isr
 000E                   .dbline 142
                       ;                 /*printf("Object to my right, so\n");
                       ;                 printf("I will avoid it\n\n");*/
                       ;                 righturn();             
                       ;             }
                       ;         
                       ;          else if ((IRDT[IR4clk] > IRTHRESHOLD) || (IRDT[IR3clk] > IRTHRESHOLD))
 000E                 L16:
 000E 3B                rti
                       ;  IX -> 0,x
 000F                 _COP_isr::
 000F                   .dbfunc COP_isr
 000F                   .dbline 148
                       ;      
                       ;             {
                       ;                 /*printf("Object to my left, so\n");
                       ;                 printf("I will avoid it\n\n");*/
                       ;                 lefturn();  
                       ;             }
 000F                 L17:
 000F 3B                rti
                       ;  IX -> 0,x
 0010                 _CLMON_isr::
 0010                   .dbfunc CLMON_isr
 0010                   .dbline 154
                       ;      }
                       ; }
                       ; 
                       ; void righturn(void)
                       ; {
                       ;     /*printf("Turning right.\n");*/
 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 text
 0011                 L20:
 0011 1B5B324A0400      .byte 27,91,50,'J,4,0
 0017                 L21:
 0017 1B5B313B314800    .byte 27,91,49,59,49,'H,0
                       ;  IX -> 0,x
                       ;             rb -> 3,x
                       ;             fb -> 5,x
                       ;             cv -> 7,x
                       ;             bl -> 9,x
                       ;          place -> 11,x
                       ;          clear -> 18,x
 001E                 _main::
 001E BD0000            jsr __enterb
 0021 18                .byte 0x18
 0022                   .dbfile dendenis.c
 0022                   .dbfunc main
 0022                   .dbline 62
 0022 EC00              ldd 0,x
 0024 C30012            addd #18
 0027 18CE0011          ldy #L20
 002B 3C                pshx
 002C 8F                xgdx
 002D CC0006            ldd #6
 0030 BD0000            jsr __asgnblk
 0033 38                pulx
 0034                   .dbline 63
 0034 EC00              ldd 0,x
 0036 C3000B            addd #11
 0039 18CE0017          ldy #L21
 003D 3C                pshx
 003E 8F                xgdx
 003F CC0007            ldd #7
 0042 BD0000            jsr __asgnblk
 0045 38                pulx
 0046                   .dbline 66
 0046 BD0000            jsr _init_analog
 0049                   .dbline 67
 0049 BD0000            jsr _init_motortk
 004C                   .dbline 68
 004C BD0000            jsr _init_clocktk
 004F                   .dbline 69
 004F BD0000            jsr _init_serial
 0052                   .dbline 71
 0052 C6FF              ldab #255
 0054 F7FFB9            stab 0xffb9
 0057                 L22:
 0057                   .dbline 77
 0057                 L23:
 0057 BD0000            jsr _rear_bumper
 005A 1A83000A          cpd #10
 005E 25F7              blo L22
 0060                   .dbline 79
 0060 BD0000            jsr _read_IR
 0063                   .dbline 86
 0063 BD009D            jsr _detectsmoke
 0066                   .dbline 88
 0066 CC0064            ldd #100
 0069 FD0004            std _lspeed
 006C CC0064            ldd #100
 006F FD0002            std _rspeed
 0072                   .dbline 89
 0072 FC0002            ldd _rspeed
 0075 37                pshb
 0076 36                psha
 0077 CC0001            ldd #1
 007A BD0000            jsr _motortk
 007D 1838              puly
 007F                   .dbline 90
 007F FC0004            ldd _lspeed
 0082 37                pshb
 0083 36                psha
 0084 CC0000            ldd #0
 0087 BD0000            jsr _motortk
 008A 1838              puly
 008C                   .dbline 94
 008C CC01F4            ldd #500
 008F BD0000            jsr _wait
 0092                   .dbline 98
 0092 BD00B5            jsr _avoidobject
 0095                   .dbline 101
 0095                 L19:
 0095 8F                xgdx
 0096 C30018            addd #24
 0099 8F                xgdx
 009A 35                txs
 009B 38                pulx
 009C 39                rts
                       ;  IX -> 0,x
 009D                 _detectsmoke::
 009D                   .dbfunc detectsmoke
 009D                   .dbline 107
 009D BD0000            jsr _read_IR
 00A0 2009              bra L27
 00A2                 L26:
 00A2                   .dbline 111
 00A2 BD0000            jsr _read_IR
 00A5                   .dbline 112
 00A5 CC000A            ldd #10
 00A8 BD0000            jsr _wait
 00AB                   .dbline 113
 00AB                 L27:
 00AB                   .dbline 109
 00AB FC0010            ldd _IRDT+16
 00AE 1A830028          cpd #40
 00B2 25EE              blo L26
 00B4                   .dbline 115
 00B4                 L25:
 00B4 39                rts
                       ;  IX -> 0,x
 00B5                 _avoidobject::
 00B5                   .dbfunc avoidobject
 00B5                   .dbline 118
 00B5 205B              bra L32
 00B7                 L31:
 00B7                   .dbline 125
 00B7 BD01A3            jsr _checkbump
 00BA                   .dbline 128
 00BA BD0000            jsr _read_IR
 00BD                   .dbline 129
 00BD BD0216            jsr _firecheck
 00C0                   .dbline 131
 00C0 CC0064            ldd #100
 00C3 FD0004            std _lspeed
 00C6 CC0064            ldd #100
 00C9 FD0002            std _rspeed
 00CC                   .dbline 132
 00CC FC0002            ldd _rspeed
 00CF 37                pshb
 00D0 36                psha
 00D1 CC0001            ldd #1
 00D4 BD0000            jsr _motortk
 00D7 1838              puly
 00D9                   .dbline 133
 00D9 FC0004            ldd _lspeed
 00DC 37                pshb
 00DD 36                psha
 00DE CC0000            ldd #0
 00E1 BD0000            jsr _motortk
 00E4 1838              puly
 00E6                   .dbline 135
 00E6 FC0008            ldd _IRDT+8
 00E9 1A83006E          cpd #110
 00ED 2209              bhi L37
 00EF FC0000            ldd _IRDT
 00F2 1A83006E          cpd #110
 00F6 2305              bls L34
 00F8                 L37:
 00F8                   .dbline 139
 00F8 BD0115            jsr _righturn
 00FB                   .dbline 140
 00FB 2015              bra L35
 00FD                 L34:
 00FD                   .dbline 142
 00FD FC000E            ldd _IRDT+14
 0100 1A83006E          cpd #110
 0104 2209              bhi L42
 0106 FC000C            ldd _IRDT+12
 0109 1A83006E          cpd #110
 010D 2303              bls L38
 010F                 L42:
 010F                   .dbline 147
 010F BD015C            jsr _lefturn
 0112                   .dbline 148
 0112                 L38:
 0112                 L35:
 0112                   .dbline 149
 0112                 L32:
 0112                   .dbline 123
 0112 20A3              bra L31
 0114                 L30:
 0114 39                rts
                       ;  IX -> 0,x
 0115                 _righturn::
 0115                   .dbfunc righturn
 0115                   .dbline 155
                       ;     rspeed = -100;
 0115 CCFF9C            ldd #-100
 0118 FD0002            std _rspeed
 011B                   .dbline 156
                       ;     lspeed = 100;
 011B CC0064            ldd #100
 011E FD0004            std _lspeed
 0121                   .dbline 157
                       ;     motortk(RIGHT_MOTOR, rspeed);
 0121 FC0002            ldd _rspeed
 0124 37                pshb
 0125 36                psha
 0126 CC0001            ldd #1
 0129 BD0000            jsr _motortk
 012C 1838              puly
 012E                   .dbline 158
                       ;     motortk(LEFT_MOTOR, lspeed);
 012E FC0004            ldd _lspeed
 0131 37                pshb
 0132 36                psha
 0133 CC0000            ldd #0
 0136 BD0000            jsr _motortk
 0139 1838              puly
 013B 2006              bra L45
 013D                 L44:
 013D                   .dbline 161
 013D BD0000            jsr _read_IR
 0140                   .dbline 162
 0140 BD0216            jsr _firecheck
 0143                   .dbline 163
 0143                 L45:
 0143                   .dbline 159
                       ;     while ((IRDT[IR1clk] > IRTHRESHOLD) || (IRDT[IR2clk] > IRTHRESHOLD))
 0143 FC0008            ldd _IRDT+8
 0146 1A83006E          cpd #110
 014A 22F1              bhi L44
 014C FC0000            ldd _IRDT
 014F 1A83006E          cpd #110
 0153 22E8              bhi L44
 0155                   .dbline 164
                       ;     {
                       ;         read_IR();
                       ;         firecheck();
                       ;     }
                       ;     wait(300);
 0155 CC012C            ldd #300
 0158 BD0000            jsr _wait
 015B                   .dbline 165
                       ; }
 015B                 L43:
 015B 39                rts
                       ;  IX -> 0,x
 015C                 _lefturn::
 015C                   .dbfunc lefturn
 015C                   .dbline 170
                       ; 
                       ; void lefturn(void)
                       ; {
                       ;     /*printf("Turning left.\n");*/
                       ;     rspeed = 100;
 015C CC0064            ldd #100
 015F FD0002            std _rspeed
 0162                   .dbline 171
                       ;     lspeed = -100;
 0162 CCFF9C            ldd #-100
 0165 FD0004            std _lspeed
 0168                   .dbline 172
                       ;     motortk(RIGHT_MOTOR, rspeed);
 0168 FC0002            ldd _rspeed
 016B 37                pshb
 016C 36                psha
 016D CC0001            ldd #1
 0170 BD0000            jsr _motortk
 0173 1838              puly
 0175                   .dbline 173
                       ;     motortk(LEFT_MOTOR, lspeed);
 0175 FC0004            ldd _lspeed
 0178 37                pshb
 0179 36                psha
 017A CC0000            ldd #0
 017D BD0000            jsr _motortk
 0180 1838              puly
 0182 2006              bra L50
 0184                 L49:
 0184                   .dbline 176
 0184 BD0000            jsr _read_IR
 0187                   .dbline 177
 0187 BD0216            jsr _firecheck
 018A                   .dbline 179
 018A                 L50:
 018A                   .dbline 174
                       ;     while ((IRDT[IR3clk] > IRTHRESHOLD) || (IRDT[IR4clk] > IRTHRESHOLD))
 018A FC000C            ldd _IRDT+12
 018D 1A83006E          cpd #110
 0191 22F1              bhi L49
 0193 FC000E            ldd _IRDT+14
 0196 1A83006E          cpd #110
 019A 22E8              bhi L49
 019C                   .dbline 180
                       ;     {
                       ;         read_IR();
                       ;         firecheck();
                       ;         
                       ;     }
                       ;     wait(300);
 019C CC012C            ldd #300
 019F BD0000            jsr _wait
 01A2                   .dbline 182
                       ;     
                       ; }
 01A2                 L48:
 01A2 39                rts
                       ;  IX -> 0,x
 01A3                 _checkbump::
 01A3                   .dbfunc checkbump
 01A3                   .dbline 186
                       ; 
                       ; void checkbump(void)
                       ; {
                       ;     if (rear_bumper() > BUMPER_FUZZY)
 01A3 BD0000            jsr _rear_bumper
 01A6 1A83000A          cpd #10
 01AA 2331              bls L55
 01AC                   .dbline 189
                       ;         {
                       ;             /*printf("You hit my ass\n\n");*/
                       ;             rspeed = lspeed = 50;
 01AC CC0032            ldd #50
 01AF FD0004            std _lspeed
 01B2 CC0032            ldd #50
 01B5 FD0002            std _rspeed
 01B8                   .dbline 190
                       ;             motortk(RIGHT_MOTOR, rspeed);
 01B8 FC0002            ldd _rspeed
 01BB 37                pshb
 01BC 36                psha
 01BD CC0001            ldd #1
 01C0 BD0000            jsr _motortk
 01C3 1838              puly
 01C5                   .dbline 191
                       ;             motortk(LEFT_MOTOR, lspeed);
 01C5 FC0004            ldd _lspeed
 01C8 37                pshb
 01C9 36                psha
 01CA CC0000            ldd #0
 01CD BD0000            jsr _motortk
 01D0 1838              puly
 01D2                   .dbline 192
                       ;             wait(500);
 01D2 CC01F4            ldd #500
 01D5 BD0000            jsr _wait
 01D8                   .dbline 193
                       ;             righturn();
 01D8 BD0115            jsr _righturn
 01DB                   .dbline 194
                       ;         }
 01DB 2038              bra L56
 01DD                 L55:
 01DD                   .dbline 195
                       ;     else if (front_bumper() > BUMPER_FUZZY)
 01DD BD0000            jsr _front_bumper
 01E0 1A83000A          cpd #10
 01E4 232F              bls L57
 01E6                   .dbline 198
                       ;         {
                       ;             /*printf("You hit my head\n\n");*/
                       ;             rspeed = lspeed = -50;
 01E6 CCFFCE            ldd #-50
 01E9 FD0004            std _lspeed
 01EC CCFFCE            ldd #-50
 01EF FD0002            std _rspeed
 01F2                   .dbline 199
                       ;             motortk(RIGHT_MOTOR, rspeed);
 01F2 FC0002            ldd _rspeed
 01F5 37                pshb
 01F6 36                psha
 01F7 CC0001            ldd #1
 01FA BD0000            jsr _motortk
 01FD 1838              puly
 01FF                   .dbline 200
                       ;             motortk(LEFT_MOTOR, lspeed);
 01FF FC0004            ldd _lspeed
 0202 37                pshb
 0203 36                psha
 0204 CC0000            ldd #0
 0207 BD0000            jsr _motortk
 020A 1838              puly
 020C                   .dbline 201
                       ;             wait(500);
 020C CC01F4            ldd #500
 020F BD0000            jsr _wait
 0212                   .dbline 202
                       ;             righturn();
 0212 BD0115            jsr _righturn
 0215                   .dbline 203
                       ;         }
 0215                 L57:
 0215                 L56:
 0215                   .dbline 204
                       ; }
 0215                 L54:
 0215 39                rts
                       ;  IX -> 0,x
 0216                 _firecheck::
 0216                   .dbfunc firecheck
 0216                   .dbline 207
                       ; void firecheck(void)
                       ; {
                       ;     read_IR();
 0216 BD0000            jsr _read_IR
 0219                   .dbline 209
                       ;     
                       ;     if (IRDT[IR6clk] > FIRE)
 0219 FC000A            ldd _IRDT+10
 021C 1A830032          cpd #50
 0220 232C              bls L60
 0222                   .dbline 212
                       ;     {
                       ;         
                       ;         rspeed = lspeed = 0;
 0222 CC0000            ldd #0
 0225 FD0004            std _lspeed
 0228 CC0000            ldd #0
 022B FD0002            std _rspeed
 022E                   .dbline 213
                       ;         motortk(RIGHT_MOTOR, rspeed);
 022E FC0002            ldd _rspeed
 0231 37                pshb
 0232 36                psha
 0233 CC0001            ldd #1
 0236 BD0000            jsr _motortk
 0239 1838              puly
 023B                   .dbline 214
                       ;         motortk(LEFT_MOTOR, lspeed);
 023B FC0004            ldd _lspeed
 023E 37                pshb
 023F 36                psha
 0240 CC0000            ldd #0
 0243 BD0000            jsr _motortk
 0246 1838              puly
 0248                   .dbline 218
                       ;          
                       ;          /*printf("I have found fire\n\n");*/
                       ;          
                       ;          wait(1000);
 0248 CC03E8            ldd #1000
 024B BD0000            jsr _wait
 024E                   .dbline 219
                       ;     }
 024E                 L60:
 024E                   .dbline 220
                       ; }
 024E                 L59:
 024E 39                rts
