home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / assemblr / library / sban12 / sbanner.asm < prev    next >
Assembly Source File  |  1994-04-11  |  8KB  |  187 lines

  1.         .model  small
  2.  
  3. Code    Segment Byte
  4.         Assume  CS: Code, DS: Code
  5.  
  6.         ORG     100H
  7.  
  8. Start:
  9.         jmp     LoadProg
  10.  
  11. ; Data
  12.  
  13. Banner  DB      255 DUP(0)              ; make buffer large
  14. Attr    DB      79                      ; yellow on red
  15.  
  16. Tick    DB      9                       ; display every 9 ticks
  17. Old_1C  DW      ?,?                     ; location of old 1C interrupt
  18. Old_2F  DW      ?,?                     ; location of old 2F interrupt
  19.  
  20. Int2F   Proc                            ;
  21.         cmp     AX, 0DB00h              ; installation check?
  22.         jne     Check1C                 ; no, check for 1C request
  23.         dec     AL                      ; successful
  24.         push    CS                      ; put code segment
  25.         pop     ES                      ;  in ES
  26.         mov     DI, OFFSET Banner       ; put offset to banner text in DI
  27.         iret                            ;
  28. Check1C:
  29.         cmp     AX, 0DB1Ch              ; do they want the old 1C location?
  30.         jne     Check2F                 ; no, check for 2F request
  31.         mov     AL, 0FFh                ; successful
  32.         mov     BX, CS: [Old_1C]        ; put offset in BX
  33.         mov     ES, CS: [Old_1C+2]      ; put segment in ES
  34.         iret                            ;
  35. Check2F:
  36.         cmp     AX, 0DB2Fh              ; do they want the old 2F location?
  37.         jne     CallOld2F               ; no, call the old 2F interrupt
  38.         mov     AL, 0FFh                ; successful
  39.         mov     BX, CS: [Old_2F]        ; put offset in BX
  40.         mov     ES, CS: [Old_2F+2]      ; put segment in ES
  41.         iret                            ;
  42. CallOld2F:
  43.         jmp     DWord Ptr CS: Old_2F    ;
  44. Int2F   EndP
  45.  
  46. Int1C   Proc
  47.         pushf                           ;
  48.         call    DWord Ptr CS: Old_1C    ; call old 1C interrupt
  49.         dec     Byte Ptr CS: Tick       ; one less tick
  50.         jnz     Done_1C                 ; if not zero, quit
  51.         mov     Byte Ptr CS: Tick, 9    ; make it 9 more ticks
  52.         call    DisplayString           ;  and display the string
  53. Done_1C:
  54.         iret                            ;
  55. Int1C   EndP
  56.  
  57. DisplayString Proc
  58.         push    AX                      ;
  59.         push    BX                      ;
  60.         push    CX                      ;
  61.         push    DX                      ;
  62.         push    DS                      ;
  63.         push    ES                      ;
  64.         push    DI                      ;
  65.         push    SI                      ;
  66.         push    BP                      ;
  67.  
  68.         xor     AX, AX                  ;
  69.         mov     ES, AX                  ;
  70.         mov     AX, 0B800h              ; use color video memory
  71.         cmp     Byte Ptr ES: [0449h], 3 ; are we in text video mode?
  72.         je      Display_Text            ; no, skip displaying text
  73.         mov     AX, 0B000h              ; use mono video memory
  74.         cmp     Byte Ptr ES: [0449h], 7 ; are we in text video mode?
  75.         jne     Display_Done            ; no, exit
  76.  
  77. Display_Text:
  78.         mov     ES, AX                  ; put video segment in ES
  79.         xor     DI, DI                  ; point to top left corner
  80.         xor     BX, BX                  ; clear pointer
  81.         mov     AH, Byte Ptr CS: Attr   ; get color attribute
  82. PutWord:
  83.         mov     AL, Byte Ptr CS: Banner[BX] ; get a charactor
  84.         cmp     AL, 13                  ; is it a carriage return?
  85.         je      Display_Done            ; yes, exit
  86.         stosw                           ; write it to the screen
  87.         inc     BX                      ; point to next charactor
  88.         jmp     PutWord                 ; do it all again
  89. Display_Done:
  90.         pop     BP                      ;
  91.         pop     SI                      ;
  92.         pop     DI                      ;
  93.         pop     ES                      ;
  94.         pop     DS                      ;
  95.         pop     DX                      ;
  96.         pop     CX                      ;
  97.         pop     BX                      ;
  98.         pop     AX                      ;
  99.         ret                             ;
  100. DisplayString EndP
  101.  
  102. ;===========================[  Transient Code  ]===============================
  103.  
  104. Copyright DB    'Screen Banner 1.02 ■ TSR to display a banner',13,10
  105.         DB      '(c) Copyright 1993,94 Product Identification'
  106.         DB      ' and Processing Systems, Inc.',13,10
  107.         DB      'Written by Dave Navarro, Jr.',13,10,10,'$'
  108. Success DB      'Screen Banner successfully installed.',13,10,'$'
  109. ErrMsg1 DB      'Screen Banner already installed.',13,10
  110.         DB      'Banner changed to new text',13,10,'$'
  111. ErrMsg2 DB      'Usage:  SBANNER Text_To_Display',13,10,13,10
  112.         DB      'Screen Banner not installed.',13,10,'$'
  113.  
  114. LoadProg Proc
  115.         mov     DX, OFFSET Copyright    ; point to copyright message
  116.         mov     AH, 9                   ;
  117.         int     21h                     ; display it
  118.         mov     AL, DS: [0080h]         ; get length of command line
  119.         or      AL, AL                  ; anything there?
  120.         jnz     CheckInstall            ; yes, check for previous install
  121.         mov     DX, OFFSET ErrMsg2      ; give them the syntax
  122.         mov     AH, 9                   ;
  123.         int     21h                     ; display it
  124.         jmp     Exit                    ; and exit
  125. CheckInstall:
  126.         mov     AX, 0DB00h              ; see if we're already installed
  127.         int     2Fh                     ;
  128.         cmp     AL, 0FFh                ; are we?
  129.         jne     DoInstall               ; no, do the instalation.
  130.         cli                             ;
  131.         mov     SI, 0082h               ; point to start of command line
  132. GetByte:
  133.         lodsb                           ; get a byte
  134.         stosb                           ; write it to buffer
  135.         cmp     AL, 13                  ; are we at the end?
  136.         jne     GetByte                 ; no, keep moving text
  137.  
  138.         sti                             ;
  139.         mov     DX, OFFSET ErrMsg1      ; let them know about the new text
  140.         mov     AH, 9                   ;
  141.         int     21h                     ; display it
  142.         jmp     Exit                    ; and exit
  143. DoInstall:
  144.         mov     SI, 0082h               ; point to start of command line
  145.         mov     DI, OFFSET Banner       ; and text buffer area
  146.         push    DS                      ;
  147.         pop     ES                      ;
  148. CopyByte:
  149.         lodsb                           ; get a byte
  150.         stosb                           ; write it to buffer
  151.         cmp     AL, 13                  ; are we at the end?
  152.         jne     CopyByte                ; no, keep moving text
  153.  
  154.         mov     ES, DS: [002Ch]         ; point to environment segment
  155.         mov     AH, 49h                 ;
  156.         int     21h                     ; release it
  157.  
  158.         mov     AX, 352Fh               ; get interrupt 2F location
  159.         int     21h                     ;
  160.         mov     CS: [Old_2F], BX        ; save offset
  161.         mov     CS: [Old_2F+2], ES      ; save segment
  162.         mov     DX, OFFSET Int2F        ; point to our interrupt handler
  163.         mov     AX, 252Fh               ;
  164.         int     21h                     ; install it
  165.  
  166.         mov     AX, 351Ch               ; get interrupt 1C location
  167.         int     21h                     ;
  168.         mov     CS: [Old_1C], BX        ; save offset
  169.         mov     CS: [Old_1C+2], ES      ; save segment
  170.         mov     DX, OFFSET Int1C        ; point to our interrupt handler
  171.         mov     AX, 251Ch               ;
  172.         int     21h                     ; install it
  173.  
  174.         mov     DX, OFFSET Success      ; let 'em know we're done
  175.         mov     AH, 9                   ;
  176.         int     21h                     ; display it
  177.  
  178.         mov     DX, OFFSET Copyright    ; point to transient code
  179.         int     27h                     ; release it
  180.  
  181. Exit:
  182.         mov     AX, 4C00h               ; exit with an error level of zero
  183.         int     21h                     ;
  184. LoadProg EndP
  185. Code    EndS
  186.         End     Start
  187.