home *** CD-ROM | disk | FTP | other *** search
- ; ------------------------------------------------------------------
- ;
- ; The following is the source code for FBOX.BBX. It's main function
- ; is to move the file name and directory search template into the
- ; same directory, translate a check box indicating the type of icon
- ; to use into a number that the internal FILE_BOX and SAVE_BOX will
- ; recognize as an icon, and then call the internal FILE_BOX (LOAD)
- ; or SAVE_BOX.
- ;
- ; It is written referring to the steps laid out in BBX_ASM.DOC
- ;
- ; Please note that this particular example uses some calls to the
- ; graphics driver, SYNERGY, to set refresh modes, etc. These are
- ; necessary for the BlackBox to work, but are not pertinent to the
- ; example of building a BlackBox in Assembly. Further information
- ; on the graphics device drivers will be available in Toolkit 3.0
- ;
- ; ------------------------------------------------------------------
-
-
- ; *** Step 1: include LANGUAGE.LIB and EQUATES.ASM
-
- include language.lib
- include equates.asm
-
-
- ; *** Step 2: Use _BBX_START_DATA to declare data segment
-
- _BBX_START_DATA
-
- ; *** Step 2a: Declare internal data.
-
- fbox_file_name db 80 dup (0)
- fbox_file_template db 80 dup (0)
-
- .overlap equ 1 ; this is a SYNERGY equate
-
- ; *** Step 2b: Use _BBX_END_DATA to end the data segment
-
- _BBX_END_DATA
-
-
-
- ; *** Step 3: Use _BBX_START_CODE to declare the code segment
-
- _BBX_START_CODE
-
-
- ; *** Step 4: Declare a series of near ptr jumps into the code so that
- ; the entry points for both BlackBoxes will always be 0 and 3
- ; respectively, even if the actual code changes. This prevents
- ; having to redo the BlackBox header and updating BlackBoxes
- ; in FlowCharts.
-
- ife language - exe ; compile this only for the .BBX
-
- use_a_load_box_jmp: jmp near ptr use_a_load_box
- use_a_save_box_jmp: jmp near ptr use_a_save_box
-
-
- ; *** Step 5: Declare procedures to take advantage of int 0F4H calls
-
- file_box proc
-
- mov bp,_INTERNAL_LOAD_BOX
- int 0F4H
- ret
-
- file_box endp
-
-
- save_box proc
-
- mov bp,_INTERNAL_SAVE_BOX
- int 0F4H
- ret
-
- save_box endp
-
- else
-
- extrn file_box :far ; these are declared external for
- extrn save_box :far ; C, BASIC, and PASCAL
-
- endif
-
-
-
- ; *** Step 6: Declare the passing stack structure
-
- file_box_varln equ 20 + 2 ; always +2 for language type
- file_buffer equ [bp+bbxc_base+16]
- file_buffer_size equ [bp+bbxc_base+14]
- file_template equ [bp+bbxc_base+10]
- file_icon_val equ [bp+bbxc_base+8]
- file_name equ [bp+bbxc_base+4]
- file_box_status equ [bp+bbxc_base]
-
-
- ; *** Step 7: Declare the procedure using _BBX_PROC
-
- _BBX_PROC USE_A_LOAD_BOX
-
-
- ; *** Step 8: write the action of the BlackBox
-
- cld
-
- ; A Synergy Command to set the refresh mode
-
- mov al,.overlap
- mov ah,39 ; _set_refresh_mode
- int 0F3H
-
-
- ; set es:[di] to point to the internal variable file_box_template
-
- push ds
- pop es
- lea di,fbox_file_template
-
- ; set ds:[si] to point to the passed file_template
- ; note that _BASIC_STRING is used to ensure that the BASIC .OBJ
- ; gets the correct pointer to the text data
-
- lds si,file_template
- _BASIC_STRING ds,si
-
- ; simply moves an ASCIIZ string from ds:[si] to es:[di]
-
- call move_to_buffer
-
-
- ; do the same thing for the file name
-
- lea di,fbox_file_name
-
- lds si,file_name
- _BASIC_STRING ds,si
-
- call move_to_buffer
-
- ; The internal FILE_BOX procedure takes the following input:
- ;
- ; es:[bx] points to a buffer for the file names
- ; cx holds the size of that buffer
- ; ds:[si] points to a DOS directory search template
- ; ds:[di] points to the destination file name
- ; dx holds an icon_value
- ; ax holds 0
- ;
- ; ax returns a 0 if successful, non-zero if not
-
- push es
- pop ds ; reset ds
- lea di,fbox_file_name
- lea si,fbox_file_template
-
- les bx,file_buffer
- mov cx,file_buffer_size
-
- ; the formula for calculating the icon number is
- ; (file_icon_val-1)*8 + 16AH
-
- mov dl,file_icon_val
- xor dh,dh
- or dx,dx
- jz use_a_load_box_empty
-
- dec dx
-
- use_a_load_box_empty:
- shl dx,1
- shl dx,1
- mov ax,dx
- shl dx,1
- add dx,ax ; dx holds file icon
- add dx,16AH
-
- xor ax,ax
-
- push bp
- call file_box ; call file_box
- pop bp
-
-
- les di,file_name
- _BASIC_STRING es,di
-
- lea si,fbox_file_name
- call move_to_buffer ; return the file name
-
- mov dl,1 ; indicates success
-
- or ax,ax
- jz use_a_file_box_exit
-
- mov dl,2 ; indicates the user cancelled
-
- use_a_file_box_exit:
-
- ; *** Step 9: return a check box value using _RETURN_VALUE
-
- _RETURN_VALUE file_box_status,dl
-
-
- ; *** Step 10: return from the procedure using _RESTORE_STACK
-
- _RESTORE_STACK file_box_varln
-
-
- ; *** Step 11: end the procedure using _BBX_ENDP
-
- _BBX_ENDP USE_A_LOAD_BOX
-
-
-
- ; *** Step 12: repeat for USE_A_SAVE_BOX
-
-
- save_box_varln equ 14 + 2
- save_buffer equ [bp+bbxc_base+10]
- save_buffer_size equ [bp+bbxc_base+8]
- save_name equ [bp+bbxc_base+4]
- save_box_status equ [bp+bbxc_base]
-
-
- _BBX_PROC USE_A_SAVE_BOX
-
- cld
-
- push ds
- pop es
- lea di,fbox_file_name
-
- lds si,save_name
- _BASIC_STRING ds,si
-
- call move_to_buffer
-
- push es
- pop ds
- lea di,fbox_file_name
-
- les bx,save_buffer
- mov cx,save_buffer_size
-
- mov al,.overlap
- mov ah,39
- int 0F3H
-
- mov al,.overlap
-
- push bp
- call save_box
- pop bp
-
- les di,save_name
- _BASIC_STRING es,di
-
- lea si,fbox_file_name
- call move_to_buffer
-
- mov dl,1
-
- or ax,ax
- jz use_a_save_box_exit
-
- mov dl,2
-
- use_a_save_box_exit:
- _RETURN_VALUE save_box_status,dl
-
- _RESTORE_STACK save_box_varln
-
- _BBX_ENDP USE_A_SAVE_BOX
-
-
-
- _PUBLIC move_to_buffer
- move_to_buffer proc
-
- push ax
-
- mov cx,80
-
- move_to_buffer_loop:
- lodsb
- stosb
- or al,al
- loopnz move_to_buffer_loop
-
- pop ax
-
- ret
-
- move_to_buffer endp
-
-
- ; *** Step 13: End the program using _BBX_END_CODE and _END_PROG
-
- _BBX_END_CODE
-
- _END_PROG