home *** CD-ROM | disk | FTP | other *** search
/ Media Share 9 / MEDIASHARE_09.ISO / progmisc / asmlib.zip / ASMDEMO.ASM < prev    next >
Assembly Source File  |  1992-06-14  |  4KB  |  192 lines

  1. include    asm.inc
  2.  
  3. public    mymain
  4. extrn    syshard:proc, syssoft:proc, runprog:proc
  5. extrn    textdemo:proc
  6. extrn    curvefit:proc, bargraph:proc
  7.  
  8. extrn    pickstr:proc
  9. extrn    pulldown:proc
  10. extrn    tfill:proc, wframe:proc, wclear:proc
  11. extrn    ansicolor:proc, getkey:proc
  12. extrn    screenmem:proc, getscreen:proc, putscreen:proc
  13. extrn    dosalloc:proc
  14. extrn    ansicolor:proc, tclear:proc
  15. extrn    tprint:proc, tprintce:proc, crtinfo:proc
  16.  
  17. .data
  18. menudata    db 'System',0
  19.         db 'Hardware',0
  20.         db 'Software',0
  21.         db 'Run another program',0
  22.         db 0
  23.         db 'Text mode',0
  24.         db 0
  25.         db 'Graphics',0
  26.         db 'Bar Graph',0
  27.         db 'Curve fitting',0
  28.         db 0
  29.         db 'Quit',0
  30.         dw 0
  31.  
  32. proc_table    dw demo0
  33.         dw demo1
  34.         dw graphdemo
  35.         dw demo3
  36. sys_table    dw sys_hard
  37.         dw sys_soft
  38.         dw run_program
  39. gdemo_table    dw bar_graph
  40.         dw curve_fit
  41. saved_bx    dw 0
  42. screen_seg    dw 0
  43.  
  44. box_corners    dw 5,5,20,70
  45.  
  46. intro_msg    db ' Welcome to the ASMLIB interactive demonstration program  ',0
  47. intro2_msg    db ' ASMDEMO will give you a few examples of ASMLIB programming ',0
  48. intro3_msg    db ' Note that ASMDEMO has not been optimized, but it will ',0
  49. intro4_msg    db " give you a flavor for some of the library's functions. ",0
  50. intro5_msg    db ' ASMDEMO was written with MASM 5.1 and ASMLIB.  No other ',0
  51. intro6_msg    db ' software tools were used. ',0
  52. press_key    db ' Press any key to continue',0
  53. escape_msg    db ' Press ESC for main menu',0
  54.  
  55. .code
  56. mymain    proc
  57.     call    ansicolor
  58.     mov    al,'░'
  59.     call    tfill
  60.     lea    bx,box_corners
  61.     mov    ah,7
  62.     call    wclear
  63.     mov    al,'■'
  64.     call    wframe
  65.     lea    si,intro_msg
  66.     mov    dh,byte ptr box_corners
  67.     inc    dh
  68.     mov    dl,byte ptr box_corners+2
  69.     inc    dl
  70.     mov    ah,15
  71.     call    tprint
  72.     lea    si,intro2_msg
  73.     inc    dh
  74.     call    tprint
  75.     lea    si,intro3_msg
  76.     inc    dh
  77.     call    tprint
  78.     lea    si,intro4_msg
  79.     inc    dh
  80.     call    tprint
  81.     lea    si,intro5_msg
  82.     inc    dh
  83.     call    tprint
  84.     lea    si,intro6_msg
  85.     inc    dh
  86.     call    tprint
  87.     lea    si,press_key
  88.     add    dh,2
  89.     mov    ah,14
  90.     call    tprint
  91.     call    getkey
  92.  
  93.     xor    bx,bx
  94.     mov    saved_bx,bx
  95. again:    lea    si,menudata
  96.     mov    bx,saved_bx
  97.     call    pulldown
  98.     mov    saved_bx,bx
  99.     cmp    ax,13
  100.     je    demo
  101.     cmp    al,0
  102.     jne    again
  103.  
  104. demo:    mov    bl,bh
  105.     xor    bh,bh
  106.     shl    bx,1
  107.     jmp    proc_table[bx]
  108.  
  109. ;;
  110. ;; SYSTEM demos
  111. ;;
  112. demo0:    mov    bx,saved_bx
  113.     xor    bh,bh        ; BX = submenu index
  114.     shl    bx,1        ; convert to an offset
  115.     jmp    sys_table[bx]
  116. sys_soft:
  117.     call    syssoft
  118.     jmp    again
  119. sys_hard:
  120.     call    syshard
  121.     jmp    again
  122. run_program:
  123.     call    save_screen
  124.     call    runprog
  125.     call    restore_screen
  126.     jmp    again
  127.  
  128. demo1:    call    textdemo
  129.     jmp    again
  130.  
  131. ;;
  132. ;; graph mode demos
  133. ;; includes: bargraph, curvefit
  134. ;;
  135. graphdemo:
  136.     call    save_screen
  137. gdemo0:    mov    bx,saved_bx
  138.     xor    bh,bh
  139.     shl    bx,1
  140.     jmp    gdemo_table[bx]
  141.  
  142. curve_fit:
  143.     call    curvefit
  144.     jmp    short gdemo9
  145. bar_graph:
  146.     call    bargraph
  147.  
  148. ; restore text-mode screen
  149. gdemo9:    call    restore_screen
  150.     jmp    again
  151.  
  152. demo3:
  153. exit:    call    ansicolor
  154.     call    tclear
  155.     ret
  156. mymain    endp
  157.  
  158. save_screen:
  159.     call    screenmem    ; returns screen size in bytes
  160.     xor    dx,dx        ; DX:AX = screen size
  161.     mov    screen_seg,dx    ; default: memory not available
  162.     call    dosalloc    ; allocate memory block
  163.     jc    ss9        ; don't save screen if no memory available
  164.     mov    screen_seg,ax    ; save base address of memory block
  165.  
  166. ; copy screen to memory block
  167.     push    ds
  168.     mov    ds,ax
  169.     xor    si,si
  170.     call    getscreen
  171.     pop    ds
  172.  
  173. ss9:    ret
  174.  
  175. restore_screen:
  176.     mov    ax,screen_seg
  177.     or    ax,ax        ; was screen saved?
  178.     jz    rs9        ;  nope, exit
  179.     push    ds
  180.     mov    ds,ax
  181.     xor    si,si
  182.     call    putscreen
  183.     pop    ds
  184.  
  185. ; release memory block
  186.     mov    es,ax        ; memory block base address
  187.     mov    ah,49h
  188.     int    21h
  189. rs9:    ret
  190.  
  191.     end
  192.