Go to most recent revision | Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
31 | halyavin | 1 | ;===[includes]===; |
2 | include 'lang.inc' |
||
3 | include 'ascl.inc' |
||
4 | include 'macros.inc' |
||
5 | ;===[header and etc.]===; |
||
6 | meos_app_start |
||
7 | ;===[code:]===; |
||
8 | code |
||
9 | ;--------------------------------------- |
||
10 | ;====== we want keyborad events ======== |
||
11 | mov eax,40 |
||
12 | mov ebx,00000000000000000000000000000010b |
||
13 | int 0x40 |
||
14 | |||
15 | ;====== wanna use keyboard scan codes == |
||
16 | mov eax,66 |
||
17 | mov ebx,1 |
||
18 | mov ecx,1 |
||
19 | int 0x40 |
||
20 | |||
21 | ;=======GET SCREEN SIZE================= |
||
22 | |||
23 | mov eax,14 ; get screen size |
||
24 | int 0x40 |
||
25 | push eax |
||
26 | and eax,0x0000ffff |
||
27 | inc eax |
||
28 | mov [size_y],eax |
||
29 | pop eax |
||
30 | shr eax,16 |
||
31 | inc eax |
||
32 | mov [size_x],eax |
||
33 | |||
34 | mov eax,[size_x] |
||
35 | shr eax,2 |
||
36 | mov [cmp_ecx],eax |
||
37 | |||
38 | mov eax,[size_x] |
||
39 | xor edx,edx |
||
40 | mov ebx,3 |
||
41 | mul ebx |
||
42 | mov [add_esi],eax |
||
43 | |||
44 | mov eax,[size_y] |
||
45 | shr eax,2 |
||
46 | mov [cmp_edx],eax |
||
47 | |||
48 | mov eax,[size_y] |
||
49 | imul eax,[size_x] |
||
50 | imul eax,3 |
||
51 | mov [i_size],eax |
||
52 | |||
53 | ;======================================= |
||
54 | |||
55 | still: |
||
56 | mov eax,10 |
||
57 | int 0x40 |
||
58 | cmp eax,2 |
||
59 | je key |
||
60 | jmp still |
||
61 | |||
62 | key: |
||
63 | mov eax,2 |
||
64 | int 0x40 |
||
65 | cmp ah,55 ;===print screen to hdd |
||
66 | je print_screen_hdd |
||
67 | cmp ah,84 ;===alt+prnt.screen = print screen to fdd |
||
68 | je print_screen_fdd |
||
69 | cmp ah,70 ;===lets make exit - scroll lock |
||
70 | je close_now |
||
71 | jmp still |
||
72 | |||
73 | close_now: |
||
74 | close |
||
75 | ;================================== |
||
76 | ;===save file to hdd=============== |
||
77 | print_screen_hdd: |
||
78 | mov [savetofdd],0 |
||
79 | call change_fname |
||
80 | call save_screen |
||
81 | jmp still |
||
82 | ;===save file to fdd=============== |
||
83 | print_screen_fdd: |
||
84 | mov [savetofdd],1 |
||
85 | call change_fname |
||
86 | call save_screen |
||
87 | jmp still |
||
88 | ;===change our file name ========== |
||
89 | change_fname: |
||
90 | cmp [bmp_name+7],'9' |
||
91 | jne addfname |
||
92 | cmp [bmp_name+6],'9' |
||
93 | je leavenow ;if name is > than 'screen99.bmp' then we do not change name |
||
94 | mov [bmp_name+7],'0' |
||
95 | add [bmp_name+6],0x1 |
||
96 | jmp leavenow |
||
97 | addfname: |
||
98 | add [bmp_name+7],0x1 |
||
99 | leavenow: |
||
100 | ret |
||
101 | ;================================== |
||
102 | |||
103 | ;============SAVE SCREEN=========== |
||
104 | read_pixel: |
||
105 | pushad |
||
106 | |||
107 | mov esi,eax |
||
108 | mov eax,[size_x] |
||
109 | mul ebx |
||
110 | add eax,esi |
||
111 | |||
112 | xchg eax,ebx |
||
113 | mov eax,35 |
||
114 | int 0x40 |
||
115 | mov [esp+28],eax |
||
116 | |||
117 | popad |
||
118 | ret |
||
119 | |||
120 | save_screen: |
||
121 | |||
122 | pusha |
||
123 | |||
124 | ; 1) READ SCREEN |
||
125 | mov edi,bmp_file_area+0x36 ;0x10036 |
||
126 | |||
127 | mov eax,[size_y] |
||
128 | dec eax |
||
129 | mov [temp_y],eax |
||
130 | |||
131 | ynew: |
||
132 | |||
133 | xor eax,eax |
||
134 | mov [temp_x],eax |
||
135 | |||
136 | xnew: |
||
137 | |||
138 | mov eax,[temp_x] |
||
139 | mov ebx,[temp_y] |
||
140 | call read_pixel |
||
141 | |||
142 | mov [edi],eax |
||
143 | add edi,3 |
||
144 | |||
145 | inc [temp_x] |
||
146 | |||
147 | mov eax,[size_x] |
||
148 | cmp [temp_x],eax |
||
149 | jb xnew |
||
150 | |||
151 | dec [temp_y] |
||
152 | |||
153 | cmp [temp_y],0 |
||
154 | jge ynew |
||
155 | |||
156 | ; 2) BMP HEADER |
||
157 | |||
158 | mov [bmp_file_area],word 'BM' ; bmp signature |
||
159 | mov eax,[i_size] |
||
160 | mov [bmp_file_area+34],eax ; image size |
||
161 | mov ebx,0x36 |
||
162 | mov [bmp_file_area+10],ebx ; headers size |
||
163 | add eax,ebx |
||
164 | mov [bmp_file_area+2],eax ; file size |
||
165 | mov [bmp_file_area+14],dword 0x28 |
||
166 | mov eax,[size_x] |
||
167 | mov [bmp_file_area+18],eax ; x size |
||
168 | mov eax,[size_y] |
||
169 | mov [bmp_file_area+22],eax ; y size |
||
170 | mov [bmp_file_area+26],word 1 |
||
171 | mov [bmp_file_area+28],word 0x18 ; bpp = 24 = 0x18 |
||
172 | |||
173 | ; 3) SAVE FILE |
||
174 | cmp [savetofdd],1 |
||
175 | je save_to_fdd |
||
176 | mov eax,56 |
||
177 | mov ebx,bmp_name |
||
178 | mov edx,bmp_file_area |
||
179 | mov ecx,[i_size] |
||
180 | add ecx,0x36 |
||
181 | mov esi,path |
||
182 | int 0x40 |
||
183 | popa |
||
184 | ret |
||
185 | |||
186 | save_to_fdd: |
||
187 | mov eax,33; |
||
188 | mov ebx,bmp_name |
||
189 | mov ecx,bmp_file_area |
||
190 | mov edx,[i_size] |
||
191 | add edx,0x36 |
||
192 | mov esi,0 |
||
193 | int 0x40 |
||
194 | popa |
||
195 | ret |
||
196 | |||
197 | |||
198 | ;======================================= |
||
199 | |||
200 | ;--------------------------------------- |
||
201 | ;===[DATA]===; |
||
202 | data |
||
203 | ;--------------------------------------- |
||
204 | bmp_name db 'SCREEN00BMP' |
||
205 | path db 0 |
||
206 | |||
207 | i_size dd 0x1 |
||
208 | |||
209 | m_x dd 100 |
||
210 | m_y dd 100 |
||
211 | |||
212 | cmp_ecx dd 0 |
||
213 | add_esi dd 0 |
||
214 | cmp_edx dd 0 |
||
215 | |||
216 | savetofdd db 0 |
||
217 | |||
218 | ;===[uninitialised data]===; |
||
219 | udata |
||
220 | ;--------------------------------------- |
||
221 | |||
222 | temp_x dd ? |
||
223 | temp_y dd ? |
||
224 | |||
225 | size_x dd ? |
||
226 | size_y dd ? |
||
227 | |||
228 | bmp_file_area: |
||
229 | rb 0x250000 |
||
230 | |||
231 | ;the happy end |
||
232 | meos_app_end |