⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dialogs.inc

📁 DOS下的调试工具
💻 INC
字号:
;=============================================================================
; Insight, real-mode debugger for MS DOS / PC DOS / FreeDOS.
; Copyright (c) Victor M. Gamayunov, Sergey Pimenov, 1993, 96, 97, 2002.
; Modifications by Oleg O. Chukaev (2006, 2007).
;-----------------------------------------------------------------------------
; dialogs.inc
; Procedures for creating dialog windows.
;-----------------------------------------------------------------------------
; This program is free software; you can redistribute it and/or
; modify it under the terms of the GNU General Public License
; as published by the Free Software Foundation; either version 2
; of the License, or (at your option) any later version.
;
; This program is distributed in the hope that it will be useful,
; but WITHOUT ANY WARRANTY; without even the implied warranty of
; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
; GNU General Public License for more details.
; 
; You should have received a copy of the GNU General Public License
; along with this program; if not, write to the Free Software
; Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
; 02111-1307, USA.
;=============================================================================


;=============================================================================
; Changelog
;-----------------------------------------------------------------------------
; 2007-02-15 (Oleg O. Chukaev)
;	Added comments to all procedures.
;	All variables moved to act[u]data.inc
;
;=============================================================================


;=============================================================================
; init_dialog
;-----------------------------------------------------------------------------
; Draws dialog window.
; In:	DS:SI -> dialog window structure.
;		Format of dialog window structure:
;			db	left, top, right, bottom ;coordinates
;			dw	ptr-to-title
;			dw	number-of-elements
;			db	number-of-initial-element (0-based)
;
;			Data of 1st element
;			...
;			Data of 2nd element
;			...
;
;		Format of header of element's data:
;			dw	ptr-to-init-procedure
;			dw	ptr-to-run-procedure
;			db	???
;
; Out:	---
; Modf:	---
; Call:	pushr, open_window, popr, init_*
; Use:	dlg_win_a, dlg_win_b, video_seg, dlg_items, dlg_active_item,
;	dlg_items_data
;
init_dialog:
		call	pushr
		cld
		lodsw			;Top/left
		mov	[dlg_win_a],ax
		mov	bx,ax
		lodsw			;Bottom/right
		mov	[dlg_win_b],ax
		mov	dx,ax
		lodsw			;Ptr to title
		push	si
		mov	si,ax
		mov	byte [si+1],atDialogWindow	;??? Change color
		mov	ax,atDialogWindow*256	;AL==0: Don't save window
		call	open_window
		pop	si
		mov	es,[video_seg]
		lodsw			;Number of elements
		mov	cx,ax
		mov	[dlg_items],ax
		jcxz	@@quit		;Exit if 0 elements

		mov	[dlg_active_item],si	;Ptr to number of active elem.
		lodsb				;Skip 1 byte
						;Now SI points to data of
						;1st element
		mov	di,dlg_items_data
@@next:
		lodsw			;Ptr to init-procedure
		add	si,3		;Ptr to real data of element
		mov	[di],si		;Save it
		inc	di
		inc	di
		call	ax		;Call init-procedure
		loop	@@next
@@quit:
		call	popr
		ret
;=============================================================================
; exec_dialog, exec_dialog_
;-----------------------------------------------------------------------------
; Executes dialog.
; In:	[dlg_win_a] -- top left corner
;	[dlg_win_b] -- lower right corner
;	[dlg_items] -- number of items in dialog window
;	[dlg_active_item] -> number of active item
;	dlg_items_data -- array of pointers to data of items
; Out:	---
; Modf:	exec_dialog:
;		AX, SI
;	exec_dialog_:
;		AX
; Call:	pushr, get_cursor, no_cursor, set_cursor, gotoxy, popr, run_*
; Use:	dlg_active_item, exec_dialog_cx, exec_dialog_dx, video_seg, dlg_items,
;	dlg_items_data, exec_dialog_res, run_push_button, run_static_text
;
exec_dialog:
		mov	si,[dlg_active_item]
		mov	byte [si],0

