; ;REC80 Remote Control for the TI85 for Usgard. ; ; by Sami Khawam (sKhawam@bigfoot.com) ; ; http://unet.univie.ac.at/~a9501901 ; ; ;This software uses the IR Link as a remote control ;for controling many devices. For informations on ;how to build and how to use the IR Link see my ;home page: ; ; http://unet.univie.ac.at/~a9501901 ; ; ;This software enable to control all the devices that ;uses the REC80 protocol. This protol is used by many ;manufacturers, among them: ; ; Akai, Cannon, Goldstar, Hitachi, Kenwood, NEC, Onkyo ; Pioneer, TEAC, Yamaha and many of other Japanese ; manufacturers. ; ; ;The REC80 code is formed by 4 bytes: 2 Group bytes ;and 2 Command bytes. The second byte of the Group ;and the Command is the complement of the first one. ; ;This version doesn't support the extended REC80 ;protocol. In the extended REC80 the second Group ;byte isn't the complement of the first one, which ;extends the range of devices that can be used. ;If you want extended REC80 protocol see the rec80e ;program. ; ;For the Groups and Commands codes, see rem34bg by ;Bjorn Gahm. ; ; ;The use of the programm is very easy. Only some ;keys are needed: ; ;-Up,Down: Inc- and Derement the Command byte. ;-Left,Right: Inc- and Derement the Group byte. ;-Enter: Send the signal. ; ; ; ;Thanks for Antoine Mercier for his excellent All_phlps ;program. ;Thanks for Andreas Ess for his excellent functions pack. ; ;-- ; Sami Khawam (sKhawam@bigfoot.com) ; ; http://unet.univie.ac.at/~a9501901 #include usgard.h .org 0 .db "REC80 Remote Control by SK",0 Code = TEXT_MEM LD A,$C0 ; Set W1 and R1 OUT (7),A Loop: call CLEARLCD call BUSY_OFF ld hl,&Text ld de,$0001 ld (CURSOR_ROW),de call D_ZT_STR ld de,$0003 ld (CURSOR_ROW),de call D_ZT_STR ld de,$0005 ld (CURSOR_ROW),de call D_ZT_STR ld a, (&Group1) cpl ld (&Group2), a push hl ld a,(&Group1) #fncall D_A_HEX ld a,(&Group2) #fncall D_A_HEX pop hl ld a, (&Command1) cpl ld (&Command2), a ld de,$0006 ld (CURSOR_ROW),de call D_ZT_STR ld a,(&Command1) #fncall D_A_HEX ld a,(&Command2) #fncall D_A_HEX Loop1: call GET_KEY cp K_EXIT ret z cp K_LEFT jr z,dec_Grp cp K_RIGHT jr z,inc_Grp cp K_DOWN jr z,dec_Cmd cp K_UP jr z,inc_Cmd cp K_Enter jr z,SendData jr Loop1 dec_Grp: ld a,(&Group1) dec a ld (&Group1), a jr Loop inc_Grp: ld a,(&Group1) inc a ld (&Group1), a jp &Loop dec_Cmd: ld a,(&Command) dec a ld (&Command),a jp &Loop inc_Cmd: ld a,(&Command) inc a ld (&Command),a jp &Loop SendData: ld hl, Code xor a ld b, 30 ClearCode: ld (hl), a djnz ClearCode call &Encode ld hl, &Data ld b,7 ; We load it into b for djnz call &SendBytes ; Send the Bytes ld hl, Code ld b, 22 ; We load it into b for djnz call &SendBytes ; Send the Bytes jp &Loop SendBytes ld a, (hl) call &PutByte ; Send the Byte inc hl djnz SendBytes ret PutByte: push bc LD C,A LD B,8 ; 8 Bits PB_Next_Bit: call BUSY_ON LD A,$C0 ; Set W1 and R1 OUT (7),A Cont: RR C JR NC,PB_SendZero PB_SendOne: LD A,$E8 JR PB_Output_val PB_SendZero: LD A,$D4 PB_Output_val: OUT (7),A LD DE,$FFFF ; For time-out PB_Wait_for_W0_and_R0: IN A,(7) AND 3 JR Z,PB_Continue IN A,(7) AND 3 JR Z,PB_Continue DEC DE LD A,D OR E JR NZ,PB_Wait_for_W0_and_R0 JR PB_End ; If error return. PB_Continue: LD A,$C0 ; Set W1 and R1 OUT (7),A LD DE,$FFFF ; Reload time-out PB_Wait_for_W1_and_R1: DEC DE LD A,D OR E JR Z,PB_End IN A,(7) AND 3 CP 3 JR NZ,PB_Wait_for_W1_and_R1 DJNZ PB_Next_Bit PB_End: POP BC ret ; This function encodes the data and stores it in 'Code' Encode: ld hl, Code ld de, &Group ld c, 8 ld a, 4 ENextByte push af ld b, 8 ld a, (de) ENextBit call &ShiftL1 call &ShiftL rla jr nc, EZero call &ShiftL call &ShiftL EZero djnz ENextBit pop af inc de dec a jr nz, ENextByte ld b, 16 ENStp1 call &ShiftL1 djnz ENStp1 ld b, 4 ENStp2 call &ShiftL djnz ENStp2 call &ShiftL1 ld a, (hl) ld b, c ShiftRest sla a djnz ShiftRest ld (hl), a ret ShiftL: push af ld a, (hl) sla a SLCont: ld (hl), a dec c jr nz, EndSL inc hl ld c, 8 EndSL: pop af ret ShiftL1: push af ld a, (hl) scf rla jr SLCont Group: Group1: .db $42 Group2: .db $BF Command: Command1: .db $20 Command2: .db 0 Data: .db 25, 21, $0F, $13, $FF, $FF, 0 ; Data + Header Text: .db "Grp : Left,Right " .db "Cmd : Up,Down",0 .db "Send: Enter",0 .db "Group : ",0 .db "Command : ",0 .end