; ; ; IR Remote for the TI92. ; Ported to the 92 by Antoine MERCIER (a.mercier@caramail.com) ; ; A sample program for using the IR Link as a Learning Remote Control. ; ; by Sami Khawam (sKhawam@bigfoot.com) ; ; http://unet.univie.ac.at/~a9501901 ; ; The programm is very simple to use. There are only 5 keys fonctions ; represented by F1-F5 keys. To make the program record data ; from an remote control, press Enter and choose the key and then the time ; base and the frequency. If you don't know thoses value , when dealing ; with an unknow remote, you should experiment by using differents ones. ; ; This has been compiled under Doors Os v0.85, but should work ; if compiled under any other shell. ; ; This programm needs the STANDART version of the IR Link. ; The IRLib library is needed. ; ; ; If you haven't yet heard of the IR Link, take a look at my homepage: ; ; http://unet.univie.ac.at/~a9501901 ; include "tios.h" include "flib.h" include "hexlib.h" include "irlib.h" xdef _main xdef _comment SetFont macro move.w \1,-(a7) jsr tios::FontSetSys lea 2(a7),a7 endm WriteStr macro move.w \3,-(a7) pea \4(pc) move.w \2,-(a7) move.w \1,-(a7) jsr tios::DrawStrXY lea 10(a7),a7 endm ;************************* Start of Program ************************** _main: clr d3 clr d4 clr d5 jsr flib::clr_scr SetFont #1 WriteStr #8,#5,#0,_comment SetFont #2 WriteStr #0,#40,#1,Text1 WriteStr #0,#60,#1,Text2 clr.b $60000C bset.b #6,$60000C ; Turn on control mode Loop: jsr flib::idle_loop cmp #264,d0 ; exit beq Exit cmp #13,d0 ; Enter beq RecordRemote cmp #268,d0 blt Loop sub #268,d0 ; 268 is the code for F1 cmp #4,d0 ; bgt Loop lea CmdTable(PC),a0 ; Now A0 points to the data start. lsl.w #5,d0 ; Multiply by 32, since we use 32 bytes for each ; of the 5 commands. add.l d0,a0 move.b #30,d3 ; Tell the link that we are going to send jsr irlib::PutByte ; 30 bytes. bsr SendHeader move #29,d5 SNextByte: move.b (a0)+,d3 jsr irlib::PutByte dbra d5,SNextByte bra Loop Exit: jsr tios::reset_link rts SendHeader: move.b (a0)+,d3 ; Send the time base. jsr irlib::PutByte clr d2 move.b (a0)+,d2 ; Read the frequency information. jsr irlib::Freq2Delay move.w #15,d4 ; Send both of them. jsr irlib::PutLink rts ; Return. RecordRemote jsr flib::clr_scr SetFont #1 WriteStr #8,#5,#0,_comment WriteStr #0,#30,#1,Text3 RRKLoop: jsr flib::idle_loop cmp #264,d0 ; exit. Return to main loop. beq _main cmp #268,d0 blt RRKLoop sub #268,d0 ; 268 is the code for F1 cmp #4,d0 ; bgt RRKLoop lea CmdTable(PC),a3 ; Now A3 points to the data start. lsl.w #5,d0 ; Multiply by 32, since we use 32 bytes for each ; of the 5 commands. add.l d0,a3 ; a3 points now to the start of data. WriteStr #0,#40,#1,Text4 ; Get time base move.w #5,d1 ; Where to print the value. move.w #8,d2 clr d5 ; Min time base = 0 move.b #$FE,d6 ; Max time base = $FE bsr InputValue ; Get time base from user. add #1,a3 WriteStr #0,#48,#1,Text5 ; Get freq move.w #6,d1 ; Where to print the value. move.w #13,d2 move.b #30,d5 ; Min freq = 30Khz move.b #48,d6 ; Max freq = 48Khz bsr InputValue ; Get time base from user. move.b #$5E,d3 ; Tell the link that we want to receive jsr irlib::PutByte ; 30 bytes. sub #1,a3 move.l a3,a0 bsr SendHeader ; Send the header. move.l a0,a3 jsr flib::clr_scr WriteStr #20,#10,#0,Text6 bclr.b #0,$60000E ; Set R1 bclr.b #1,$60000E ; Set W1 WaitSig: tst.w (tios::kb_vars+$1C) beq CheckLines move.w (tios::kb_vars+$1E),d0 clr.w (tios::kb_vars+$1C) cmp.w #264,d0 beq _main CheckLines: btst.b #2,$60000E bne ReceiveData btst.b #3,$60000E bne ReceiveData bra WaitSig ReceiveData: move.b #29,d5 move.l #5,d1 move.l #0,d2 GNextByte: jsr irlib::GetByte move.b d3,(a3)+ move.l d3,d0 move.l #1,d4 cmp.l #19,d5 bne nonewline1 add.l #1,d1 nonewline1 cmp.l #9,d5 bne nonewline2 add.l #1,d1 nonewline2: jsr hexlib::put_hex add.l #1,d2 dbra d5,GNextByte jsr flib::idle_loop bra _main ; InputValue ; Input: d1 ( row), d2 (column) ; d5 ( min val), d6 ( max val ) ; a3 ( address where the byte will be stored ) ; Output: (a3) contains byte read ; InputValue: movem d1-d6,-(a7) ; Save the coordinates of the numbers move.b (a3),d4 ; Read the data from memory. clr.b d0 Convert2BCD subi.b #10,d4 bcs IVCont addi.b #$10,d0 bra Convert2BCD IVCont addi.b #10,d4 or.b d4,d0 move.w #1,d4 jsr hexlib::put_hex jsr flib::idle_loop movem (a7)+,d1-d6 ; Restore the coordinates of the numbers cmp #344,d0 ; down beq Decrement cmp #338,d0 ; up beq Increment cmp #13,d0 ; Enter beq IVExit bra InputValue Decrement: move.b (a3),d0 ; Read the data from memory. cmp.b d5,d0 beq InputValue sub.b #1,d0 move.b d0,(a3) ; Write data to memory. bra InputValue Increment: move.b (a3),d0 ; Read the data from memory. cmp.b d6,d0 beq InputValue add.b #1,d0 move.b d0,(a3) ; Write data to memory. bra InputValue IVExit: rts CmdTable: dc.b 10,32 dc.b 1,2,3,4,5,6,7,8,9,$Fe dc.b 0,0,0,0,0,0,0,0,0,0 dc.b 0,0,0,0,0,0,0,0,0,0 dc.b 11,34 dc.b 0,0,0,0,0,0,0,0,0,0 dc.b 0,0,0,0,0,0,0,0,0,0 dc.b 0,0,0,0,0,0,0,0,0,0 dc.b 12,36 dc.b 0,0,0,0,0,0,0,0,0,0 dc.b 0,0,0,0,0,0,0,0,0,0 dc.b 0,0,0,0,0,0,0,0,0,0 dc.b 13,38 dc.b 0,0,0,0,0,0,0,0,0,0 dc.b 0,0,0,0,0,0,0,0,0,0 dc.b 0,0,0,0,0,0,0,0,0,0 dc.b 14,40 dc.b 0,0,0,0,0,0,0,0,0,0 dc.b 0,0,0,0,0,0,0,0,0,0 dc.b 0,0,0,0,0,0,0,0,0,0 Text1: dc.b "Enter to Record.",0 Text2: dc.b "F1-F5 to Send.",0 Text3: dc.b "Key (F1-F5) to Assing:",0 Text4: dc.b "Time Base:",0 Text5: dc.b "Frequency (KHz):",0 Text6: dc.b "Waiting for data...",0 _comment dc.b "IR Remote by Sami Khawam",0 end