exec_dialog_:
		call	pushr
		call	get_cursor
		mov	[exec_dialog_cx],cx
		mov	[exec_dialog_dx],dx
		call	no_cursor
		mov	es,[video_seg]
		cld
		mov	cx,[dlg_items]
		jcxz	@@quit

		mov	bx,[dlg_active_item]
		mov	bl,[bx]		;Number of active element
		mov	bh,0

@@next:
		push	cx
		call	no_cursor
		pop	cx
		mov	di,bx
		add	di,di
		mov	si,[dlg_items_data+di]	;Ptr to real data of element
		call	word [si-3]		;Call run-procedure
		or	ax,ax			;ESC?
		jz	@@quit			;Yes, exit
		cmp	ax,1
		je	@@enter
@@find_next:
		cmp	ax,2			;Tab
		je	@@inc
		or	bx,bx			;First element?
		jz	@@end			;Yes, move to last element
		dec	bx			;(Shift+Tab)
		jmp	@@check_static
@@end:
		mov	bx,cx
		dec	bx
		jmp	@@check_static
@@inc:
		inc	bx
		cmp	bx,cx
		jb	@@check_static
@@home:
		xor	bx,bx

@@check_static:
		mov	di,bx
		add	di,di
		mov	si,[dlg_items_data+di]
		cmp	word [si-3],run_static_text
		jne	@@next
		jmp	@@find_next

@@quit:
		xor	ax,ax		; CM_CANCEL
		mov	si,[dlg_active_item]
		mov	bl,[si]

@@exit:
		mov	si,[dlg_active_item]
		mov	[si],bl

@@restore_cursor:
		mov	[exec_dialog_res],ax
		mov	cx,[exec_dialog_cx]
		call	set_cursor
		mov	dx,[exec_dialog_dx]
		call	gotoxy
		call	popr
		mov	ax,[exec_dialog_res]
		or	ax,ax
		ret
@@enter:
		mov	ax,CM_DEFAULT
		cmp	word [si-3],run_push_button
		jne	@@exit
		mov	ax,[si+5]
		jmp	@@exit
;=============================================================================
; init_push_button
;-----------------------------------------------------------------------------
; Initializes button.
; In:	DS:SI -> push button structure
;		Format of push button structure (7 bytes):
;			db	column, row	;relative coordinates
;			db	width-of-button
;			dw	ptr-to-label
;			dw	number-of-command
;	ES -- segment of video buffer
; Out:	SI -> structure of next element
; Modf:	BX, DL, SI
; Call:	draw_push_button
; Use:	---
;
init_push_button:
		mov	bh,atPushButton
		mov	bl,atlPushButton
		test	byte [si-1],BF_DEFAULT
		jz	@@1
		mov	bh,atPushButtonDef
		mov	bl,atlPushButtonDef
@@1:
		mov	dl,0
		call	draw_push_button
		add	si,7
		ret
;=============================================================================
; draw_push_button
;-----------------------------------------------------------------------------
; Draws button.
; In:	DS:SI -> push button structure
;	BL -- color of hot letter
;	BH -- color of text
;	DL -- flag:
;		0 -- draw normal button
;		1 -- draw pressed button
;	ES -- segment of video buffer
; Out:	---
; Modf:	---
; Call:	pushr, get_addr, point_len, draw_text, popr
; Use:	dlg_win_a
;
draw_push_button:
		call	pushr
		lodsw			;Coordinates
		add	ax,[dlg_win_a]
		call	get_addr
		lodsb			;Width
		cbw
		mov	cx,ax
		push	cx
		mov	al,' '
		or	dl,dl
		jz	@@2
		mov	ah,atDialogWindow
		stosw
@@2:
		mov	ah,bh
	rep	stosw
		mov	ah,atButtonShadow
		or	dl,dl
		jnz	@@3
		mov	al,'

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -