home *** CD-ROM | disk | FTP | other *** search
- ;
- ;
- ; This is a TI82 port of the programm for ASH.
- ;
- ; 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 4 keys fonctions
- ; each one represented by an arrow key. To make the program record data
- ; from an remote control, press 2nd and choose the key and then the time
- ; base and the frequency. If you don't know thoses value you should
- ; experiment by using differents ones.
- ; DO NOT specifie frequencies that are less than 30 KHz or more than
- ; 48 KHz!
- ;
- ; This programm needs the STANDART version of the IR Link.
- ;
- ; The PutByte and was taken (and modified) from a disassembly of the ROM.
- ; GetByte is from Randy Gluvna (gluvna@home.com). Thanks.
- ;
-
- #INCLUDE "TI82.H"
- #INCLUDE "KEYS.INC"
-
- PORT = 000H
- Port = 000H
-
- .ORG START_ADDR
- Name:
- .db "IR Remote "
- PName2:
- .db "by Sami Khawam",0
-
- Start:
- LD A, $C0 ; Set W1 and R1
- OUT (Port),A
-
- ROM_CALL(CLEARLCD)
-
- set 3,(IY+05)
- ld hl, PName2
- ld de,$0000
- ld ($800C),de
- ROM_CALL(D_ZT_STR)
-
- res 3,(IY+05)
- ld hl, Text1
- ld de,$0003
- ld ($800C),de
- ROM_CALL(D_ZT_STR)
-
- ProgLoop:
- CALL GET_KEY
- or a
- jr z, ProgLoop
- cp $37
- ret z
- cp G_2nd
- jr z, RecordRemote
-
- dec a ; Only less than 3
- cp 4
- jr nc, ProgLoop
-
- ld hl, CK_1
- ld de, 32
- ld b, a ; Get Offset
- AddNxt1:
- add hl, de
- djnz AddNxt1
-
- ; Now Send data
- ld a, 30 ; Always 30 bytes.
- call PutByte ; Send the Byte
- call SendHeader
- ld b, 30
- NextByte:
- ld a, (hl)
- call PutByte ; Now we send all bytes.
- inc hl
- djnz NextByte
- jr Start
-
-
-
-
-
- RecordRemote
- ROM_CALL(CLEARLCD)
- ld hl, Text2
- ld de,$0001
- ld ($800C),de
- ROM_CALL(D_ZT_STR)
-
- WaitKey:
- call GET_KEY
- or a
- jr z, WaitKey
- cp $37
- jr z, Start
-
- dec a ; Only less than 3
- cp 4
- jr nc, WaitKey
-
- ld hl, CK_1
- ld de, 32
- ld b, a ; Get Offset
- AddNxt2:
- add hl, de
- djnz AddNxt2
-
- push hl
- ld hl, Text_TimeBase
- ld de,$0002
- ld ($800C),de
- ROM_CALL(D_ZT_STR)
- pop hl
- call InputValue
-
- inc hl
- push hl
- ld hl, Text_Wait1
- ld de,$0003
- ld ($800C),de
- ROM_CALL(D_ZT_STR)
- pop hl
- call InputValue
-
- ld a, $5E ; $5E = 30d & $40, because we have 30 bytes
- call PutByte
-
- dec hl
- call SendHeader
-
- push hl
- ROM_CALL(CLEARLCD)
- ld hl, Text_Wait3
- ld de,$0103
- ld ($800C),de
- ROM_CALL(D_ZT_STR)
- ROM_CALL(BUSY_ON)
- WaitSig:
- in a,(Port)
- and 3
- cp 3
- jr nz, DataComing
- call GET_KEY
- cp G_MODE
- jr z, Quit
- jr WaitSig
-
- DataComing:
- pop hl
-
- ld b, 30
- GNextByte:
- push bc
- call GetByte
- pop bc
- ld (hl), a
- inc hl
- call PrintHex
- djnz GNextByte
- ROM_CALL(BUSY_OFF)
- WaitLoop:
- call GET_KEY
- or a ; cp 0
- jr z, WaitLoop
- jp Start
- Quit
- pop hl
- jp Start
-
-
-
-
- InputValue
- IVLoop
- ld de, (CURSOR_ROW)
- set 3,(IY+05)
- ld a, (hl)
- ; #fncall D_A_DEC
- call DispA
- res 3,(IY+05)
- ld (CURSOR_ROW),de
- push hl
- call GET_KEY
- pop hl
- or a
- jr z, IVLoop
- cp G_ENTER
- ret z
- cp G_UP
- jr z, Increment
- cp G_DOWN
- jr z, Decrement
- Increment
- ld a, (hl)
- inc a
- ld (hl), a
- jr IVLoop
- Decrement
- ld a, (hl)
- dec a
- ld (hl), a
- jr IVLoop
-
-
-
- SendHeader
- ld a, (hl)
- call PutByte
- inc hl
-
- ld a, (hl)
- sub 30
- rr a
- inc hl
-
- push hl
-
- ld hl, DelayTab
- ld de, 2
- ld b, a ; Get Offset
- AddNxt3:
- add hl, de
- djnz AddNxt3
-
- ld a, (hl)
- call PutByte
- inc hl
- ld a, (hl)
- call PutByte
- pop hl
- ret
-
-
-
-
-
- GetByte:
- LD B,008H
- R0:
- LD DE,0FFFFH
- JR R2
- R1:
- IN A,(PORT)
- AND 003H
- RET Z
- CP 003H
- JR NZ,R3
- IN A,(PORT)
- AND 003H
- RET Z
- CP 003H
- JR NZ,R3
- R2:
- DEC DE
- LD A,D
- OR E
- JR NZ,R1
- RET
- R3:
- SUB 002H
- JR NC,R8
- LD A,0D4H
- OUT (PORT),A
- RR C
- LD DE,0FFFFH
- R4:
- IN A,(PORT)
- AND 003H
- CP 002H
- JR Z,R5
- DEC DE
- LD A,D
- OR E
- JR NZ,R4
- RET
- R5:
- LD A,0C0H
- OUT (PORT),A
- LD D,004H
- R6:
- DEC D
- JR Z,R7
- IN A,(PORT)
- AND 003H
- CP 003H
- JR NZ,R6
- R7:
- DJNZ R0
- LD A,C
- RET
- R8:
- LD A,0E8H
- OUT (PORT),A
- RR C
- LD DE,0FFFFH
- R9:
- IN A,(PORT)
- AND 003H
- CP 001H
- JR Z,R5
- DEC DE
- LD A,D
- OR E
- JR NZ,R9
- RET
-
-
-
- PutByte:
- push bc
- LD C,A
- LD B,8 ; 8 Bits
-
- PB_Next_Bit:
- ld d, B ; Only to see if it is working.
- ld e, $01 ;
- ld ($800C),de ;
- ld A, B ;
- ROM_CALL(TX_CHARPUT) ;
-
-
- 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
-
-
-
- ;;;;;;;;;;;PrintHex function
- PrintHex: ; de destroyed
- push hl
- 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
- pop hl
- ret
- ;;;;;;;;;end PrintHex function
-
-
-
- DispA: ;Routine to Display A [By: Matthew Shepcar]
- push hl
- push de
- ld l,a ;Loads a into l
- ld h,0 ;0 into H
- ;DispHL: ;Displays HL [By: Matthew Shepcar]
- xor a ;Loads 0 into A
- ROM_CALL(D_HL_DECI) ;Calls 4A33h
- dec hl ;Decrease it
- ROM_CALL(D_ZT_STR) ;Put on screen and return
- pop de
- pop hl
- ret
-
-
-
-
-
- CK_1:
- .db 10, 32
- .db 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
- .db 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
- .db 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
-
- .db 11, 34
- .db 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
- .db 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
- .db 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
-
- .db 12, 36
- .db 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
- .db 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
- .db 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
-
- .db 13, 38
- .db 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
- .db 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
- .db 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
-
-
- DelayTab:
- .db $0B, $0F
- .db $0C, $10
- .db $0D, $11
- .db $0E, $12
- .db $0F, $12
- .db $0F, $13
- .db $10, $14
- .db $11, $14
- .db $11, $15
- .db $12, $15
-
-
- Text1:
- .db "2nd to record.", 0
- Text2:
- .db "Key to assign:", 0
- Text_TimeBase:
- .db "Time base:", 0
- Text_Wait1:
- .db "Frequency:", 0
- Text_Wait3:
- .db "Getting "
- Text_Data:
- .db "Data", $CE, 0
- .end
-