#include "ti86asm.inc" ; _dispAHL equ 4A33h ; .org _asm_exec_ram ; nop ; pour le shell jp Depart .dw $0000 .dw Title Title: .db "Test all RC5 codes !",0 ; Depart: call _flushallmenus call _runindicoff call _clrLCD ld hl,Text ld de,$0001 ld (_curRow),de call _puts ld de,$0005 ld (_curRow),de call _puts Loop: ld de,$0B05 ld (_curRow),de ld hl,(App) ld h,0 xor a call _dispAHL ld de,$0B06 ld (_curRow),de ld hl,(Cmde) ld h,0 xor a call _dispAHL ; call _getkey cp kExit jr z,quit cp kDown call z,dec_App cp kUp call z,inc_App cp kLeft call z,dec_Code cp kRight call z,inc_Code cp kDel call z,Send_code jr Loop ; quit: call _clrScrn call _homeup ret dec_App: ld a,(App) cp 0 ret z dec a ld (App),a xor a ret inc_App: ld a,(App) cp 31 ret z inc a ld (App),a xor a ret dec_Code: ld a,(Cmde) cp 0 ret z dec a ld (Cmde),a xor a ret inc_Code: ld a,(Cmde) cp 127 ret z inc a ld (Cmde),a xor a ret ;******************************************************************************************* ;************ Routine pour convertir l'appareil et la commande en code RC5 ***************** ;******************************************************************************************* Send_code: ld a,(App) xor %11100000 ld c,a call Change_4_bits ld (Code+4),a call Change_4_bits ld (Code+5),a ld a,(Cmde) cp 63 call nz,Etendu ld c,a sla c sla c call Change_4_bits ld (Code+6),a call Change_4_bits xor %00001010 ld (Code+7),a ;******************************************************************************************* ;****************** Routine pour envoyer le code par Sami Khawam *************************** ;******************************************************************************************* SendData: ld a,$C0 out (7),a ; sorties hautes ; ld a,(Code) ; Number of bytes ld b,a ; We load it into b for djnz call PutByte ; Send the Byte ld a,(Code+1) ; The Duration of a Bit call PutByte ; Send the Byte ld a,(Code+2) ; The First delay call PutByte ; Send the Byte ld a,(Code+3) ; The Second delay call PutByte ; Send the Byte ld hl,Code+4 NextByte: ld a,(hl) call PutByte ; Now we send all bytes. inc hl djnz NextByte ret PutByte: push bc ld c,a ld b,8 ; 8 Bits PBNextBit: ld a,$C0 out (7),a Cont: rr c jr nc,PBSendZero PBSendOne: ld a,$E8 jr PBOutputval PBSendZero: ld a,$D4 PBOutputval: out (7),a ld de,$FFFF ; For time-out PBWaitforW0andR0: in a,(7) and 3 jr Z,PBContinue in a,(7) and 3 jr Z,PBContinue dec de ld a,d or e jr nz,PBWaitforW0andR0 or 3 jr PBEnd ; If error return. PBContinue: ld a,$C0 out (7),a ld de,$FFFF ; Reload time-out PBWaitforW1andR1: dec de ld a,d or e jr z,PBEnd in a,(7) and 3 cp 3 jr nz,PBWaitforW1andR1 djnz PBNextBit PBEnd: pop bc ret ;******************************************************************************************* Change_4_bits: xor a ld b,4 CtRC5: sla a sla a bit 7,c jr nz,Un xor %00000010 jr Suite Un: xor %00000001 Suite: rlc c djnz CtRC5 ret ;******************************************************************************************* Etendu: ret c ; s'il est inféreur à 63, c'est fini sub 64 ; sinon on lui retranche 64 push af ; on sauve la nouvelle commande ld a,(Code+4) ; modification au niveau de l'adresse xor %00110000 ; on change un 1 logique en 0 ld (Code+4),a ; sauve cette modification pop af ret ;************************************************************************************* Text: .db "Appareil : Up/Down " .db "Commande : Left/Right" .db "Send : Del",0 .db "Appareil : " .db "Commande : ",0 App: .db 0 Cmde: .db 0 Code: .db 4,32,$0E,$12,0,0,0,0 .end