home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / assemblr / library / asm_wiz / example.asm < prev    next >
Assembly Source File  |  1991-02-11  |  15KB  |  286 lines

  1. comment $
  2.  
  3.    +----------------------------------------------------------------------+
  4.    |                                                                      |
  5.    |           ASMWIZ  Copyright (c) 1990  Thomas G. Hanlin III           |
  6.    |                                                                      |
  7.    |                          ASMWIZ Demo Program                         |
  8.    |                                                                      |
  9.    |              assembled with the excellent OPTASM by SLR              |
  10.    |                                                                      |
  11.    +----------------------------------------------------------------------+
  12.  
  13.    The code here has been designed to be easily understandable and is not as
  14.    efficient as the coding used in the actual library.
  15. $
  16.  
  17.  
  18. ; the use of a dummy stack segment here eliminates the meaningless error
  19. ; message from LINK about there being no stack defined.
  20.  
  21. Sseg          segment byte stack 'prog'     ; dummy stack segment
  22. Sseg          ends
  23.  
  24. Cseg          segment byte public 'prog'
  25.                                                         assume cs:Cseg, ds:Cseg, ss:Sseg
  26.  
  27.               org            100h
  28.  
  29.  
  30.  
  31. extrn  MV_INIT:NEAR, MV_LOCATE:NEAR, MV_MODE:NEAR, MV_GETMODE:NEAR
  32. extrn  MV_POPUP:NEAR, MV_STROUT:NEAR, MV_HIDECURSOR:NEAR
  33. extrn  MV_SHOWCURSOR:NEAR, MV_STROUT:NEAR, MV_INSLINE:NEAR, MV_DELLINE:NEAR
  34. extrn  MV_INSCHR:NEAR, MV_DELCHR:NEAR, MV_COLOR:NEAR, MV_CLS:NEAR
  35. extrn  MV_FIXCOLOR:NEAR, MD_TICK:NEAR, MI_GETSCREEN:NEAR, MI_PARSE:NEAR
  36. extrn  S0_LENGTH:NEAR, S0_UPCASE:NEAR, ME_BLOAD:NEAR
  37.  
  38.  
  39.  
  40. MAIN          proc           far       ; ASMWIZ example program
  41.               call           Initialize     ; initialize screen and colors
  42.               call           ShowWelcome    ; display welcome message
  43.               call           SlideWelcome   ; slide welcome message left
  44.               call           ShowWindow     ; display pop-up window w/ text
  45.               call           WaitOnKey      ; display "press any" and wait
  46.               call           Picture        ; display picture (if CGA/EGA/VGA)
  47.               call           Terminate      ; restore original screen mode, etc
  48.               mov            ax,4C00h       ;
  49.               int            21h            ; exit program
  50. MAIN          endp                     ; ASMWIZ example program
  51.  
  52.  
  53.  
  54. Initialize    proc           near      ; initialize the screen
  55.               call           MV_GETMODE     ; get current screen mode
  56.               mov            OldMode,al     ; save it
  57.               call           MV_INIT        ; initialize display routines
  58.               mov            al,3           ; mode 3: 80x25 color text
  59.               call           MV_MODE        ; set display mode
  60.               call           MV_HIDECURSOR  ; turn off the cursor
  61.               mov            si,0080h       ; pointer to the command line
  62.               lea            di,FileBuf     ; pointer to filename buffer
  63.               lea            bx,OptBuf      ; pointer to option buffer
  64.               mov            al,"/"         ; use normal DOS switch character
  65.               call           MI_PARSE       ; parse the command line
  66.               or             ah,ah          ; is there an option?
  67.               jz             CheckCRT       ;   no, go check the CRT type
  68.               mov            si,bx          ; pointer to first option
  69.               mov            di,bx          ;
  70.               call           S0_UPCASE      ; convert it to uppercase
  71.               cmp byte ptr   [bx],"B"       ; is it /B for monochrome mode?
  72.               jne            CheckCRT       ;   no, check CRT type
  73.               mov            al,1           ; set to mono
  74.               jmp            SetCRT         ;   go set type
  75. CheckCRT:     call           MI_GETSCREEN   ; see what the screen type is
  76. SetCRT:       call           MV_FIXCOLOR    ; set the color handler to suit
  77.               mov            al,2Fh         ; bright white on green
  78.               call           MV_COLOR       ; set text color
  79.               call           MV_CLS         ; clear screen to new color
  80.               ret                           ;
  81. Initialize    endp                     ; initialize the screen
  82.  
  83.  
  84.  
  85. ShowWelcome   proc           near      ; display welcome message
  86.               mov            dx,0125h       ; row 1, column 37
  87.               call           MV_LOCATE      ; set cursor location
  88.               lea            dx,WelcomeMsg  ; ptr to "Welcome"
  89.               call           MV_STROUT      ; display it
  90.               mov            cx,8           ;
  91. Welcome1:     call           MV_INSLINE     ; scroll it down
  92.               push           cx             ;
  93.               mov            cx,1           ;
  94.               call           MD_TICK        ; delay an 18th of a second
  95.               pop            cx             ;
  96.               loop           Welcome1       ; ...nine times
  97.               mov            dx,0B25h       ; row 11, column 37
  98.               call           MV_LOCATE      ; set cursor location
  99.               lea            dx,ToTheMsg    ; ptr to "to the"
  100.               call           MV_STROUT      ; display it
  101.               mov            dx,0D01h       ; row 13, column 1
  102.               call           MV_LOCATE      ; set cursor location
  103.               lea            dx,AsmMsg      ; ptr to "ASM" <cr>
  104.               call           MV_STROUT      ; display it
  105.               mov            cx,37          ;
  106. Welcome2:     call           MV_INSCHR      ; scroll it right
  107.               push           cx             ;
  108.               mov            cx,1           ;
  109.               call           MD_TICK        ; delay an 18th of a second
  110.               pop            cx             ;
  111.               loop           Welcome2       ; ...37 times
  112.               mov            dx,0D4Dh       ; row 13, column 73
  113.               call           MV_LOCATE      ;
  114.               lea            dx,WizMsg      ; ptr to "WIZ"
  115.               call           MV_STROUT      ; display it
  116.               mov            dx,0D29h       ; row 13, column 41
  117.               call           MV_LOCATE      ; set cursor location
  118.               mov            cx,36          ;
  119. Welcome3:     call           MV_DELCHR      ; scroll it left
  120.               push           cx             ;
  121.               mov            cx,1           ;
  122.               call           MD_TICK        ; delay an 18th of a second
  123.               pop            cx             ;
  124.               loop           Welcome3       ; ...36 times
  125.               mov            dx,1925h       ; row 25, column 37
  126.               call           MV_LOCATE      ; set cursor location
  127.               lea            dx,LibraryMsg  ; ptr to "Library"
  128.               call           MV_STROUT      ; display it
  129.               mov            dx,0E01h       ; row 14, column 1
  130.               call           MV_LOCATE      ; set cursor location
  131.               mov            cx,10          ;
  132. Welcome4:     call           MV_DELLINE     ; scroll it up
  133.               push           cx             ;
  134.               mov            cx,1           ;
  135.               call           MD_TICK        ; delay an 18th of a second
  136.               pop            cx             ;
  137.               loop           Welcome4       ; ...10 times
  138.               ret                           ;
  139. ShowWelcome   endp                     ; display welcome message
  140.  
  141.  
  142.  
  143. SlideWelcome  proc           near      ; slide welcome message left
  144.               mov            dx,0901h       ; row 9, column 1
  145.               mov            ax,4           ;
  146. ScrollAll:    mov            cx,20          ; columns to scroll
  147. LineLeft:     call           MV_LOCATE      ; set cursor position
  148.               call           MV_DELCHR      ; scroll it left
  149.               loop           LineLeft       ;   go for all columns
  150.               add            dh,2           ; move to next line
  151.               dec            ax             ; done yet?
  152.               jnz            ScrollAll      ;   no, go for next row
  153.               ret                           ;
  154. SlideWelcome  endp                     ; slide welcome message left
  155.  
  156.  
  157.  
  158. ShowWindow    proc           near      ; display pop-up window w/ text
  159.               lea            dx,ScrWindow   ;
  160.               call           MV_POPUP       ; pop up intro window
  161.               lea            si,WindowText  ; pointer to window text
  162.               mov            dx,word ptr ScrWindow
  163.               xchg           dl,dh          ;
  164.               add            dx,0102h       ; starting text position
  165. ShowText:     call           MV_LOCATE      ; set cursor position
  166.               call           S0_LENGTH      ; determine length of text
  167.               jcxz           ShoWindowXit   ;   if zero, we're done-- go exit
  168.               mov            al,[si]        ; get text color
  169.               call           MV_COLOR       ; set it
  170.               inc            si             ; skip over color to actual text
  171.               xchg           dx,si          ;
  172.               call           MV_STROUT      ; display the text
  173.               xchg           dx,si          ;
  174.               add            si,cx          ; move to next text line
  175.               inc            dh             ; move to next screen line
  176.               jmp            ShowText       ;   go for all text
  177. ShoWindowXit: ret                           ;
  178. ShowWindow    endp                     ; display pop-up window w/ text
  179.  
  180.  
  181.  
  182. WaitOnKey     proc           near      ; display "press any key", wait for it
  183.               mov            dx,191Bh       ; row 25, column 26
  184.               call           MV_LOCATE      ; set cursor location
  185.               mov            al,74h         ; red on white
  186.               call           MV_COLOR       ;
  187.               lea            dx,PressAnyMsg ; ptr to "Press any key..."
  188.               call           MV_STROUT      ; display it
  189.               mov            al,07h         ; normal video
  190.               call           MV_COLOR       ;
  191.               mov            ah,7           ; get a key
  192.               int            21h            ;
  193.               or             al,al          ; is it extended?
  194.               jnz            WaitOnKeyXit   ;   no, go exit
  195.               mov            ah,7           ; get the rest of the key
  196.               int            21h            ;
  197. WaitOnKeyXit: ret                           ;
  198. WaitOnKey     endp                     ; display "press any key", wait for it
  199.  
  200.  
  201.  
  202. Picture       proc           near      ; display picture (if CGA/EGA/VGA)
  203.               call           MI_GETSCREEN   ; get active display type
  204.               or             al,al          ; color display?
  205.               jnz            PictureXit     ;   no, go exit
  206.               cmp            ah,3           ; CGA?
  207.               je             CGApic         ;   yep, go do CGA picture
  208.               cmp            ah,4           ; EGA?
  209.               je             EGApic         ;   yep, go do EGA picture
  210.               cmp            ah,6           ; VGA?
  211.               jne            PictureXit     ;   no, go exit
  212. EGApic:       mov            al,16          ; EGA/VGA 640x350 graphics mode
  213.               call           MV_MODE        ; set the screen mode
  214.               lea            dx,EGAfile     ; EGA file name
  215.               call           ME_BLOAD       ; load it onto the screen
  216.               jmp            WaitForKey     ;   go wait for a keypress
  217. CGApic:       mov            al,6           ; CGA 640x200 graphics mode
  218.               call           MV_MODE        ; set the screen mode
  219.               lea            dx,CGAfile     ; CGA file name
  220.               call           ME_BLOAD       ; load it onto the screen
  221. WaitForKey:   mov            ah,7           ; get a key
  222.               int            21h            ;
  223.               or             al,al          ; is it extended?
  224.               jnz            PictureXit     ;   no, go exit
  225.               mov            ah,7           ; get the rest of the key
  226.               int            21h            ;
  227.               mov            al,3           ; text mode
  228.               call           MV_MODE        ; set the video mode
  229. PictureXit:   ret                           ;
  230. Picture       endp                     ; display picture (if CGA/EGA/VGA)
  231.  
  232.  
  233.  
  234. Terminate     proc           near      ; restore original screen mode, etc
  235.               mov            al,OldMode     ; get old screen mode
  236.               call           MV_MODE        ; set video mode
  237.               call           MV_SHOWCURSOR  ; restore the cursor
  238.               ret                           ;
  239. Terminate     endp                     ; restore original screen mode, etc
  240.  
  241.  
  242.  
  243. WelcomeMsg    db "Welcome",0
  244. ToTheMsg      db "to the",0
  245. AsmMsg        db "ASM",13,0
  246. WizMsg        db "WIZ",0
  247. LibraryMsg    db "Library",0
  248. PressAnyMsg   db "Press any key to continue",0
  249.  
  250. ScrWindow     db 2,40,23,79        ; window coordinates
  251.               db 1,4Eh             ; frame type and color
  252.               dw offset ScrTitle   ; pointer to title
  253. ScrTitle      db "The Assembly Wizard's Library",0   ; window title
  254.  
  255. WindowText    db 41h,"Since you're evidently an assembly  ",0
  256.               db 41h,"language programmer and may be      ",0
  257.               db 41h,"considered reasonably sophisticated,",0
  258.               db 41h,"I'll skip the sales pitch here and  ",0
  259.               db 41h,"just list a few of the capabilities ",0
  260.               db 41h,"of the ASMWIZ library:              ",0
  261.               db 41h,0
  262.               db 70h,"DOS, BIOS, and machine-level display",0
  263.               db 30h,"Save/restore any part of the display",0
  264.               db 70h,"Base conversions (integer and long) ",0
  265.               db 30h,"Long integer math support           ",0
  266.               db 70h,"Delay and countdown services        ",0
  267.               db 30h,"Pseudo-random number generation     ",0
  268.               db 70h,"File matching, command-line parsing ",0
  269.               db 30h,"Environment scanning                ",0
  270.               db 70h,"Handling of Break and Control-C     ",0
  271.               db 30h,"String functions                    ",0
  272.               db 70h,"Mouse support and sound generation  ",0
  273.               db 30h,"Checksum and CRC calculation        ",0
  274.               db 70h,"International time and date support ",0,0
  275.  
  276. FileBuf   db 80 dup(?)
  277. OptBuf    db 80 dup(?)
  278.  
  279. OldMode   db 3
  280.  
  281. CGAfile   db "EXAMPLE.CGA",0
  282. EGAfile   db "EXAMPLE.EGA",0
  283.  
  284. Cseg          ends
  285.               end            MAIN
  286.