Subversion Repositories Kolibri OS

Rev

Rev 307 | Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
205 heavyiron 1
save_file:
2
pusha
3
	bt	dword [flags],0
4
	jnc	.not_shooted
5
 
6
	cmp	byte [ed_buffer.1],0
7
	je	.no_file_name
8
 
9
	mov	edi,sign_n_input
10
	call	zstr_to_int
11
	mov	[sign_n],al
12
 
13
	; генерируем имя файла
14
	xor	eax,eax
15
	mov	ecx,1056
16
	mov	edi,file_name
17
	rep	stosb	; заполняем нулями
18
 
19
	mov	esi,ed_buffer.1
20
	mov	edi,file_name
21
.next:
22
	mov	ah,[esi]
23
	test	ah,ah
24
	jz	.str_end
25
	cmp	ah,'*'
26
	jne	.no_insert_number
27
	jmp	.insert_number
28
.no_insert_number:
29
	mov	[edi],ah
30
	inc	edi
31
	inc	esi
32
	jmp	.next
33
.insert_number:
34
	bt	word [ch6.flags],1
35
	jnc	@f
36
	mov	eax,[cur_number]
37
	;mov     ebx,4
38
	movsx	ebx,byte [sign_n]
39
	push	ebx
40
	call	int_to_str
41
	pop	ebx
42
	add	edi,ebx
43
@@:
44
	inc	esi
45
	jmp	.next
46
.str_end:
47
 
48
	; выделяем память
49
	mov	ecx,[scr_buf.end_ptr]
50
	mov	[sf_buf.bmp_header],ecx
51
	add	ecx,0x36
52
	mov	[sf_buf.bmp_area],ecx
53
	movsx	ebx,word [scr_buf.width]
54
	movsx	edx,word [scr_buf.height]
55
	imul	ebx,edx
56
	lea	ebx,[ebx*3]
57
	add	ecx,ebx
58
	mov	[sf_buf.end],ecx
59
	add	ecx,4096
60
	xor	ebx,ebx
61
	inc	ebx
62
	movr	 eax,64
63
	int	0x40
64
 
65
	; заполняем структуру для сохранения файла
66
	mov	edi,fs_struc
67
	mov	[edi],dword 2
68
	mov	eax,[sf_buf.bmp_header]
69
	mov	ebx,[sf_buf.end]
70
	sub	ebx,eax
71
	mov	[edi+12],ebx
72
	mov	[edi+16],eax
73
	mov	[edi+21],dword file_name
74
 
75
	; заполняем заголовок bmp
76
	mov	edi,[sf_buf.bmp_header]
77
	mov	[edi],word 'BM'
78
	mov	ebx,[sf_buf.end]
79
	sub	ebx,[sf_buf.bmp_area]
80
	mov	[edi+34],ebx	; размер картинки
81
	mov	[edi+10],dword 0x36	; размер заголовка
82
	add	ebx,0x36
83
	mov	[edi+2],ebx ; размер файла
84
	mov	[edi+14],dword 0x28
85
	movsx	eax,word [scr_buf.width]
86
	mov	[edi+18],eax ; горизонтальный размер
87
	movsx	eax,word [scr_buf.height]
88
	mov	[edi+22],eax ; вертикльный размер
89
	mov	[edi+26],word 1
90
	mov	[edi+28],word 24
91
 
92
	; копируем и переворачиваем
93
	mov	esi,[scr_buf.ptr]
94
	mov	edi,[sf_buf.bmp_area]
95
	mov	edx,[sf_buf.end]
96
	sub	edx,edi
97
	movsx	ecx,word [scr_buf.height]
98
.next_str:
99
push	ecx
100
 
101
	movsx	ecx,word [scr_buf.width]
102
	lea	ecx,[ecx*3]
103
	mov	ebx,ecx
104
.next_byte:
105
	mov	ah,[esi+ebx]
106
	mov	[edi+edx],ah
107
	dec	ebx
108
	dec	edx
109
	loop	.next_byte
110
	movsx	ecx,word [scr_buf.width]
111
	lea	ecx,[ecx*3]
112
	add	esi,ecx
113
pop	ecx
114
	loop	.next_str
115
 
116
	; сохраняем
117
	draw_status saving
118
	mov	eax,70
119
	mov	ebx,fs_struc
120
	int	0x40
121
 
122
	test	eax,eax
123
	jne	save_error
124
 
125
	inc	dword [cur_number]
126
	call	draw_number
127
 
128
	draw_status saved_ok
129
popa
130
ret
131
 
132
.no_file_name:
133
	draw_status no_file_name
134
popa
135
ret
136
 
137
.not_shooted:
138
	draw_status not_shooted
139
popa
140
ret
141
 
142
save_error:
143
	cmp	al,5
144
	jne	@f
145
	mov	[status.text],dword bad_file_name
146
@@:
147
	cmp	al,8
148
	jne	@f
149
	mov	[status.text],dword disk_filled
150
@@:
151
 
152
	cmp	al,9
153
	jne	@f
154
	mov	[status.text],dword bad_fat_table
155
@@:
156
 
157
	cmp	al,10
158
	jne	@f
159
	mov	[status.text],dword ac_den
160
@@:
161
 
162
	cmp	al,11
163
	jne	@f
164
	mov	[status.text],dword device_er
165
@@:
166
	call	send_draw_status
167
popa
168
ret