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

📄 fasmd.asm

📁 Fasm - Flat Assmebler
💻 ASM
📖 第 1 页 / 共 4 页
字号:
	pop	es
	mov	esi,screen_row_buffer
	mov	edi,[screen_offset]
	mov	ecx,[window_width]
	shr	ecx,1
	rep	movsd
	setc	cl
	rep	movsw
	mov	eax,[window_width]
	shl	eax,1
	sub	edi,eax
	add	edi,[video_pitch]
	mov	[screen_offset],edi
	pop	es
	pop	edx esi
	inc	edx
	mov	eax,edx
	sub	eax,[window_line_number]
	cmp	eax,[window_height]
	jae	screen_ok
	mov	edi,[line_buffer]
	or	esi,esi
	jnz	prepare_line
	push	esi edx
	push	[window_position]
	jmp	line_prepared
    screen_ok:
	call	update_status_bar
	ret

  syntax_proc:
	mov	ebx,characters
	xor	edx,edx
    scan_syntax:
	lodsb
    check_character:
	cmp	al,20h
	je	syntax_space
	cmp	al,3Bh
	je	syntax_comment
	mov	ah,al
	xlatb
	or	al,al
	jz	syntax_symbol
	or	edx,edx
	jnz	syntax_neutral
	cmp	ah,27h
	je	syntax_string
	cmp	ah,22h
	je	syntax_string
	cmp	ah,24h
	je	syntax_pascal_hex
	cmp	ah,39h
	ja	syntax_neutral
	cmp	ah,30h
	jae	syntax_number
    syntax_neutral:
	or	edx,-1
	inc	edi
	loop	scan_syntax
	jmp	syntax_done
    syntax_space:
	xor	edx,edx
	inc	edi
	loop	scan_syntax
	jmp	syntax_done
    syntax_symbol:
	mov	al,[symbol_color]
	stosb
	xor	edx,edx
	loop	scan_syntax
	jmp	syntax_done
    syntax_pascal_hex:
	cmp	ecx,1
	je	syntax_neutral
	mov	al,[esi]
	mov	ah,al
	xlatb
	or	al,al
	jz	syntax_neutral
	cmp	ah,24h
	jne	syntax_number
	cmp	ecx,2
	je	syntax_neutral
	mov	al,[esi+1]
	xlatb
	or	al,al
	jz	syntax_neutral
    syntax_number:
	mov	al,[number_color]
	stosb
	loop	number_character
	jmp	syntax_done
    number_character:
	lodsb
	mov	ah,al
	xlatb
	xchg	al,ah
	or	ah,ah
	jz	check_character
	cmp	al,20h
	je	check_character
	cmp	al,3Bh
	je	check_character
	mov	al,[number_color]
	stosb
	loop	number_character
	jmp	syntax_done
    syntax_string:
	mov	al,[string_color]
	stosb
	dec	ecx
	jz	syntax_done
	lodsb
	cmp	al,ah
	jne	syntax_string
	mov	al,[string_color]
	stosb
	dec	ecx
	jz	syntax_done
	lodsb
	cmp	al,ah
	je	syntax_string
	xor	edx,edx
	jmp	check_character
    syntax_comment:
	mov	al,[comment_color]
	stosb
	loop	syntax_comment
    syntax_done:
	ret

