home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 9 / 09.iso / l / l010 / 5.ddi / C5.ARC / FBOX.ASM < prev    next >
Encoding:
Assembly Source File  |  1989-12-20  |  6.5 KB  |  305 lines

  1. ; ------------------------------------------------------------------
  2. ;
  3. ; The following is the source code for FBOX.BBX.  It's main function
  4. ; is to move the file name and directory search template into the
  5. ; same directory, translate a check box indicating the type of icon
  6. ; to use into a number that the internal FILE_BOX and SAVE_BOX will
  7. ; recognize as an icon, and then call the internal FILE_BOX (LOAD)
  8. ; or SAVE_BOX.
  9. ;
  10. ; It is written referring to the steps laid out in BBX_ASM.DOC
  11. ;
  12. ; Please note that this particular example uses some calls to the
  13. ; graphics driver, SYNERGY, to set refresh modes, etc.    These are
  14. ; necessary for the BlackBox to work, but are not pertinent to the
  15. ; example of building a BlackBox in Assembly.  Further information
  16. ; on the graphics device drivers will be available in Toolkit 3.0
  17. ;
  18. ; ------------------------------------------------------------------
  19.  
  20.  
  21. ; *** Step 1: include LANGUAGE.LIB and EQUATES.ASM
  22.  
  23. include language.lib
  24. include equates.asm
  25.  
  26.  
  27. ; *** Step 2: Use _BBX_START_DATA to declare data segment
  28.  
  29. _BBX_START_DATA
  30.  
  31. ; *** Step 2a: Declare internal data.
  32.  
  33. fbox_file_name       db    80 dup (0)
  34. fbox_file_template db    80 dup (0)
  35.  
  36. .overlap       equ    1            ; this is a SYNERGY equate
  37.  
  38. ; *** Step 2b: Use _BBX_END_DATA to end the data segment
  39.  
  40. _BBX_END_DATA
  41.  
  42.  
  43.  
  44. ; *** Step 3: Use _BBX_START_CODE to declare the code segment
  45.  
  46. _BBX_START_CODE
  47.  
  48.  
  49. ; *** Step 4: Declare a series of near ptr jumps into the code so that
  50. ;          the entry points for both BlackBoxes will always be 0 and 3
  51. ;          respectively, even if the actual code changes.  This prevents
  52. ;          having to redo the BlackBox header and updating BlackBoxes
  53. ;          in FlowCharts.
  54.  
  55. ife language - exe    ; compile this only for the .BBX
  56.  
  57. use_a_load_box_jmp:    jmp  near ptr use_a_load_box
  58. use_a_save_box_jmp:    jmp  near ptr use_a_save_box
  59.  
  60.  
  61. ; *** Step 5: Declare procedures to take advantage of int 0F4H calls
  62.  
  63. file_box      proc
  64.  
  65.           mov    bp,_INTERNAL_LOAD_BOX
  66.           int    0F4H
  67.           ret
  68.  
  69. file_box      endp
  70.  
  71.  
  72. save_box      proc
  73.  
  74.           mov    bp,_INTERNAL_SAVE_BOX
  75.           int    0F4H
  76.           ret
  77.  
  78. save_box      endp
  79.  
  80. else
  81.  
  82. extrn     file_box  :far       ; these are declared external for
  83. extrn     save_box  :far       ; C, BASIC, and PASCAL
  84.  
  85. endif
  86.  
  87.  
  88.  
  89. ; *** Step 6: Declare the passing stack structure
  90.  
  91. file_box_varln       equ    20 + 2             ; always +2 for language type
  92. file_buffer       equ    [bp+bbxc_base+16]
  93. file_buffer_size   equ    [bp+bbxc_base+14]
  94. file_template       equ    [bp+bbxc_base+10]
  95. file_icon_val       equ    [bp+bbxc_base+8]
  96. file_name       equ    [bp+bbxc_base+4]
  97. file_box_status    equ    [bp+bbxc_base]
  98.  
  99.  
  100. ; *** Step 7: Declare the procedure using _BBX_PROC
  101.  
  102. _BBX_PROC     USE_A_LOAD_BOX
  103.  
  104.  
  105. ; *** Step 8: write the action of the BlackBox
  106.  
  107.           cld
  108.  
  109.           ; A Synergy Command to set the refresh mode
  110.  
  111.           mov    al,.overlap
  112.           mov    ah,39            ; _set_refresh_mode
  113.           int    0F3H
  114.  
  115.  
  116.           ; set es:[di] to point to the internal variable file_box_template
  117.  
  118.           push    ds
  119.           pop    es
  120.           lea    di,fbox_file_template
  121.  
  122.           ; set ds:[si] to point to the passed file_template
  123.           ; note that _BASIC_STRING is used to ensure that the BASIC .OBJ
  124.           ; gets the correct pointer to the text data
  125.  
  126.           lds    si,file_template
  127.           _BASIC_STRING ds,si
  128.  
  129.           ; simply moves an ASCIIZ string from ds:[si] to es:[di]
  130.  
  131.           call    move_to_buffer
  132.  
  133.  
  134.           ; do the same thing for the file name
  135.  
  136.           lea    di,fbox_file_name
  137.  
  138.           lds    si,file_name
  139.           _BASIC_STRING ds,si
  140.  
  141.           call    move_to_buffer
  142.  
  143.           ; The internal FILE_BOX procedure takes the following input:
  144.           ;
  145.           ; es:[bx] points to a buffer for the file names
  146.           ; cx holds the size of that buffer
  147.           ; ds:[si] points to a DOS directory search template
  148.           ; ds:[di] points to the destination file name
  149.           ; dx holds an icon_value
  150.           ; ax holds 0
  151.           ;
  152.           ; ax returns a 0 if successful, non-zero if not
  153.  
  154.           push    es
  155.           pop    ds             ; reset ds
  156.           lea    di,fbox_file_name
  157.           lea    si,fbox_file_template
  158.  
  159.           les    bx,file_buffer
  160.           mov    cx,file_buffer_size
  161.  
  162.           ; the formula for calculating the icon number is
  163.           ; (file_icon_val-1)*8 + 16AH
  164.  
  165.           mov    dl,file_icon_val
  166.           xor    dh,dh
  167.           or    dx,dx
  168.           jz    use_a_load_box_empty
  169.  
  170.           dec    dx
  171.  
  172. use_a_load_box_empty:
  173.           shl    dx,1
  174.           shl    dx,1
  175.           mov    ax,dx
  176.           shl    dx,1
  177.           add    dx,ax            ; dx holds file icon
  178.           add    dx,16AH
  179.  
  180.           xor    ax,ax
  181.  
  182.           push    bp
  183.           call    file_box        ; call file_box
  184.           pop    bp
  185.  
  186.  
  187.           les    di,file_name
  188.           _BASIC_STRING es,di
  189.  
  190.           lea    si,fbox_file_name
  191.           call    move_to_buffer        ; return the file name
  192.  
  193.           mov    dl,1            ; indicates success
  194.  
  195.           or    ax,ax
  196.           jz    use_a_file_box_exit
  197.  
  198.           mov    dl,2            ; indicates the user cancelled
  199.  
  200. use_a_file_box_exit:
  201.  
  202. ; *** Step 9: return a check box value using _RETURN_VALUE
  203.  
  204.           _RETURN_VALUE file_box_status,dl
  205.  
  206.  
  207. ; *** Step 10: return from the procedure using _RESTORE_STACK
  208.  
  209.           _RESTORE_STACK file_box_varln
  210.  
  211.  
  212. ; *** Step 11: end the procedure using _BBX_ENDP
  213.  
  214. _BBX_ENDP     USE_A_LOAD_BOX
  215.  
  216.  
  217.  
  218. ; *** Step 12: repeat for USE_A_SAVE_BOX
  219.  
  220.  
  221. save_box_varln       equ    14 + 2
  222. save_buffer       equ    [bp+bbxc_base+10]
  223. save_buffer_size   equ    [bp+bbxc_base+8]
  224. save_name       equ    [bp+bbxc_base+4]
  225. save_box_status    equ    [bp+bbxc_base]
  226.  
  227.  
  228. _BBX_PROC     USE_A_SAVE_BOX
  229.  
  230.           cld
  231.  
  232.           push    ds
  233.           pop    es
  234.           lea    di,fbox_file_name
  235.  
  236.           lds    si,save_name
  237.           _BASIC_STRING ds,si
  238.  
  239.           call    move_to_buffer
  240.  
  241.           push    es
  242.           pop    ds
  243.           lea    di,fbox_file_name
  244.  
  245.           les    bx,save_buffer
  246.           mov    cx,save_buffer_size
  247.  
  248.           mov    al,.overlap
  249.           mov    ah,39
  250.           int    0F3H
  251.  
  252.           mov    al,.overlap
  253.  
  254.           push    bp
  255.           call    save_box
  256.           pop    bp
  257.  
  258.           les    di,save_name
  259.           _BASIC_STRING es,di
  260.  
  261.           lea    si,fbox_file_name
  262.           call    move_to_buffer
  263.  
  264.           mov    dl,1
  265.  
  266.           or    ax,ax
  267.           jz    use_a_save_box_exit
  268.  
  269.           mov    dl,2
  270.  
  271. use_a_save_box_exit:
  272.           _RETURN_VALUE save_box_status,dl
  273.  
  274.           _RESTORE_STACK save_box_varln
  275.  
  276. _BBX_ENDP     USE_A_SAVE_BOX
  277.  
  278.  
  279.  
  280. _PUBLIC move_to_buffer
  281. move_to_buffer       proc
  282.  
  283.            push      ax
  284.  
  285.            mov         cx,80
  286.  
  287. move_to_buffer_loop:
  288.            lodsb
  289.            stosb
  290.            or         al,al
  291.            loopnz    move_to_buffer_loop
  292.  
  293.            pop         ax
  294.  
  295.            ret
  296.  
  297. move_to_buffer       endp
  298.  
  299.  
  300. ; *** Step 13: End the program using _BBX_END_CODE and _END_PROG
  301.  
  302. _BBX_END_CODE
  303.  
  304. _END_PROG
  305.