home *** CD-ROM | disk | FTP | other *** search
/ Turbo Toolbox / Turbo_Toolbox.iso / 1989 / 11 / ldm / help.asm next >
Encoding:
Assembly Source File  |  1989-08-18  |  11.2 KB  |  380 lines

  1. ;* ------------------------------------------------------- *
  2. ;*                        HELP.ASM                         *
  3. ;*                  Residentes Help-Tool                   *
  4. ;*             (c) 1989 Meik Stoll & TOOLBOX               *
  5. ;* ------------------------------------------------------- *
  6.  
  7.            BIOS SEGMENT AT 0
  8.              ORG 417h
  9.              shiftflag DB ?
  10.            BIOS ENDS
  11.  
  12.            CODE SEGMENT
  13.            ASSUME CS:CODE, DS:CODE, ES:BIOS, SS:CODE
  14.  
  15.            ORG 80h
  16.  
  17. cmdlen     DB ?
  18. cmd        DB ?
  19.            filename DB ?
  20.  
  21.            ORG 100h
  22.  
  23. dos        MACRO nummer
  24.              MOV AH,nummer
  25.              INT 21h
  26.            ENDM
  27.  
  28. print      MACRO text
  29.              MOV DX,OFFSET text
  30.              DOS 9
  31.            ENDM
  32.  
  33. ;* ------------------------------------------------------- *
  34.  
  35.            interrupt = 5h
  36.  
  37. main:      jmp begin
  38.  
  39.            card     db ?               ; 7 = Herc, sonst CGA
  40.            cardseg  dw ?               ; Segment Grafikkarte
  41.  
  42.            oldvec   dw ?,?             ;Alter PRTSC-Vektor
  43.  
  44.            busy     dw ?               ;Flag für beschäftigt
  45.  
  46.            handle   dw ?
  47.            filelen  dw ?               ;Länge der HELP-Datei
  48.  
  49.            suchwort db 80 dup (?)
  50.            laenge   dw ?
  51.  
  52.            spalte   db ?
  53.            zeile    db ?
  54.            ofs      dw ?
  55.  
  56.            msg      db 13,10,'HELP',13,10
  57.                     db '(c) 1989 Meik Stoll & TOOLBOX',13,10
  58.                     db 'Aufruf mit SHIFT + SHIFT + PRTSC'
  59.                     db 13,10,13,10,'$'
  60.  
  61.            errormsg db 'Aufruf von MS-DOS: '
  62.                     db 'HELP [Laufwerk:][Pfad]Dateiname'
  63.                     db 13,10,'$'
  64.  
  65.            msgerr   db 'Fehler!!!',13,10
  66.                     db 'HELP wurde nicht '
  67.                     db 'resident installiert!!!'
  68.                     db 13,10,'$'
  69.  
  70. begin:     print msg                   ; MSG drucken
  71.            cmp   cmdlen,0
  72.            jnz   ok1
  73.            jmp   fehler
  74. ok1:       call  loadfile
  75.            mov   ah,15                 ; Videomodus holen
  76.            int   10h
  77.            mov   card,al               ; mitsp. in card
  78.            cmp   al,7
  79.            je    herc
  80.            mov   cardseg,0b800h        ; CGA-Seg. setzen
  81.            jmp   skip
  82. herc:      mov   cardseg,0b000h        ; Herc.Seg.setzen
  83. skip:      mov   al,interrupt          ; Alte Interrupt-
  84.            dos   35h                   ; Adresse merken ...
  85.            mov   oldvec[0],bx
  86.            mov   oldvec[2],es
  87.            mov   al,interrupt          ; ... und neue setzen
  88.            mov   dx,offset new28h
  89.            dos   25h
  90.            mov   busy,0
  91.            mov   dx,offset prgend      ; Anz. Par. in DX
  92.            add   dx,filelen            ; Dateilänge dazu
  93.            mov   cl,4
  94.            shr   dx,cl
  95.            add   dx,3
  96.            mov   al,0                  ; Errorlevel=0
  97.            dos   31h                   ; TSR
  98. fehler:    print errormsg
  99.            mov   ax,4c01h
  100.            int   21h
  101.  
  102. loadfile   proc  near
  103.            mov   si,offset cmd         ; CR durch #0 ers.
  104.            dec   si
  105. lf1:       inc   si
  106.            cmp   byte ptr [si],13
  107.            jnz   lf1
  108.            mov   byte ptr [si],0
  109.  
  110.            mov   ax,3d00h              ; Datei öffnen
  111.            mov   dx,offset filename
  112.            int   21h
  113.            jc    error
  114.            mov   handle,ax
  115.  
  116.            mov   ax,4202h              ; Länge feststellen
  117.            mov   bx,handle
  118.            xor   cx,cx
  119.            xor   dx,dx
  120.            int   21h
  121.            jc    error
  122.            mov   filelen,ax
  123.  
  124.            mov   ax,4200h              ; Wieder auf 0 pos.
  125.            mov   bx,handle
  126.            xor   cx,cx
  127.            xor   dx,dx
  128.            int   21h
  129.            jc    error
  130.  
  131.            mov   bx,handle             ; Datei lesen
  132.            mov   cx,filelen
  133.            mov   dx,offset datei
  134.            dos   3fh
  135.            jc    error
  136.  
  137.            mov   bx,handle             ; Datei schließen
  138.            dos   3eh
  139.            jc    error
  140.  
  141.            ret
  142. loadfile   endp
  143.  
  144. error:     print msgerr
  145.            mov   ax,4c01h
  146.            int   21h
  147.  
  148. savescreen proc  near
  149.            mov   cx,4000               ; 4000 Zeichen
  150.            mov   ax,cs:cardseg         ; Card-Segment in DS
  151.            mov   ds,ax
  152.            mov   ax,cs                 ; Puffer-Seg. in ES
  153.            mov   es,ax
  154.            xor   si,si                 ; Start bei Offset 0
  155.            mov   di,offset buffer      ; Start bei
  156.                                        ; Offset. v. Buffer
  157.            cld                         ; nach oben kopieren
  158.            repz  movsb                 ; und los geht's ...
  159.            ret
  160. savescreen endp
  161.  
  162. loadscreen proc  near
  163.            mov   cx,4000               ; 4000 Zeichen
  164.            mov   ax,cs                 ; Puffer-Seg. in DS
  165.            mov   ds,ax
  166.            mov   ax,cs:cardseg         ; Card-Seg. in ES
  167.            mov   es,ax
  168.            mov   si,offset buffer      ; Kopierstart bei
  169.                                        ; Offset von Buffer
  170.            xor   di,di                 ; Start bei Offset 0
  171.            cld                         ; nach oben kopieren
  172.            repz  movsb                 ; und los geht's
  173.            ret
  174. loadscreen endp
  175.  
  176. search     proc  near                  ; Suchwort suchen
  177.            mov   ax,cs
  178.            mov   ds,ax
  179.            mov   si,offset suchwort
  180.            mov   di,offset datei
  181.            xor   cx,cx
  182. search2:   mov   al,[di]
  183.            cmp   al,26
  184.            jz    eof
  185.            cmp   al,[si]               ; Buchstabe mit
  186.            jz    search1               ; Suchwort vergl.
  187.            xor   al,32                 ; in UPPER/LOWER-
  188.                                        ; Case umwandeln
  189.            cmp   al,[si]               ; und vergleichen
  190.            jz    search1
  191.            inc   di
  192.            xor   cx,cx
  193.            mov   si,offset suchwort
  194.            jmp   short search2
  195.  
  196. eof:       mov   ax,1
  197.            ret
  198.  
  199. search1:   inc   cx
  200.            cmp   cx,laenge
  201.            jz    found
  202.            inc   si
  203.            inc   di
  204.            jmp   short search2
  205.  
  206. found:     add   di,3
  207.            mov   bx,di
  208.            xor   ax,ax
  209.            ret
  210. search     endp
  211.  
  212. help       proc  near
  213.            mov   cs:suchwort,'#'       ; '#' als Anfang
  214.                                        ; für Suchwort
  215.            mov   ah,3                  ; Cursorpos.
  216.            mov   bh,0                  ; feststellen
  217.            int   10h
  218.            mov   cs:zeile,dh
  219.            mov   cs:spalte,dl
  220.            mov   al,cs:zeile           ; Offset des
  221.            xor   ah,ah                 ; Cursors berechnen
  222.            mov   cx,160
  223.            mul   cx
  224.            mov   bl,cs:spalte
  225.            xor   bh,bh
  226.            shl   bx,1
  227.            add   ax,bx
  228.            mov   cs:ofs,ax
  229.            mov   ax,cs:cardseg
  230.            mov   es,ax
  231.            mov   bx,cs:ofs
  232.  
  233. scan:      dec   bx                    ; Suchwort festst.
  234.            dec   bx
  235.            cmp   byte ptr es:[bx],'A'
  236.            jl    no
  237.            cmp   byte ptr es:[bx],'z'
  238.            jg    no
  239.            cmp   byte ptr es:[bx],'Z'
  240.            jle   scan
  241.            cmp   byte ptr es:[bx],'a'
  242.            jge   scan
  243.  
  244. no:        inc   bx                    ; es:[bx]=bildschirm
  245.            inc   bx
  246.            mov   bp,offset suchwort+1  ; ds:[bp]=
  247.            mov   ax,cs                 ; suchwort im
  248.            mov   ds,ax                 ; speicher
  249.  
  250. no2:       mov   ax,es:[bx]            ; von bildschirm in
  251.            mov   ds:[bp],ax            ; speicher kopieren
  252.            inc   bx
  253.            inc   bx
  254.            inc   bp
  255.            cmp   byte ptr es:[bx],'A'
  256.            jl    no1
  257.            cmp   byte ptr es:[bx],'z'
  258.            jg    no1
  259.            cmp   byte ptr es:[bx],'Z'
  260.            jle   no2
  261.            cmp   byte ptr es:[bx],'a'
  262.            jge   no2
  263.  
  264. no1:       mov   byte ptr ds:[bp],'#'  ; #=Ende
  265.                                        ; des Suchworts
  266.            dec   bp
  267.            sub   bp,offset suchwort-2
  268.            mov   cs:laenge,bp          ; Länge des
  269.                                        ; Suchworts speichern
  270.  
  271.            call  search                ; Suchwort suchen
  272.            cmp   ax,1
  273.            jz    notfound
  274.  
  275.            push  bx                    ; Textstelle sichern
  276.            mov   ah,15                 ; Bildschirm löschen
  277.            int   10h
  278.            xor   ah,ah
  279.            int   10h
  280.            pop   bx                    ; Textstelle wieder
  281.                                        ; holen
  282.  
  283. no21:      mov   al,[bx]               ; Gefundenen Text
  284.            mov   ah,0eh                ; ausgeben
  285.            push  bx
  286.            mov   bx,0
  287.            int   10h
  288.            pop   bx
  289.            inc   bx
  290.            cmp   word ptr [bx],'$$'    ; Ende?
  291.            jnz   no21
  292.  
  293.            mov   cx,80                 ; 80 mal '-' ausgeben
  294. no6:       push  cx
  295.            mov   ah,0eh
  296.            mov   al,196
  297.            mov   bx,0
  298.            int   10h
  299.            pop   cx
  300.            loop  no6
  301.  
  302.            mov   ah,0                  ; Auf Tastendruck
  303.            int   16h                   ; warten
  304.  
  305. no30:      mov   bx,0                  ; alte Cursorpos.
  306.            mov   ah,2                  ; setzen
  307.            mov   dh,cs:zeile
  308.            mov   dl,cs:spalte
  309.            int   10h
  310.  
  311. helpback:  ret
  312.  
  313. notfound:  mov   ah,0eh                ; BELL, wenn nicht
  314.            mov   al,7                  ; gefunden
  315.            mov   bx,0
  316.            int   10h
  317.            jmp   short no30
  318. help       endp
  319.  
  320. new28h     proc  far
  321.            pushf                       ; Alles sichern
  322.            push  ax
  323.            push  bx
  324.            push  cx
  325.            push  dx
  326.            push  si
  327.            push  di
  328.            push  ds
  329.            push  es
  330.            push  bp
  331.            xor   ax,ax
  332.            mov   es,ax
  333.            mov   al,es:shiftflag       ; Test, ob beide
  334.            and   al,3                  ; SHIFT-Tasten
  335.            cmp   al,3                  ; gedrückt sind
  336.            jnz   back
  337.            cmp   cs:busy,1
  338.            jz    back
  339.            mov   cs:busy,1
  340.            call  savescreen
  341.            call  help
  342.            call  loadscreen
  343.            pop   bp                    ; alles wieder
  344.            pop   es                    ; holen
  345.            pop   ds
  346.            pop   di
  347.            pop   si
  348.            pop   dx
  349.            pop   cx
  350.            pop   bx
  351.            pop   ax
  352.            popf
  353.            mov   cs:busy,0             ; und zurück
  354.            iret
  355. back:      pop   bp
  356.            pop   es                    ; normale
  357.            pop   ds                    ; PRTSC-Routine
  358.            pop   di
  359.            pop   si
  360.            pop   dx
  361.            pop   cx
  362.            pop   bx
  363.            pop   ax
  364.            popf
  365.            jmp   dword ptr cs:[oldvec]
  366. new28h     endp
  367.  
  368.  
  369. buffer     db    4096 dup(?)           ; Screen-Buffer
  370.  
  371. prgend:
  372.  
  373. datei:                         ; Hier wird die HELP-Datei
  374.                                ; abgelegt.
  375. code       ends
  376.            end   main
  377.  
  378. ;* ------------------------------------------------------- *
  379. ;*                  Ende von HELP.ASM                      *
  380.