; Status drawing

  update_status_bar:
	mov	edi,screen_row_buffer
	mov	al,20h
	mov	ecx,[screen_width]
	rep	stosb
	mov	edi,screen_row_buffer+256
	mov	eax,'Row '
	stosd
	mov	eax,[caret_line_number]
	call	number_as_text
	mov	al,'/'
	stosb
	mov	eax,[lines_count]
	call	number_as_text
	mov	eax,', Co'
	stosd
	mov	eax,'lumn'
	stosd
	mov	al,' '
	stosb
	mov	eax,[caret_position]
	inc	eax
	call	number_as_text
	mov	al,'/'
	stosb
	mov	eax,[maximum_position]
	inc	eax
	call	number_as_text
	mov	ecx,edi
	mov	esi,screen_row_buffer+256
	sub	ecx,esi
	mov	eax,[screen_width]
	lea	edi,[screen_row_buffer+eax-1]
	sub	edi,ecx
	mov	byte [edi-2],0B3h
	lea	ebx,[edi-11]
	rep	movsb
	mov	edi,ebx
	sub	ebx,2
	mov	byte [ebx],0B3h
	push	ebx
	cmp	[undo_data],0
	je	modified_status_ok
	mov	eax,'Modi'
	stosd
	mov	eax,'fied'
	stosd
     modified_status_ok:
	mov	edi,screen_row_buffer+1
	xor	eax,eax
	mov	edx,[previous_instance]
     count_preceding_instances:
	inc	eax
	or	edx,edx
	jz	preceding_instances_count_ok
	mov	edx,[edx+16+previous_instance-editor_data]
	jmp	count_preceding_instances
     preceding_instances_count_ok:
	push	eax
	call	number_as_text
	mov	al,'/'
	stosb
	pop	eax
	mov	edx,[next_instance]
     count_following_instances:
	or	edx,edx
	jz	following_instances_count_ok
	inc	eax
	mov	edx,[edx+16+next_instance-editor_data]
	jmp	count_following_instances
     following_instances_count_ok:
	call	number_as_text
	inc	edi
	mov	al,'-'
	stosb
	inc	edi
	pop	ecx
	sub	ecx,edi
	mov	esi,[file_path]
	call	get_file_title
      print_file_title:
	lodsb
	or	al,al
	jz	editor_title_ok
	stosb
	loop	print_file_title
      editor_title_ok:
	push	es gs
	pop	es
	mov	edi,[video_pitch]
	mov	eax,[screen_height]
	dec	eax
	imul	edi,eax
	mov	esi,screen_row_buffer
	mov	ecx,[screen_width]
	mov	ah,[status_colors]
     draw_status_bar:
	lodsb
	stosw
	loop	draw_status_bar
	pop	es
	ret
     get_file_title:
	or	esi,esi
	jz	untitled
	mov	ebx,esi
      find_file_name:
	lodsb
	or	al,al
	jz	file_title_ok
	cmp	al,'\'
	jne	find_file_name
	mov	ebx,esi
	jmp	find_file_name
      file_title_ok:
	mov	esi,ebx
	ret
      untitled:
	mov	esi,_untitled
	ret
  update_title_bar:
	mov	edi,screen_row_buffer
	mov	al,20h
	mov	ecx,[screen_width]
	sub	ecx,10+1
	rep	stosb
	mov	al,0B3h
	stosb
	mov	esi,_caption
	mov	edi,screen_row_buffer+1
     draw_caption:
	lodsb
	or	al,al
	jz	caption_ok
	stosb
	jmp	draw_caption
     caption_ok:
	mov	edx,[main_project_file]
	or	edx,edx
	jz	main_file_title_ok
	mov	al,20h
	stosb
	mov	al,'-'
	stosb
	mov	al,20h
	stosb
	mov	esi,[file_path]
	cmp	edx,[editor_memory]
	je	get_main_file_title
	mov	esi,[edx+16+file_path-editor_data]
     get_main_file_title:
	call	get_file_title
	mov	ecx,[screen_width]
	add	ecx,screen_row_buffer-14
	sub	ecx,edi
     print_main_file_title:
	lodsb
	or	al,al
	jz	main_file_title_ok
	stosb
	loop	print_main_file_title
     main_file_title_ok:
	push	es gs
	pop	es
	xor	edi,edi
	mov	esi,screen_row_buffer
	mov	ecx,[screen_width]
	sub	ecx,10
	mov	ah,[status_colors]
     draw_title_bar:
	lodsb
	stosw
	loop	draw_title_bar
	pop	es
	call	update_clock
	ret
  update_clock:
	mov	edi,[screen_width]
	mov	ecx,10
	sub	edi,ecx
	shl	edi,1
	mov	al,[status_colors]
     prepare_clock_colors:
	mov	[gs:edi+(ecx-1)*2+1],al
	loop	prepare_clock_colors
	mov	ah,2Ch
	int	21h
	mov	[gs:edi],byte 20h
	mov	al,ch
	aam
	add	ax,'00'
	mov	[gs:edi+1*2],ah
	mov	[gs:edi+2*2],al
	mov	[gs:edi+3*2],byte ':'
	mov	al,cl
	aam
	add	ax,'00'
	mov	[gs:edi+4*2],ah
	mov	[gs:edi+5*2],al
	mov	[gs:edi+6*2],byte ':'
	mov	al,dh
	aam
	add	ax,'00'
	mov	[gs:edi+7*2],ah
	mov	[gs:edi+8*2],al
	mov	[gs:edi+9*2],byte 20h
	ret
  wait_for_input:
	call	update_clock
	mov	ah,11h
	int	16h
	jz	wait_for_input
	mov	ah,10h
	int	16h
	ret

  number_as_text:
	push	ebx
	mov	ecx,1000000000
	xor	edx,edx
	xor	bl,bl
      number_loop:
	div	ecx
	push	edx
	cmp	ecx,1
	je	store_digit
	or	bl,bl
	jnz	store_digit
	or	al,al
	jz	digit_ok
	not	bl
      store_digit:
	add	al,'0'
	stosb
      digit_ok:
	mov	eax,ecx
	xor	edx,edx
	mov	ecx,10
	div	ecx
	mov	ecx,eax
	pop	eax
	or	ecx,ecx
	jnz	number_loop
	pop	ebx
	ret
  sprintf:
	lodsb
	cmp	al,'%'
	je	format_parameter
	stosb
	or	al,al
	jnz	sprintf
	ret
    format_parameter:
	lodsb
	mov	edx,[ebx]
	add	ebx,4
	cmp	al,'s'
	je	insert_string
	cmp	al,'d'
	je	insert_number
	or	al,al
	jnz	sprintf
	dec	esi
	jmp	sprintf
    insert_number:
	push	esi
	mov	eax,edx
	call	number_as_text
	pop	esi
	jmp	sprintf
    insert_string:
	push	esi
	mov	esi,edx
    string_insertion_loop:
	lodsb
	or	al,al
	jz	string_insertion_ok
	stosb
	jmp	string_insertion_loop
    string_insertion_ok:
	pop	esi
	jmp	sprintf

; Windows

  message_box:
	push	eax ebx
	xor	ebp,ebp
	mov	edi,buffer+200h
	mov	dl,[esp+4+3]
	or	dl,dl
	jnz	calculate_buttons_width
	mov	dl,1
	mov	[first_button],_ok
    calculate_buttons_width:
	mov	[buttons_width],0
	mov	eax,[first_button]
	call	add_button_width
	dec	dl
	jz	buttons_width_ok
	add	[buttons_width],2
	mov	eax,[second_button]
	call	add_button_width
	jmp	buttons_width_ok
    add_button_width:
	push	edi
	mov	edi,eax
	xor	al,al
	or	ecx,-1
	repne	scasb
	neg	cl
	add	cl,6-2
	add	[buttons_width],cl
	pop	edi
	ret
    buttons_width_ok:
	mov	al,[buttons_width]
	mov	[message_width],al
    start_message_line:
	mov	ebx,edi
	mov	edx,edi
	mov	ecx,[screen_width]
	sub	ecx,14
	mov	eax,[screen_height]
	sub	eax,7
	inc	ebp
	cmp	ebp,eax
	jae	message_prepared
    copy_message:
	lodsb
	stosb
	cmp	al,20h
	jne	message_character_ok
	mov	edx,edi
    message_character_ok:
	cmp	byte [esi],0
	je	message_prepared
	loop	copy_message
	cmp	edx,ebx
	je	split_word
	lea	eax,[edx-1]
	mov	ecx,[screen_height]
	sub	ecx,7
	inc	ebp
	cmp	ebp,ecx
	je	cut_message
	mov	byte [eax],0Ah
	sub	eax,ebx
	mov	ebx,edx
	mov	ecx,[screen_width]
	lea	ecx,[ecx-14+ebx]
	sub	ecx,edi
	cmp	al,[message_width]
	jbe	copy_message
	mov	[message_width],al
	jmp	copy_message
    cut_message:
	mov	edi,eax
	jmp	message_prepared
    split_word:
	mov	eax,[screen_width]
	sub	eax,14
	mov	[message_width],al
	mov	al,0Ah
	stosb
	jmp	start_message_line
    message_prepared:
	mov	eax,edi
	sub	eax,ebx
	cmp	al,[message_width]
	jbe	message_width_ok
	mov	[message_width],al
    message_width_ok:
	xor	al,al
	stosb
	mov	ecx,ebp
	mov	ch,cl
	add	ch,6
	mov	cl,[message_width]
	add	cl,8
	pop	esi
	mov	ah,[esp+1]
	call	draw_centered_window
	mov	esi,buffer+200h
	add	edi,2*2
    draw_message:
	xor	ecx,ecx
	add	edi,[video_pitch]
    draw_message_row:
	lodsb
	or	al,al
	jz	message_drawn
	cmp	al,0Ah
	je	draw_message
	mov	byte [gs:edi+ecx*2],al
	inc	ecx
	jmp	draw_message_row
    message_drawn:
	add	edi,[video_pitch]
	add	edi,[video_pitch]
	mov	cx,1000h
	mov	ah,1
	int	10h
	movzx	eax,[message_width]
	sub	al,[buttons_width]
	and	al,not 1
	add	edi,eax
	cmp	byte [esp+3],2
	jae	two_button_message
	pop	eax
	mov	ah,al
	mov	esi,[first_button]
	call	draw_button
    wait_for_ok:
	call	wait_for_input
	cmp	ah,1
	je	message_aborted
	cmp	al,20h
	je	message_ok
	cmp	al,0Dh
	jne	wait_for_ok
    message_ok:
	mov	eax,1
	ret
    message_aborted:
	xor	eax,eax
	ret
    two_button_message:
	pop	edx
	xor	cl,cl
	test	edx,10000h
	jnz	two_button_loop
	mov	cl,-1
    two_button_loop:
	push	edi
	mov	al,dl
	and	al,cl
	mov	ah,cl
	not	ah
	and	ah,dh
	or	ah,al
	mov	esi,[first_button]
	call	draw_button
	add	edi,2*2
	mov	al,dh
	and	al,cl
	mov	ah,cl
	not	ah
	and	ah,dl
	or	ah,al
	mov	esi,[second_button]
	call	draw_button
	push	ecx edx
	call	wait_for_input
	pop	edx ecx edi
	cmp	ah,1
	je	message_aborted
	cmp	al,9
	je	two_button_switch
	cmp	ah,0Fh
	je	two_button_switch
	cmp	ah,4Bh
	je	two_button_switch
	cmp	ah,4Dh
	je	two_button_switch
	cmp	ah,48h
	je	two_button_switch
	cmp	ah,50h
	je	two_button_switch
	cmp	al,0Dh
	je	button_selected
	cmp	al,20h
	jne	two_button_loop
    button_selected:
	or	cl,cl
	jnz	message_ok
	mov	eax,2
	ret
    two_button_switch:
	not	cl
	jmp	two_button_loop
    draw_button:
	push	es gs
	pop	es
	mov	al,'['
	stosw
	mov	al,20h
	stosw
	stosw
    draw_button_label:
	lodsb
	or	al,al
	jz	button_label_ok
	stosw
	jmp	draw_button_label
    button_label_ok:
	mov	al,20h
	stosw
	stosw
	mov	al,']'
	stosw
	pop	es
	ret
  draw_centered_window:
	mov	dl,byte [screen_width]
	sub	dl,cl
	shr	dl,1
	mov	dh,byte [screen_height]
	sub	dh,ch
	shr	dh,1
  draw_window:
	push	es gs
	pop	es
	movzx	edi,dh
	imul	edi,[video_pitch]
	movzx	ebx,dl
	shl	ebx,1
	add	edi,ebx
	movzx	edx,ch
	movzx	ecx,cl
	sub	ecx,4
	sub	edx,2
	push	ecx edi
	mov	al,' '
	stos	word [edi]
	mov	al,'

⌨️ 快捷键说明

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