home *** CD-ROM | disk | FTP | other *** search
/ Enigma Amiga Life 109 / EnigmaAmiga109CD.iso / software / testi / corsoasm / sorgenti7 / lezione11n2.s < prev    next >
Text File  |  1995-09-29  |  2KB  |  76 lines

  1.  
  2. ; Lezione11n2.s -Routine di temporizzazione che permette di attendere un
  3. ;         certo numero di Hertz
  4.  
  5. Start:
  6.     move.l    4.w,a6        ; Execbase in a6
  7.     jsr    -$84(a6)    ; forbid
  8.     jsr    -$78(a6)    ; disable
  9.     LEA    $DFF000,A5
  10.  
  11.     bsr.s    CIAHZ    ; Attendi un paio di secondi
  12.  
  13.     move.l    4.w,a6        ; Execbase in a6
  14.     jsr    -$7e(a6)    ; enable
  15.     jsr    -$8a(a6)    ; permit
  16.     rts
  17.  
  18.  
  19. ; bfe801 todlo    -    1=~0,02 secs o 1/50 sec (PAL) o 1/60 sec (NTSC)
  20. ; bfe901 todmid    -    1=~3 secs
  21. ; bfea01 todhi    -    1=~21 mins
  22. ;
  23. ; In pratica e' un timer che puo' contenere un numero a 23 bit, e tale num.
  24. ; e' diviso: bits 0-7 in TODLO, bits 8-15 in TODMID e bits 16-23 in TODHI.
  25.  
  26.  
  27. CIAHZ:
  28.     MOVE.L    A2,-(SP)
  29.     LEA    $BFE001,A2    ; CIAA base -> USATO
  30. ;    LEA    $BFD000,A2    ; CIAB base
  31.  
  32.     MOVE.B    #0,$800(A2)    ; TODLO - bit 7-0 del timer a 50-60hz
  33.                 ; reset timer!
  34. WCIA:
  35.     CMPI.B    #50*2,$800(A2)    ; TODLO - Wait time = 2 secondi...
  36.     BGE.S    DONE
  37.     BRA.S    WCIA
  38. DONE:
  39.     MOVE.L    (SP)+,A2
  40.     RTS
  41.  
  42.     end
  43.  
  44. Da notare che se si vuole usare il CIAB, si passa ad un timer di sync
  45. orizzontale e non verticale, per cui e' mooolto piu' veloce. Per attendere
  46. 2 secondi circa occorre scomodare il TODMID:
  47.  
  48. CIAHZ:
  49.     MOVE.L    A2,-(SP)
  50. ;    LEA    $BFE001,A2    ; CIAA base
  51.     LEA    $BFD000,A2    ; CIAB base -> USATO
  52.  
  53.     MOVE.B    #0,$800(A2)    ; TODLO - bit 7-0 del timer a 50-60hz
  54.                 ; reset timer!
  55. WCIA:
  56.     CMPI.B    #120,$900(A2)    ; TODMID - Wait time = 2 secondi...
  57.     BGE.S    DONE
  58.     BRA.S    WCIA
  59. DONE:
  60.     MOVE.L    (SP)+,A2
  61.     RTS
  62.  
  63. Attenzione al fatto che il TOD del CIAA e' usato dal timer.device, mentre il
  64. TOD del CIAB e' usato dalla graphics.library!
  65.  
  66. Se potete, aspettate tempi brevi con la classica routine:
  67.  
  68.     lea    $dff006,a0    ; VHPOSR
  69.     moveq    #XXX-1,d0    ; Numero di linee da aspettare
  70. waitlines:
  71.     move.b    (a0),d1        ; $dff006 - linea verticale attuale in d1
  72. stepline:
  73.     cmp.b    (a0),d1        ; siamo sempre alla stessa linea?
  74.     beq.s    stepline    ; se si aspetta
  75.     dbra    d0,waitlines    ; linea "aspettata", aspetta d0-1 linee
  76.