home *** CD-ROM | disk | FTP | other *** search
/ Turbo Toolbox / Turbo_Toolbox.iso / dtx9202 / tricks / asm / uhr.tsr < prev   
Encoding:
Text File  |  1992-01-10  |  3.9 KB  |  148 lines

  1. ;* ------------------------------------------------------- *
  2. ;*                      UHR.TSR                            *
  3. ;*   Uhrroutine zum Einbinden in das TSR Gerüstprogramm    *
  4. ;*          (c) 1992 Ralph Seelig & DMV-Verlag             *
  5. ;* ------------------------------------------------------- *
  6.  
  7. scrpuffer  db 160 dup (?)
  8. aktseite   db ?
  9. scrofs     dw ?
  10.  
  11.  
  12. WriteByte proc
  13.   ; gibt eine Zahl zwischen 0 .. 99 dezimal aus
  14.   ; AL     = Zahl
  15.   ; DL,DH  = Koordinate
  16.   push cx
  17.   push bx
  18.   xor ah,ah
  19.   mov bh,al
  20.   mov bl,100
  21.   div bl             ; AL= int(AL / 100)
  22.   mul bl             ; AL= int(AL / 100) * 100
  23.   sub bh,al          ; 100 er löschen
  24.   mov al,bh          ; AL enthält nur Zahlen zwischen 0..99
  25.   xor ah,ah
  26.   mov bl,10          ; Teilerfaktor
  27.   mov bh,al
  28.   mov cx,2
  29.   wrbl:
  30.     push cx
  31.     div bl
  32.     push ax
  33.     push bx
  34.     mov bh,aktseite
  35.     mov ah,02
  36.     int 10h         ; Cursor setzen
  37.     inc dl          ; x Position erhöhen
  38.     add al,48       ; numerisch => alphanumerisch
  39.     mov ah,09
  40.     mov cx,1
  41.     mov bl,07h      ; Farbattribut
  42.     int 10h         ; Zeichen setzen
  43.     pop bx
  44.     pop ax
  45.     mul bl
  46.     sub bh,al       ; höherwertige Stelle löschen
  47.     mov al,bh
  48.     mov bl,1
  49.     pop cx
  50.   loop wrbl
  51.   pop bx
  52.   pop cx
  53.   ret
  54. WriteByte endp
  55.  
  56. TsrProgram proc
  57.   ; speicherresidente Uhrroutine
  58.   mov ah,0fh
  59.   int 10h                      ; aktuellen Vidomode holen
  60.   cmp al,4                     ; Grafikmodi ?
  61.   jb erlaubt
  62.     mov dl,7                   ; dann TSR Start verhindern
  63.     mov ah,2
  64.     int 21h                    ; Ton ausgeben
  65.     ret
  66.   erlaubt:
  67.   push es
  68.   xor dx,dx
  69.   mov es,dx
  70.   mov word ptr ax,es:[044eh]   ; Bildschirmoffset holen
  71.   mov scrofs,ax
  72.   mov byte ptr al,es:[0462h]   ; aktuelle Seite holen
  73.   mov aktseite,al
  74.   pop es
  75.  
  76.   mov ah,03h
  77.   mov bh,al                    ; aktuelle Screenseite
  78.   int 10h
  79.   push dx                      ; Cursorposition retten
  80.   mov di,offset scrpuffer      ; Zeiger auf Puffer
  81.   push ds
  82.   pop es                       ; ES=DS
  83.   mov ax,0b800h                ; Segment der Videokarte
  84.   push ax                      ; Wert retten
  85.   mov si,scrofs                ; Offset Bildschirmseite
  86.   mov ds,ax
  87.   mov cx,160                   ; 160 Bytes
  88.   rep movsb                    ; vom Bildschirm retten
  89.   push es
  90.   pop ds                       ; DS wieder herstellen
  91.  
  92.   ; eigentliches Programm
  93.  
  94.   xor dh,dh
  95.   mov dl,72           ; x - Position festlegen
  96.   mov cx,2
  97.   SetDPunkt:
  98.     push cx
  99.     push dx
  100.     mov bh,aktseite
  101.     mov ah,02h
  102.     int 10h           ; Cursor setzen
  103.     mov cx,1
  104.     mov ah,09
  105.     mov bl,7
  106.     mov al,':'
  107.     int 10h           ; einen Doppelpunkt anzeigen
  108.     pop dx
  109.     add dl,3          ; x Position erhöhen
  110.     pop cx
  111.   loop SetDPunkt
  112.   xor bx,bx
  113.   UhrLoop:
  114.     mov ah,2ch
  115.     int 21h
  116.     cmp dh,bl         ; eine Sekunde weiter
  117.     jz UhrLoop        ; nein, dann nochmal Uhrzeit holen
  118.     mov bl,dh         ; Sekunden nach BL
  119.     push dx           ; Sekunden retten
  120.     mov al,ch         ; Stunden nach AL
  121.     xor dh,dh
  122.     mov dl,70         ; x Position
  123.     call WriteByte
  124.     inc dl            ; x Position incrementieren
  125.     mov al,cl         ; Minuten nach AL
  126.     call WriteByte
  127.     pop ax            ; Sekunden restaurieren
  128.     mov al,ah
  129.     inc dl            ; x Position
  130.     call WriteByte
  131.     mov ah,01h
  132.     int 16h           ; ist Taste gedrückt worden ?
  133.   jz Uhrloop          ; nein, dann weiter Uhr anzeigen
  134.     xor ax,ax
  135.     int 16h
  136.  
  137.   pop es                       ; Segment der Videokarte
  138.   mov di,scrofs
  139.   mov si,offset scrpuffer
  140.   mov cx,160                   ; Bildschirmausschnitt
  141.   rep movsb                    ; restaurieren
  142.   pop dx                       ; Cursorposition holen
  143.   mov bh,aktseite
  144.   mov ah,02h
  145.   int 10h                      ; Cursor setzen
  146.   ret
  147. TsrProgram endp
  148.