home *** CD-ROM | disk | FTP | other *** search
/ ticalc.org / ticalc_org_rev_b.iso / archives / 82 / asm / source / ash / all_phps.asm next >
Encoding:
Assembly Source File  |  2001-07-01  |  4.1 KB  |  212 lines

  1. #INCLUDE "TI82.H"
  2. #INCLUDE "KEYS.INC"
  3. ;
  4. App      =  APD_BUF
  5. Cmde    =    App+1
  6. Code    =    App+2
  7. ;
  8.  
  9. .ORG START_ADDR
  10.     .db "Test  all  RC5  codes !",0
  11. ;
  12. Depart:
  13.    ROM_CALL(BUSY_OFF)
  14.    ROM_CALL(CLEARLCD)
  15.    ld hl,Text
  16.     ld de,$0001
  17.     ld (CURSOR_ROW),de
  18.    ROM_CALL(D_ZT_STR)            
  19.     ld de,$0005
  20.     ld (CURSOR_ROW),de
  21.    ROM_CALL(D_ZT_STR)            
  22. Loop:
  23.    ld de,$0A05
  24.     ld (CURSOR_ROW),de
  25.     ld hl,(App)
  26.     ld h,0
  27.    ROM_CALL(D_HL_DECI)
  28.    ld de,$0A06
  29.     ld (CURSOR_ROW),de
  30.     ld hl,(Cmde)
  31.     ld h,0
  32.    ROM_CALL(D_HL_DECI)
  33. GetK:
  34.     call GET_KEY
  35.    cp G_MODE
  36.     ret z
  37.    cp G_DOWN
  38.     jr z,dec_App
  39.    cp G_UP
  40.     jr z,inc_App
  41.    cp G_LEFT
  42.     jr z,dec_Code
  43.    cp G_RIGHT
  44.     jr z,inc_Code
  45.    cp G_DEL
  46.     jr z,Send_code
  47.     jr GetK
  48. ;
  49. dec_App:
  50.     ld a,(App)
  51.    or a
  52.     jr z,Loop
  53.     dec a
  54.     ld (App),a
  55.     jr Loop
  56. inc_App:
  57.     ld a,(App)
  58.     cp 31
  59.     jr z,Loop
  60.     inc a
  61.     ld (App),a
  62.     jr Loop
  63. dec_Code:
  64.     ld a,(Cmde)
  65.     cp 0
  66.     jr z,Loop
  67.     dec a
  68.     ld (Cmde),a
  69.     jr Loop
  70. inc_Code:
  71.     ld a,(Cmde)
  72.     cp 127
  73.     jr z,Loop
  74.     inc a
  75.     ld (Cmde),a
  76.     jr Loop
  77.  
  78. ;*******************************************************************************************
  79. ;************ Routine pour convertir l'appareil et la commande en code RC5 *****************
  80. ;*******************************************************************************************
  81. Send_code:
  82.     ld a,4
  83.     ld (Code),a
  84.     ld a,32
  85.     ld (Code+1),a
  86.     ld a,$0E
  87.     ld (Code+2),a
  88.     ld a,$12
  89.     ld (Code+3),a
  90. ;
  91.     ld a,(App)
  92.     xor %11100000
  93.     ld c,a
  94.    call Change_4_bits
  95.     ld (Code+4),a
  96.    call Change_4_bits
  97.     ld (Code+5),a
  98.     ld a,(Cmde)
  99.     cp 63
  100.    call nz,Etendu
  101.     ld c,a
  102.     sla c
  103.     sla c
  104.    call Change_4_bits
  105.     ld (Code+6),a
  106.    call Change_4_bits
  107.     xor %00001010
  108.     ld (Code+7),a
  109. ;*******************************************************************************************
  110. ;****************** Routine pour envoyer le code par Sami Khawam ***************************
  111. ;*******************************************************************************************
  112. SendData:
  113.     ld a,$C0
  114.    out (0),a               ; sorties hautes
  115. ;
  116.     ld a,(Code)                    ; Number of bytes
  117.     ld b,a                        ; We load it into b for djnz
  118.    call PutByte           ; Send the Byte
  119.     ld a,(Code+1)                ; The Duration of a Bit
  120.    call PutByte           ; Send the Byte
  121.     ld a,(Code+2)                ; The First delay
  122.    call PutByte           ; Send the Byte
  123.     ld a,(Code+3)                ; The Second delay
  124.    call PutByte           ; Send the Byte
  125.     ld hl,Code+4
  126. NextByte:
  127.     ld a,(hl)
  128.    call PutByte           ; Now we send all bytes.
  129.     inc hl
  130.     djnz NextByte
  131.    jp Loop
  132. PutByte:
  133.     push bc
  134.     ld c,a
  135.     ld b,8                        ; 8 Bits
  136. PB_Next_Bit:
  137.     ld a,$C0                    ; Set W1 and R1
  138.    out (0),a
  139.     rr c
  140.     jr NC,PB_SendZero
  141.     ld a,$E8
  142.     jr PB_output_val
  143. PB_SendZero:
  144.     ld a,$D4
  145. PB_output_val:
  146.    out (0),a
  147.     ld de,$FFFF                    ; For time-out
  148. PB_Wait_for_W0_and_R0:
  149.    in a,(0)
  150.     and 3
  151.     jr z,PB_Continue
  152.    in a,(0)
  153.     and 3
  154.     jr z,PB_Continue
  155.     dec de
  156.     ld a,d
  157.     or e
  158.     jr NZ,PB_Wait_for_W0_and_R0
  159.     jr PB_End                    ; If error return.
  160. PB_Continue:
  161.     ld a,$C0                    ; Set W1 and R1
  162.    out (0),a
  163.     ld de,$FFFF                    ; Reload time-out
  164. PB_Wait_for_W1_and_R1:
  165.     dec de
  166.     ld a,d
  167.     or e
  168.     jr z,PB_End
  169.    in a,(0)
  170.     and 3
  171.     cp 3
  172.     jr NZ,PB_Wait_for_W1_and_R1
  173.     djnz PB_Next_Bit
  174. PB_End:
  175.     pop bc
  176.     ret
  177. ;*******************************************************************************************
  178. Change_4_bits:
  179.     xor a
  180.     ld b,4
  181. CtRC5:
  182.     sla a
  183.     sla a
  184.     bit 7,c    
  185.     jr nz,Un
  186.     xor %00000010
  187.     jr Suite
  188. Un:
  189.     xor %00000001
  190. Suite:
  191.     rlc c
  192.     djnz CtRC5
  193.     ret
  194. ;*******************************************************************************************
  195. Etendu:
  196.     ret c                        ; s'il est infΘreur α 63, c'est fini
  197.     sub 64                        ; sinon on lui retranche 64
  198.     push af                        ; on sauve la nouvelle commande
  199.     ld a,(Code+4)                ; modification au niveau de l'adresse
  200.     xor %00110000                ; on change un 1 logique en 0
  201.     ld (Code+4),a                ; sauve cette modification
  202.     pop af
  203.     ret
  204. ;*******************************************************************************************
  205. Text:
  206.    .db   "App : Up/Down   "
  207.    .db   "Cmd : Left/Right"
  208.    .db   "Send: Del",0
  209.    .db   "Appareil :      "
  210.    .db   "Commande :",0
  211. .end
  212.