home *** CD-ROM | disk | FTP | other *** search
- ;
- ;
- ; IR Link Library v1.0 for the TI92
- ;
- ; by Sami Khawam ( sKhawam@bigfoot.com )
- ;
- ;
- ; This library will enable you to use the IR Link. There are only
- ; 4 routines now, but new routines will be added in the future ( like
- ; remote control encoding, deconding...).
- ;
- ; Although the ROM link routines can be used with the IR Link, this
- ; library has it own linking routines ( work also without the IR Link ).
- ;
- ;
- ; If you haven't yet heard of the IR Link, take a look at my homepage:
- ;
- ; http://unet.univie.ac.at/~a9501901
- ;
- ;
- ; Thanks for Antoine Mercier for having ported
- ; the PutByte routine from the TI85.
- ;
- ;
- ; Sami Khawam
-
-
- include "tios.h"
- xdef _library
- xdef irlib@0000
- xdef irlib@0001
- xdef irlib@0002
- xdef irlib@0003
- xdef irlib@0004
-
- ;************** Start of library ***************
-
-
-
- ; **********************************************
- ;
- ; PutByte: Send a byte to the IR Link
- ; Input: d3.b Byte to send
- ; Output: none
- ; Destroyed: d4
- ;
- ;
- ;
- ; PutLink: Send a byte/word of longword to the IR Link
- ; Input: d3 data to send
- ; d4 number of bits -1 (7...31)
- ; Output: none
- ; Destroyed: none
- ;
- ; Thanks for Antoine Mercier for having ported
- ; those routine from the TI85.
- ;
-
- irlib@0000:
- PutByte:
- move.w #7,d4
- irlib@0001:
- PutLink
- movem d2-d4,-(a7)
- clr.b $60000C
- bset.b #6,$60000C ; Turn on control mode
-
- nextbit:
- bclr.b #0,$60000E ; rouge haut
- bclr.b #1,$60000E ; blanc haut
- lsr.l #1,d3
- bcc pbsend0
- pbsend1:
- bset.b #1,$60000E ; blanc bas
- bra pbsuite
- pbsend0:
- bset.b #0,$60000E ; rouge bas
- pbsuite:
- move.w #$FFFF,d2
- waitforR0:
- btst.b #2,$60000E
- bne suite1
- btst.b #2,$60000E
- bne suite1
- dbne d2,waitforR0
- bra pbfin
- suite1:
- move.w #$FFFF,d2
- waitforW0:
- btst.b #3,$60000E
- bne suite2
- btst.b #3,$60000E
- bne suite2
- dbne d2,waitforW0
- bra pbfin
- suite2:
- bclr.b #0,$60000E ; rouge haut
- bclr.b #1,$60000E ; blanc haut
- move.w #$FFFF,d2
- waitforR1:
- btst.b #2,$60000E
- beq suite3
- btst.b #2,$60000E
- beq suite3
- dbne d2,waitforR1
- bra pbfin
- suite3:
- move.w #$FFFF,d2
- waitforW1:
- btst.b #3,$60000E
- beq suite4
- btst.b #3,$60000E
- beq suite4
- dbne d2,waitforW1
- bra pbfin
- suite4:
- dbne d4,nextbit
- pbfin:
- bclr.b #0,$60000E ; rouge haut
- bclr.b #1,$60000E ; blanc haut
- movem (a7)+,d2-d4
- rts
-
- ;*****************************************************
-
-
- ; **********************************************
- ;
- ; GetByte: Get a byte from the IR Link
- ; Input: none
- ; Output: d3.b Byte received
- ; Destroyed: d4
- ;
- ;
- ;
- ; PutLink: Get a byte/word of longword from the IR Link-DOESN'T WORK
- ; Input: d4.w Number of Bits
- ; Output: d3 data received
- ; Destroyed: none
- ;
- ; The GetLink routine DOES NOT WORK!
- ;
- ;
- irlib@0002:
- GetByte:
- move.w #8,d4
- irlib@0003:
- GetLink: ; Doesn't work with d4 != 8
- movem d1-d2,-(a7)
- clr.l d3
- ; clr.b $60000C
- ; bset.b #6,$60000C ; Turn on control mode
- GLNextBit
- move.w #$FFFF,d2
- GLWaitChange:
- btst.b #2,$60000E
- bne GLGet0
- btst.b #3,$60000E
- bne GLGet1
- btst.b #2,$60000E
- bne GLGet0
- btst.b #3,$60000E
- bne GLGet1
- sub.w #1,d2
- cmp.w #0,d2
- bne GLWaitChange
- bra GLEnd
- GLGet0:
- bset.b #1,$60000E ; Set W0
- lsr.l #1,d3
- GLWaitR1:
- btst.b #2,$60000E
- beq GLSetHigh
- btst.b #2,$60000E
- beq GLSetHigh
- sub.w #1,d2
- cmp.w #0,d2
- bne GLWaitR1
- bra GLEnd
- GLGet1:
- bset.b #0,$60000E ; Set R0
- lsr.l #1,d3
- ori #$80,d3
- GLWaitW1:
- btst.b #3,$60000E
- beq GLSetHigh
- btst.b #3,$60000E
- beq GLSetHigh
- sub.w #1,d2
- cmp.w #0,d2
- bne GLWaitW1
- bra GLEnd
- GLSetHigh
- bclr.b #0,$60000E ; Set R1
- bclr.b #1,$60000E ; Set W1
- move.w #$0008,d2
- GLWaitR1_2:
- btst.b #2,$60000E
- beq GLCont1
- btst.b #2,$60000E
- beq GLCont1
- sub.w #1,d2
- cmp.w #0,d2
- bne GLWaitR1_2
- GLCont1:
- move.w #$0008,d2
- GLWaitW1_2:
- btst.b #3,$60000E
- beq GLCont2
- btst.b #3,$60000E
- beq GLCont2
- sub.w #1,d2
- cmp.w #0,d2
- bne GLWaitW1_2
- GLCont2:
- sub.w #1,d4
- cmp.w #0,d4
- bne GLNextBit
- GLEnd:
- bclr.b #0,$60000E ; Set R1
- bclr.b #1,$60000E ; Set W1
- movem (a7)+,d1-d2
- rts
-
- ;*****************************************************
- ;
- ; Convert between frequency in KHz to delay units needed by the IR Link.
- ; Input: d2.b Freq in KHz.
- ; Output: d3.w contains the 2 delay values.
- ; Used: a2
- ;
- irlib@0004:
- Freq2Delay:
- sub.b #30,d2 ; Substract 30KHz from it.
- andi #30,d2
- lea DelayTab(PC),a2 ; Now A2 points to the delay table.
- move.w 0(a2,d2),d3 ; Copy the 2 delay values corresponding
- ; to the freq to d3.
- rts
-
-
-
-
- ;*****************************************************
-
-
- DelayTab: ; To convert between KHz and delay units.
- dc.b $0B,$0F
- dc.b $0C,$10
- dc.b $0D,$11
- dc.b $0E,$12
- dc.b $0F,$12
- dc.b $0F,$13
- dc.b $10,$14
- dc.b $11,$14
- dc.b $11,$15
- dc.b $12,$15
-
- _library dc.b "irlib",0
- end
-