OldTimerS dw 0
OldTimerO dw 0

Timer     dd 0

NewTimer:
  push ax
    inc dword [cs:Timer]
    add byte [cs:TunnelX],1
    add byte [cs:TunnelY],2

    inc byte [cs:anglex]
;    inc byte [cs:angley]
;    inc byte [cs:anglez]

    cmp dword [cs:valeurPersp],70
    je .pas_inc_persp
      sub dword [cs:valeurPersp],2
    .pas_inc_persp:

    in al,60h
    cmp al,1
    jne .pas_fin_tout
      mov al,20h
      out 20h,al
      call Fin_Tout
    .pas_fin_tout:

    mov al,20h
    out 20h,al
  pop ax
iret




StartTimer:
  push cs
  pop ds

  mov cx,04295h    ; = 70/sec

  cli
  mov al,36h
  out 43h,al
  mov al,cl
  out 40h,al
  mov al,ch
  out 40h,al

  mov ax,3508h
  int 21h
  mov [OldTimerS],es
  mov [OldTimerO],bx

  mov ax,2508h
  mov dx,NewTimer
  int 21h

  sti
ret


StopTimer:
  cli
  mov al,36h
  out 43h,al
  mov al,0
  out 40h,al
  out 40h,al

  push ds
  mov ds,[cs:OldTimerS]
  mov dx,[cs:OldTimerO]
  mov ax,2508h
  int 21h
  pop ds
  sti
ret


