#include "ti86asm.inc" #include "ram86.inc" ; _dispAHL equ 4A33h .org _asm_exec_ram ; nop ; pour le shell jp Depart .dw $0000 .dw Title Title: .db "Test all Sony codes !",0 ; Depart: call _flushallmenus call _runindicoff call _clrScrn ld hl,Text ld de,$0001 ld (_curRow),de call _puts ld de,$0005 ld (_curRow),de call _puts Loop: ld de,$0d05 ld (_curRow),de ld hl,(nbr) call Affhlhex ; call _getkey cp kExit jr z,quit cp kDown call z,decnbr cp kUp call z,incnbr cp kDel call z,Send_code cp kF1 jr z,Input jr Loop ; quit: call _clrScrn call _homeup ret Input: call _clrScrn ld de,$0003 ld (_curRow),de ld hl,invitcmd call _puts ld b,3 Keyiptloop: push bc call _getkey pop bc cp kExit jr z,quit cp kLog jr z,ahex cp kSin jr z,bhex cp kCos jr z,chex cp kTan jr z,dhex cp kExp jr z,ehex cp kLn jr z,fhex cp k0 jr c,Keyiptloop cp k9+1 jr nc,Keyiptloop sub $1c ld c,a add a,$30 call _putc ld a,b cp 3 jr z,premchiffre cp 2 jr z,deuchiffre troichiffre: ld a,(nbr) or c ld (nbr),a call Send_code jp Depart premchiffre: dec b ld a,c ld (nbr+1),a jr Keyiptloop deuchiffre: dec b sla c sla c sla c sla c ld a,c ld (nbr),a jr Keyiptloop ahex: ld c,$a jr hexfin bhex: ld c,$b jr hexfin chex: ld c,$c jr hexfin dhex: ld c,$d jr hexfin ehex: ld c,$e jr hexfin fhex: ld c,$f hexfin: ld a,c call _putc ld a,b cp 3 jr z,premchiffre cp 2 jr z,deuchiffre jr troichiffre decnbr: ld hl,(nbr) dec hl ld (nbr),hl ret incnbr: ld hl,(nbr) inc hl ld (nbr),hl ret ; Routine pour convertir l'appareil et la commande Send_code: ld hl,Code+4 ; destination ld b,15 call 437bh ld hl,(nbr) ld d,l ; l'octet à convertir ld hl,Code+4 ; destination ld (hl),%00111100 ld c,5 ; on a déja la tête ld b,8 ; 8 bits à convertir call convert ld b,4 ; 8 bits à convertir push hl ld hl,(nbr) ld d,h ; l'octet à convertir pop hl call convert push bc ld d,(hl) ld a,8 decal: inc c cp c jr z,findecal rl d jr decal findecal: ld (hl),d pop bc ld b,41 ld a,8 trente8bit0: inc c cp c jr nz,pasinchl ld c,0 inc hl pasinchl: djnz trente8bit0 xor a ld b,4 head2: or 1 inc c call verif rla djnz head2 inc c call verif rla ld (hl),a ld b,8 ; 8 bits à convertir push hl ld hl,(nbr) ld d,l ; l'octet à convertir pop hl call convert ld b,4 ; 8 bits à convertir push hl ld hl,(nbr) ld d,h ; l'octet à convertir pop hl call convert ld d,(hl) ld a,8 Fin: inc c cp c jr z,finconv rl d jr Fin finconv: ld (hl),d 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 ;=================== convert: cLoop: ld a,(hl) bit 0,d jr z,code0 code1: or 1 inc c call verif rla or 1 inc c call verif rla inc c call verif rla jr suite code0: or 1 inc c call verif rla inc c call verif rla suite: ld (hl),a ld a,d rrca ld d,a djnz cLoop ret verif: push af ld a,c cp 8 jr nz,vend pop af ld (hl),a inc hl ld c,0 xor a ret vend: pop af ret Affahex: push af srl a srl a srl a srl a add a,48 cp 58 jr c,abcdef1 add a,7 abcdef1: call _putc pop af and %1111 add a,48 cp 58 jr c,abcdef2 add a,7 abcdef2: jp _putc Affhlhex: push af ld a,h call Affahex ld a,l call Affahex pop af ret ; Thanks for Sami Khawam (sKhawam@bigfoot.com) for his send routine. PutByte: call _runindicon 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 jp _runindicoff ;************************************************************************************* Text: .db "Device : Up/Down " .db "Command : Left/Right" .db "Send : Del",0 .db "Command : $",0 invitcmd: .db "Command :",0 nbr: .dw $690 Code: .db 16,22,$0f,$13 .db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 .end