home *** CD-ROM | disk | FTP | other *** search
- ;
- ;REC80 Remote Control for the TI82 for ASH.
- ;
- ; 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 "TI82.H"
- #INCLUDE "KEYS.INC"
-
- PORT = 000H
-
- .ORG START_ADDR
- .db "REC80 Remote Control by SK",0
-
- Code = APD_BUF
-
- LD A,$C0 ; Set W1 and R1
- OUT (PORT),A
-
- Loop:
- ROM_CALL(CLEARLCD)
- ROM_CALL(BUSY_OFF)
- ld hl,Text
-
- ld de,$0001
- ld (CURSOR_ROW),de
- ROM_CALL(D_ZT_STR)
-
- ld de,$0003
- ld (CURSOR_ROW),de
- ROM_CALL(D_ZT_STR)
-
- ld de,$0005
- ld (CURSOR_ROW),de
- ROM_CALL(D_ZT_STR)
-
- ld a, (Group1)
- cpl
- ld (Group2), a
-
- push hl
- ld a,(Group1)
- call DispAHex
- ld a,(Group2)
- call DispAHex
- pop hl
-
- ld a, (Command1)
- cpl
- ld (Command2), a
-
- ld de,$0006
- ld (CURSOR_ROW),de
- ROM_CALL(D_ZT_STR)
-
- ld a,(Command1)
- call DispAHex
- ld a,(Command2)
- call DispAHex
-
- Loop1:
- call GET_KEY
- cp G_MODE
- ret z
- cp G_LEFT
- jr z,dec_Grp
- cp G_RIGHT
- jr z,inc_Grp
- cp G_DOWN
- jr z,dec_Cmd
- cp G_UP
- jr z,inc_Cmd
- cp G_ENTER
- jr z,SendData
- jr Loop1
-
- dec_Grp:
- ld a,(Group1)
- dec a
- ld (Group1), a
- jp 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, 20 ; 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:
- ROM_CALL(BUSY_ON)
- LD A,$C0 ; Set W1 and R1
- OUT (PORT),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 (PORT),A
- LD DE,$FFFF ; For time-out
- PB_Wait_for_W0_and_R0:
- IN A,(PORT)
- AND 3
- JR Z,PB_Continue
- IN A,(PORT)
- 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 (PORT),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,(PORT)
- 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
-
-
- DispAHex:
- push bc
- push de
-
- ld b, a
- and $0f0
- rrca
- rrca
- rrca
- rrca
-
- add a, 30h
- cp $3a
- jr c, hexnumber0
- add a, $7
- hexnumber0:
- ROM_CALL(TX_CHARPUT)
-
- ld a, b
- and $0f
-
- add a, 30h
- cp $3a
- jr c, hexnumber1
- add a, $7
- hexnumber1:
- ROM_CALL(TX_CHARPUT)
- pop de
- pop bc
- ret
-
-
- Group:
- Group1:
- .db $42
- Group2:
- .db $BF
- Command:
- Command1:
- .db $20
- Command2:
- .db 0
-
- Data:
- .db 23, 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
-