home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / asywiz / example.asm < prev    next >
Encoding:
Assembly Source File  |  1994-11-03  |  14.0 KB  |  278 lines

  1. comment $
  2.  
  3.    +----------------------------------------------------------------------+
  4.    |                                                                      |
  5.    |        AsmWiz  Copyright (c) 1990-1994  Thomas G. Hanlin III         |
  6.    |                                                                      |
  7.    |                          AsmWiz Demo Program                         |
  8.    |                                                                      |
  9.    |                        assembled with MASM 6.0                       |
  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.  
  26.               assume cs:Cseg, ds:Cseg, ss:Sseg
  27.  
  28.               org            100h
  29.  
  30.  
  31.  
  32. extrn  BKO_GETKEY:near, MD_DONE:near, MD_DELAY:near, MD_INIT:near
  33. extrn  MV_INIT:near, MV_LOCATE:near, MV_MODE:near, MV_GETMODE:near
  34. extrn  MV_POPUP:near, MV_STROUT:near, MV_HIDECURSOR:near
  35. extrn  MV_SHOWCURSOR:near, MV_STROUT:near, MV_INSLINE:near, MV_DELLINE:near
  36. extrn  MV_INSCHR:near, MV_DELCHR:near, MV_COLOR:near, MV_CLS:near
  37. extrn  MV_FIXCOLOR:near, MV_FRAME:near, MI_GETSCREEN:near, MI_PARSE:near
  38. extrn  S0_LENGTH:near, S0_UPCASES:near
  39.  
  40.  
  41.  
  42. MAIN          proc           far       ; AsmWiz example program
  43.               call           Initialize     ; initialize screen and colors
  44.               call           ShowWelcome    ; display welcome message
  45.               call           SlideWelcome   ; slide welcome message left
  46.               call           ShowWindow     ; display pop-up window w/ text
  47.               call           ShowCopyright  ; display copyright message
  48.               call           WaitOnKey      ; display "press any" and wait
  49.               call           Terminate      ; restore original screen mode, etc
  50.               mov            ax,4C00h       ;
  51.               int            21h            ; exit program
  52. MAIN          endp                     ; AsmWiz example program
  53.  
  54.  
  55.  
  56. Initialize    proc           near      ; initialize the screen
  57.               call           MV_GETMODE     ; get current screen mode
  58.               mov            OldMode,al     ; save it
  59.               call           MV_INIT        ; initialize display routines
  60.               mov            al,3           ; mode 3: 80x25 color text
  61.               call           MV_MODE        ; set display mode
  62.               call           MV_HIDECURSOR  ; turn off the cursor
  63.               mov            si,0080h       ; pointer to the command line
  64.               lea            di,FileBuf     ; pointer to filename buffer
  65.               lea            bx,OptBuf      ; pointer to option buffer
  66.               mov            al,"/"         ; use normal DOS switch character
  67.               call           MI_PARSE       ; parse the command line
  68.               or             ah,ah          ; is there an option?
  69.               jz             CheckCRT       ;   no, go check the CRT type
  70.               mov            si,bx          ; pointer to first option
  71.               mov            di,bx          ;
  72.               call           S0_UPCASES     ; convert it to uppercase
  73.               cmp byte ptr   [bx],"B"       ; is it /B for monochrome mode?
  74.               jne            CheckCRT       ;   no, check CRT type
  75.               mov            al,1           ; set to mono
  76.               jmp            SetCRT         ;   go set type
  77. CheckCRT:     call           MI_GETSCREEN   ; see what the screen type is
  78. SetCRT:       call           MV_FIXCOLOR    ; set the color handler to suit
  79.               mov            al,1Fh         ; bright white on blue
  80.               call           MV_COLOR       ; set text color
  81.               call           MV_CLS         ; clear screen to new color
  82.               call           MD_INIT        ; initialize hi-res timer system
  83.               ret                           ;
  84. Initialize    endp                     ; initialize the screen
  85.  
  86.  
  87.  
  88. ShowWelcome   proc           near      ; display welcome message
  89.               mov            dx,0125h       ; row 1, column 37
  90.               call           MV_LOCATE      ; set cursor location
  91.               lea            dx,WelcomeMsg  ; ptr to "Welcome"
  92.               call           MV_STROUT      ; display it
  93.               mov            cx,8           ;
  94. Welcome1:     call           MV_INSLINE     ; scroll it down
  95.               push           cx             ;
  96.               mov            cx,4           ;
  97.               call           MD_DELAY       ; delay 4/100ths of a second
  98.               pop            cx             ;
  99.               loop           Welcome1       ; ...nine times
  100.               mov            dx,0B25h       ; row 11, column 37
  101.               call           MV_LOCATE      ; set cursor location
  102.               lea            dx,ToTheMsg    ; ptr to "to the"
  103.               call           MV_STROUT      ; display it
  104.               mov            dx,0D01h       ; row 13, column 1
  105.               call           MV_LOCATE      ; set cursor location
  106.               lea            dx,AsmMsg      ; ptr to "Asm" <cr>
  107.               call           MV_STROUT      ; display it
  108.               mov            cx,37          ;
  109. Welcome2:     call           MV_INSCHR      ; scroll it right
  110.               push           cx             ;
  111.               mov            cx,2           ;
  112.               call           MD_DELAY       ; delay 2/100ths of a second
  113.               pop            cx             ;
  114.               loop           Welcome2       ; ...37 times
  115.               mov            dx,0D4Dh       ; row 13, column 73
  116.               call           MV_LOCATE      ;
  117.               lea            dx,WizMsg      ; ptr to "Wiz"
  118.               call           MV_STROUT      ; display it
  119.               mov            dx,0D29h       ; row 13, column 41
  120.               call           MV_LOCATE      ; set cursor location
  121.               mov            cx,36          ;
  122. Welcome3:     call           MV_DELCHR      ; scroll it left
  123.               push           cx             ;
  124.               mov            cx,2           ;
  125.               call           MD_DELAY       ; delay 2/100ths of a second
  126.               pop            cx             ;
  127.               loop           Welcome3       ; ...36 times
  128.               mov            dx,1925h       ; row 25, column 37
  129.               call           MV_LOCATE      ; set cursor location
  130.               lea            dx,LibraryMsg  ; ptr to "Library"
  131.               call           MV_STROUT      ; display it
  132.               mov            dx,0E01h       ; row 14, column 1
  133.               call           MV_LOCATE      ; set cursor location
  134.               mov            cx,10          ;
  135. Welcome4:     call           MV_DELLINE     ; scroll it up
  136.               push           cx             ;
  137.               mov            cx,4           ;
  138.               call           MD_DELAY       ; delay 4/100ths of a second
  139.               pop            cx             ;
  140.               loop           Welcome4       ; ...10 times
  141.               mov            cx,200         ; delay 200/100ths of a second
  142.               call           MD_DELAY       ;
  143.               ret                           ;
  144. ShowWelcome   endp                     ; display welcome message
  145.  
  146.  
  147.  
  148. SlideWelcome  proc           near      ; slide welcome message left
  149.               mov            dx,0901h       ; row 9, column 1
  150.               mov            ax,4           ;
  151. ScrollAll:    mov            cx,20          ; columns to scroll
  152. LineLeft:     call           MV_LOCATE      ; set cursor position
  153.               call           MV_DELCHR      ; scroll it left
  154.               loop           LineLeft       ;   go for all columns
  155.               add            dh,2           ; move to next line
  156.               dec            ax             ; done yet?
  157.               jnz            ScrollAll      ;   no, go for next row
  158.               mov            al,15h         ; magenta on white
  159.               call           MV_COLOR       ; set text color
  160.               mov            cx,070Eh       ; upper left row, col
  161.               mov            dx,111Ah       ; lower right row, col
  162.               mov            si,-9          ; solid block frame
  163.               mov            ax,4           ; frame loop count
  164. WildFrame:    call           MV_FRAME       ; display frame
  165.               sub            cx,0101h       ; move upper left corner out one
  166.               add            dx,0101h       ; move lower right corner out one
  167.               inc            si             ; set to next lighter frame type
  168.               dec            ax             ; are we still drawing frames?
  169.               jnz            WildFrame      ;   yep, go draw that funky thang
  170.               ret                           ;
  171. SlideWelcome  endp                     ; slide welcome message left
  172.  
  173.  
  174.  
  175. ShowCopyright proc           near      ; display copyright message
  176.               mov            dx,010Fh       ; row 1, column 15
  177.               call           MV_LOCATE      ; set cursor position
  178.               mov            al,1Bh         ; cyan on blue
  179.               call           MV_COLOR       ; set text color
  180.               lea            dx,CopyrMsg    ; copyright text
  181.               call           MV_STROUT      ; display it
  182.               ret                           ;
  183. ShowCopyright endp                     ; display copyright message
  184.  
  185.  
  186.  
  187. ShowWindow    proc           near      ; display pop-up window w/ text
  188.               lea            dx,ScrWindow   ;
  189.               call           MV_POPUP       ; pop up intro window
  190.               lea            si,WindowText  ; pointer to window text
  191.               mov            dx,word ptr ScrWindow
  192.               xchg           dl,dh          ;
  193.               add            dx,0102h       ; starting text position
  194. ShowText:     call           MV_LOCATE      ; set cursor position
  195.               call           S0_LENGTH      ; determine length of text
  196.               jcxz           ShoWindowXit   ;   if zero, we're done-- go exit
  197.               mov            al,[si]        ; get text color
  198.               call           MV_COLOR       ; set it
  199.               inc            si             ; skip over color to actual text
  200.               xchg           dx,si          ;
  201.               call           MV_STROUT      ; display the text
  202.               xchg           dx,si          ;
  203.               add            si,cx          ; move to next text line
  204.               inc            dh             ; move to next screen line
  205.               jmp            ShowText       ;   go for all text
  206. ShoWindowXit: ret                           ;
  207. ShowWindow    endp                     ; display pop-up window w/ text
  208.  
  209.  
  210.  
  211. WaitOnKey     proc           near      ; display "press any key", wait for it
  212.               mov            dx,191Bh       ; row 25, column 26
  213.               call           MV_LOCATE      ; set cursor location
  214.               mov            al,74h         ; red on white
  215.               call           MV_COLOR       ;
  216.               lea            dx,PressAnyMsg ; ptr to "Press any key..."
  217.               call           MV_STROUT      ; display it
  218.               mov            al,07h         ; normal video
  219.               call           MV_COLOR       ;
  220.               mov            al,1           ; wait for key
  221.               call           BKO_GETKEY     ; get a key
  222.               ret                           ;
  223. WaitOnKey     endp                     ; display "press any key", wait for it
  224.  
  225.  
  226.  
  227. Terminate     proc           near      ; restore original screen mode, etc
  228.               call           MD_DONE        ; shut down hi-res timer system
  229.               mov            al,OldMode     ; get old screen mode
  230.               call           MV_MODE        ; set video mode
  231.               call           MV_SHOWCURSOR  ; restore the cursor
  232.               ret                           ;
  233. Terminate     endp                     ; restore original screen mode, etc
  234.  
  235.  
  236.  
  237. WelcomeMsg    db "Welcome",0
  238. ToTheMsg      db "to the",0
  239. AsmMsg        db "Asm",13,0
  240. WizMsg        db "Wiz",0
  241. LibraryMsg    db "Library",0
  242. CopyrMsg      db "AsmWiz  Copyright 1990-1994  Thomas G. Hanlin III",0
  243. PressAnyMsg   db "Press any key to continue",0
  244.  
  245. ScrWindow     db 3,40,23,79        ; window coordinates
  246.               db 1,4Eh             ; frame type and color
  247.               dw offset ScrTitle   ; pointer to title
  248. ScrTitle      db "The Assembly Wizard's Library",0   ; window title
  249.  
  250. WindowText    db 4Ah,"Let's face it, asm programming can  ",0
  251.               db 4Ah,"be slow.  By the time you finish all",0
  252.               db 4Ah,"the low-level stuff, you forget what",0
  253.               db 4Ah,"you wanted to do in the first place!",0
  254.               db 4Ah,"AsmWiz takes care of all the little ",0
  255.               db 4Ah,"tedious details for you, so you can ",0
  256.               db 4Ah,"concentrate on the real work.       ",0
  257.               db 4Ah,0
  258.               db 70h,"Extensive text and graphics support ",0
  259.               db 30h,"Base conversions and 32-bit math    ",0
  260.               db 70h,"Delay and countdown services        ",0
  261.               db 30h,"Random numbers, checksums, CRCs     ",0
  262.               db 70h,"Parse input or the command line     ",0
  263.               db 30h,"Scan DOS environment variables      ",0
  264.               db 70h,"Intercept Break and Control-C       ",0
  265.               db 30h,"String functions, sound effects     ",0
  266.               db 70h,"Mouse and keyboard management       ",0
  267.               db 30h,"File handling with buffers, sharing ",0
  268.               db 70h,"International time and date support ",0,0
  269.  
  270. FileBuf   db 80 dup(?)
  271. OptBuf    db 80 dup(?)
  272.  
  273. OldMode   db 3
  274.  
  275. Cseg          ends
  276.               end            MAIN
  277.  
  278.