Rev 335 | Rev 399 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 335 | Rev 381 | ||
---|---|---|---|
Line 10... | Line 10... | ||
10 | 10 | ||
Line 11... | Line 11... | ||
11 | calculatefatchain: |
11 | calculatefatchain: |
Line 12... | Line 12... | ||
12 | 12 | ||
13 | pushad |
13 | pushad |
Line 14... | Line 14... | ||
14 | 14 | ||
15 | mov esi,0x100000+512 |
15 | mov esi,RAMDISK+512 |
16 | mov edi,0x280000 |
16 | mov edi,RAMDISK_FAT |
17 | 17 | ||
Line 36... | Line 36... | ||
36 | mov dword [edi+8],ecx |
36 | mov dword [edi+8],ecx |
37 | mov dword [edi+12],edx |
37 | mov dword [edi+12],edx |
38 | add edi,16 |
38 | add edi,16 |
39 | add esi,12 |
39 | add esi,12 |
Line 40... | Line 40... | ||
40 | 40 | ||
41 | cmp edi,0x280000+2856*2 ;2849 clusters |
41 | cmp edi,RAMDISK_FAT+2856*2 ;2849 clusters |
Line 42... | Line 42... | ||
42 | jnz fcnew |
42 | jnz fcnew |
43 | 43 | ||
Line 44... | Line 44... | ||
44 | popad |
44 | popad |
Line 45... | Line 45... | ||
45 | ret |
45 | ret |
Line 46... | Line 46... | ||
46 | 46 | ||
47 | 47 | ||
Line 48... | Line 48... | ||
48 | restorefatchain: ; restore fat chain |
48 | restorefatchain: ; restore fat chain |
49 | 49 | ||
50 | pushad |
50 | pushad |
51 | 51 | ||
Line 64... | Line 64... | ||
64 | mov dword [edi],eax |
64 | mov dword [edi],eax |
65 | mov word [edi+4],bx |
65 | mov word [edi+4],bx |
66 | add edi,6 |
66 | add edi,6 |
67 | add esi,8 |
67 | add esi,8 |
Line 68... | Line 68... | ||
68 | 68 | ||
69 | cmp edi,0x100000+512+4278 ;4274 bytes - all used FAT |
69 | cmp edi,RAMDISK+512+4278 ;4274 bytes - all used FAT |
Line 70... | Line 70... | ||
70 | jb fcnew2 |
70 | jb fcnew2 |
71 | 71 | ||
72 | mov esi,0x100000+512 ; duplicate fat chain |
72 | mov esi,RAMDISK+512 ; duplicate fat chain |
73 | mov edi,0x100000+512+0x1200 |
73 | mov edi,RAMDISK+512+0x1200 |
74 | mov ecx,1069 ;4274/4 |
74 | mov ecx,1069 ;4274/4 |
Line 75... | Line 75... | ||
75 | cld |
75 | cld |
Line 86... | Line 86... | ||
86 | ; rewr.by Mihasik |
86 | ; rewr.by Mihasik |
87 | ;--------------------------------------------- |
87 | ;--------------------------------------------- |
Line 88... | Line 88... | ||
88 | 88 | ||
Line 89... | Line 89... | ||
89 | push eax ebx ecx |
89 | push eax ebx ecx |
90 | 90 | ||
91 | mov edi,0x280000 ;start of FAT |
91 | mov edi,RAMDISK_FAT ;start of FAT |
92 | xor ax,ax ;Free cluster=0x0000 in FAT |
92 | xor ax,ax ;Free cluster=0x0000 in FAT |
93 | xor ebx,ebx ;counter |
93 | xor ebx,ebx ;counter |
94 | mov ecx,2849 ;2849 clusters |
94 | mov ecx,2849 ;2849 clusters |
Line 200... | Line 200... | ||
200 | jbe fr_do1 |
200 | jbe fr_do1 |
201 | sub edx,14 |
201 | sub edx,14 |
202 | sub ecx,edx |
202 | sub ecx,edx |
203 | fr_do1: |
203 | fr_do1: |
204 | shl ebx,9 |
204 | shl ebx,9 |
205 | mov esi,0x100000+512*19 |
205 | mov esi,RAMDISK+512*19 |
206 | add esi,ebx |
206 | add esi,ebx |
207 | shl ecx,7 |
207 | shl ecx,7 |
208 | cld |
208 | cld |
209 | rep movsd |
209 | rep movsd |
210 | popf |
210 | popf |
Line 244... | Line 244... | ||
244 | 244 | ||
Line 245... | Line 245... | ||
245 | frnew: |
245 | frnew: |
246 | 246 | ||
247 | add eax,31 ;bootsector+2*fat+filenames |
247 | add eax,31 ;bootsector+2*fat+filenames |
248 | shl eax,9 ;*512 |
248 | shl eax,9 ;*512 |
249 | add eax,0x100000 ;image base |
249 | add eax,RAMDISK ;image base |
Line 250... | Line 250... | ||
250 | mov ebx,[esp+8] |
250 | mov ebx,[esp+8] |
251 | mov ecx,512 ;[esp+4] |
251 | mov ecx,512 ;[esp+4] |
Line 258... | Line 258... | ||
258 | je frnoread |
258 | je frnoread |
259 | jmp frfl8 |
259 | jmp frfl8 |
260 | frfl7: |
260 | frfl7: |
261 | dec dword [esp+16] |
261 | dec dword [esp+16] |
262 | frfl8: |
262 | frfl8: |
263 | movzx eax,word [edi*2+0x280000] ; find next cluster from FAT |
263 | movzx eax,word [edi*2+RAMDISK_FAT] ; find next cluster from FAT |
264 | mov edi,eax |
264 | mov edi,eax |
265 | cmp edi,4095 ;eof - cluster |
265 | cmp edi,4095 ;eof - cluster |
266 | jz frnoread2 |
266 | jz frnoread2 |
Line 267... | Line 267... | ||
267 | 267 | ||
Line 324... | Line 324... | ||
324 | mov edi,eax ;edi = cluster |
324 | mov edi,eax ;edi = cluster |
Line 325... | Line 325... | ||
325 | 325 | ||
Line 326... | Line 326... | ||
326 | frnewd: |
326 | frnewd: |
327 | 327 | ||
328 | shl edi,1 ;find next cluster from FAT |
328 | shl edi,1 ;find next cluster from FAT |
329 | add edi,0x280000 |
329 | add edi,RAMDISK_FAT |
330 | movzx eax,word [edi] |
330 | movzx eax,word [edi] |
331 | mov [edi],word 0x0 ;clear fat chain cluster |
331 | mov [edi],word 0x0 ;clear fat chain cluster |
332 | mov edi,eax |
332 | mov edi,eax |
Line 373... | Line 373... | ||
373 | 373 | ||
Line 374... | Line 374... | ||
374 | rd_do_save: |
374 | rd_do_save: |
Line 375... | Line 375... | ||
375 | 375 | ||
376 | push eax ebx ecx edx esi edi |
376 | push eax ebx ecx edx esi edi |
377 | 377 | ||
378 | mov edi,0x100000+512*18+512 ;Point at directory |
378 | mov edi,RAMDISK+512*18+512 ;Point at directory |
379 | mov edx,224 +1 |
379 | mov edx,224 +1 |
380 | ; find an empty spot for filename in the root dir |
380 | ; find an empty spot for filename in the root dir |
Line 405... | Line 405... | ||
405 | call get_date_for_file ; from FAT32.INC |
405 | call get_date_for_file ; from FAT32.INC |
406 | mov [edi+24],ax ; date |
406 | mov [edi+24],ax ; date |
407 | call get_time_for_file ; from FAT32.INC |
407 | call get_time_for_file ; from FAT32.INC |
408 | mov [edi+22],ax ; time |
408 | mov [edi+22],ax ; time |
409 | ; End |
409 | ; End |
410 | mov edi,0x280000 ;pointer to first cluster |
410 | mov edi,RAMDISK_FAT ;pointer to first cluster |
411 | mov ecx,2849 |
411 | mov ecx,2849 |
412 | cld |
412 | cld |
413 | frnewds: |
413 | frnewds: |
414 | xor ax,ax |
414 | xor ax,ax |
415 | repne scasw |
415 | repne scasw |
Line 421... | Line 421... | ||
421 | dec edx |
421 | dec edx |
422 | call fdc_filesave |
422 | call fdc_filesave |
423 | pusha ; move save to floppy cluster |
423 | pusha ; move save to floppy cluster |
424 | add ebx,31 |
424 | add ebx,31 |
425 | shl ebx,9 |
425 | shl ebx,9 |
426 | add ebx,0x100000 |
426 | add ebx,RAMDISK |
427 | mov eax,[esp+32+16] |
427 | mov eax,[esp+32+16] |
428 | mov ecx,512 |
428 | mov ecx,512 |
429 | call memmove |
429 | call memmove |
430 | popa |
430 | popa |
Line 456... | Line 456... | ||
456 | 456 | ||
457 | rd_findfile: |
457 | rd_findfile: |
458 | ;by Mihasik |
458 | ;by Mihasik |
Line 459... | Line 459... | ||
459 | ;IN: eax - pointer to filename OUT: filestring+11 in edi or notZero in flags and fnf in eax,ebx |
459 | ;IN: eax - pointer to filename OUT: filestring+11 in edi or notZero in flags and fnf in eax,ebx |
460 | 460 | ||
461 | mov edi,0x100000+512*18+512 ;Point at directory |
461 | mov edi,RAMDISK+512*18+512 ;Point at directory |
462 | cld |
462 | cld |
463 | rd_newsearch: |
463 | rd_newsearch: |
464 | mov esi,eax |
464 | mov esi,eax |
465 | mov ecx,11 |
465 | mov ecx,11 |
466 | rep cmpsb |
466 | rep cmpsb |
467 | je rd_ff |
467 | je rd_ff |
468 | add cl,21 |
468 | add cl,21 |
469 | add edi,ecx |
469 | add edi,ecx |
470 | cmp edi,0x100000+512*33 |
470 | cmp edi,RAMDISK+512*33 |
471 | jb rd_newsearch |
471 | jb rd_newsearch |
472 | mov eax,5 ;if file not found - eax=5 |
472 | mov eax,5 ;if file not found - eax=5 |
473 | xor ebx,ebx |
473 | xor ebx,ebx |
Line 900... | Line 900... | ||
900 | call bdfe_to_fat_date |
900 | call bdfe_to_fat_date |
901 | mov [edi+24], ax ; last write date |
901 | mov [edi+24], ax ; last write date |
902 | ret |
902 | ret |
Line 903... | Line 903... | ||
903 | 903 | ||
904 | ramdisk_root_first: |
904 | ramdisk_root_first: |
905 | mov edi, 0x100000+512*19 |
905 | mov edi, RAMDISK+512*19 |
906 | clc |
906 | clc |
907 | ret |
907 | ret |
908 | ramdisk_root_next: |
908 | ramdisk_root_next: |
909 | add edi, 0x20 |
909 | add edi, 0x20 |
910 | cmp edi, 0x100000+512*33 |
910 | cmp edi, RAMDISK+512*33 |
911 | cmc |
911 | cmc |
Line 912... | Line 912... | ||
912 | ret |
912 | ret |
913 | 913 | ||
Line 930... | Line 930... | ||
930 | push ecx |
930 | push ecx |
931 | mov ecx, [eax] |
931 | mov ecx, [eax] |
932 | push [rd_prev_sector] |
932 | push [rd_prev_sector] |
933 | pop [rd_prev_prev_sector] |
933 | pop [rd_prev_prev_sector] |
934 | mov [rd_prev_sector], ecx |
934 | mov [rd_prev_sector], ecx |
935 | mov ecx, [ecx*2+0x280000] |
935 | mov ecx, [ecx*2+RAMDISK_FAT] |
936 | and ecx, 0xFFF |
936 | and ecx, 0xFFF |
937 | cmp ecx, 2849 |
937 | cmp ecx, 2849 |
938 | jae ramdisk_notroot_first.err2 |
938 | jae ramdisk_notroot_first.err2 |
939 | mov [eax], ecx |
939 | mov [eax], ecx |
940 | pop ecx |
940 | pop ecx |
Line 943... | Line 943... | ||
943 | cmp eax, 2 |
943 | cmp eax, 2 |
944 | jb .err |
944 | jb .err |
945 | cmp eax, 2849 |
945 | cmp eax, 2849 |
946 | jae .err |
946 | jae .err |
947 | shl eax, 9 |
947 | shl eax, 9 |
948 | lea edi, [eax+(31 shl 9)+0x100000] |
948 | lea edi, [eax+(31 shl 9)+RAMDISK] |
949 | clc |
949 | clc |
950 | ret |
950 | ret |
951 | .err2: |
951 | .err2: |
952 | pop ecx |
952 | pop ecx |
953 | .err: |
953 | .err: |
Line 960... | Line 960... | ||
960 | ret |
960 | ret |
Line 961... | Line 961... | ||
961 | 961 | ||
962 | ramdisk_notroot_extend_dir: |
962 | ramdisk_notroot_extend_dir: |
963 | pusha |
963 | pusha |
964 | xor eax, eax |
964 | xor eax, eax |
965 | mov edi, 0x280000 |
965 | mov edi, RAMDISK_FAT |
966 | mov ecx, 2849 |
966 | mov ecx, 2849 |
967 | repnz scasw |
967 | repnz scasw |
968 | jnz .notfound |
968 | jnz .notfound |
969 | mov word [edi-2], 0xFFF |
969 | mov word [edi-2], 0xFFF |
970 | sub edi, 0x280000 |
970 | sub edi, RAMDISK_FAT |
971 | shr edi, 1 |
971 | shr edi, 1 |
972 | dec edi |
972 | dec edi |
973 | mov eax, [esp+28] |
973 | mov eax, [esp+28] |
974 | mov ecx, [eax] |
974 | mov ecx, [eax] |
975 | mov [0x280000+ecx*2], di |
975 | mov [RAMDISK_FAT+ecx*2], di |
976 | mov [eax], edi |
976 | mov [eax], edi |
977 | shl edi, 9 |
977 | shl edi, 9 |
978 | add edi, (31 shl 9)+0x100000 |
978 | add edi, (31 shl 9)+RAMDISK |
979 | mov [esp], edi |
979 | mov [esp], edi |
980 | xor eax, eax |
980 | xor eax, eax |
981 | mov ecx, 128 |
981 | mov ecx, 128 |
982 | rep stosd |
982 | rep stosd |
Line 1077... | Line 1077... | ||
1077 | jz .eof |
1077 | jz .eof |
1078 | cmp edi, 0xFF8 |
1078 | cmp edi, 0xFF8 |
1079 | jae .eof |
1079 | jae .eof |
1080 | lea eax, [edi+31] ; bootsector+2*fat+filenames |
1080 | lea eax, [edi+31] ; bootsector+2*fat+filenames |
1081 | shl eax, 9 ; *512 |
1081 | shl eax, 9 ; *512 |
1082 | add eax, 0x100000 ; image base |
1082 | add eax, RAMDISK ; image base |
1083 | ; now eax points to data of cluster |
1083 | ; now eax points to data of cluster |
1084 | sub ebx, 512 |
1084 | sub ebx, 512 |
1085 | jae .skip |
1085 | jae .skip |
1086 | lea eax, [eax+ebx+512] |
1086 | lea eax, [eax+ebx+512] |
1087 | neg ebx |
1087 | neg ebx |
Line 1095... | Line 1095... | ||
1095 | add edx, ecx |
1095 | add edx, ecx |
1096 | sub [esp], ecx |
1096 | sub [esp], ecx |
1097 | pop ecx |
1097 | pop ecx |
1098 | xor ebx, ebx |
1098 | xor ebx, ebx |
1099 | .skip: |
1099 | .skip: |
1100 | movzx edi, word [edi*2+0x280000] ; find next cluster from FAT |
1100 | movzx edi, word [edi*2+RAMDISK_FAT] ; find next cluster from FAT |
1101 | jmp .new |
1101 | jmp .new |
1102 | .eof: |
1102 | .eof: |
1103 | mov ebx, edx |
1103 | mov ebx, edx |
1104 | pop eax edx ecx |
1104 | pop eax edx ecx |
1105 | sub ebx, edx |
1105 | sub ebx, edx |
Line 1166... | Line 1166... | ||
1166 | pop ecx eax |
1166 | pop ecx eax |
1167 | mov esi, edi ; esi points to block of data of folder entry (BDFE) |
1167 | mov esi, edi ; esi points to block of data of folder entry (BDFE) |
1168 | .main_loop: |
1168 | .main_loop: |
1169 | mov edi, eax |
1169 | mov edi, eax |
1170 | shl edi, 9 |
1170 | shl edi, 9 |
1171 | add edi, 0x100000 |
1171 | add edi, RAMDISK |
1172 | push eax |
1172 | push eax |
1173 | .l1: |
1173 | .l1: |
1174 | call fat_get_name |
1174 | call fat_get_name |
1175 | jc .l2 |
1175 | jc .l2 |
1176 | cmp byte [edi+11], 0xF |
1176 | cmp byte [edi+11], 0xF |
Line 1182... | Line 1182... | ||
1182 | inc eax |
1182 | inc eax |
1183 | dec byte [esp+262*2+16] |
1183 | dec byte [esp+262*2+16] |
1184 | jz .done |
1184 | jz .done |
1185 | jns @f |
1185 | jns @f |
1186 | ; read next sector from FAT |
1186 | ; read next sector from FAT |
1187 | mov eax, [(eax-31-1)*2+0x280000] |
1187 | mov eax, [(eax-31-1)*2+RAMDISK_FAT] |
1188 | and eax, 0xFFF |
1188 | and eax, 0xFFF |
1189 | cmp eax, 0xFF8 |
1189 | cmp eax, 0xFF8 |
1190 | jae .done |
1190 | jae .done |
1191 | add eax, 31 |
1191 | add eax, 31 |
1192 | mov byte [esp+262*2+16], 0 |
1192 | mov byte [esp+262*2+16], 0 |
1193 | @@: |
1193 | @@: |
1194 | mov edi, eax |
1194 | mov edi, eax |
1195 | shl edi, 9 |
1195 | shl edi, 9 |
1196 | add edi, 0x100000 |
1196 | add edi, RAMDISK |
1197 | push eax |
1197 | push eax |
1198 | .do_bdfe: |
1198 | .do_bdfe: |
1199 | inc dword [edx+8] ; new file found |
1199 | inc dword [edx+8] ; new file found |
1200 | dec ebx |
1200 | dec ebx |
1201 | jns .l2 |
1201 | jns .l2 |
Line 1211... | Line 1211... | ||
1211 | inc eax |
1211 | inc eax |
1212 | dec byte [esp+262*2+16] |
1212 | dec byte [esp+262*2+16] |
1213 | jz .done |
1213 | jz .done |
1214 | jns @f |
1214 | jns @f |
1215 | ; read next sector from FAT |
1215 | ; read next sector from FAT |
1216 | mov eax, [(eax-31-1)*2+0x280000] |
1216 | mov eax, [(eax-31-1)*2+RAMDISK_FAT] |
1217 | and eax, 0xFFF |
1217 | and eax, 0xFFF |
1218 | cmp eax, 0xFF8 |
1218 | cmp eax, 0xFF8 |
1219 | jae .done |
1219 | jae .done |
1220 | add eax, 31 |
1220 | add eax, 31 |
1221 | mov byte [esp+262*2+16], 0 |
1221 | mov byte [esp+262*2+16], 0 |
Line 1991... | Line 1991... | ||
1991 | jbe @f |
1991 | jbe @f |
1992 | mov ecx, ebx |
1992 | mov ecx, ebx |
1993 | @@: |
1993 | @@: |
1994 | mov eax, edi |
1994 | mov eax, edi |
1995 | shl eax, 9 |
1995 | shl eax, 9 |
1996 | add eax, 0x100000+31*512+0x200 |
1996 | add eax, RAMDISK+31*512+0x200 |
1997 | sub eax, ebx |
1997 | sub eax, ebx |
1998 | mov ebx, eax |
1998 | mov ebx, eax |
1999 | mov eax, edx |
1999 | mov eax, edx |
2000 | call memmove |
2000 | call memmove |
2001 | xor ebx, ebx |
2001 | xor ebx, ebx |
2002 | add edx, ecx |
2002 | add edx, ecx |
2003 | sub [esp], ecx |
2003 | sub [esp], ecx |
2004 | pop ecx |
2004 | pop ecx |
2005 | jz .ret |
2005 | jz .ret |
2006 | .next_cluster: |
2006 | .next_cluster: |
2007 | movzx edi, word [edi*2+0x280000] |
2007 | movzx edi, word [edi*2+RAMDISK_FAT] |
2008 | jmp .write_loop |
2008 | jmp .write_loop |
Line 2009... | Line 2009... | ||
2009 | 2009 | ||
2010 | ramdisk_extend_file.zero_size: |
2010 | ramdisk_extend_file.zero_size: |
2011 | xor eax, eax |
2011 | xor eax, eax |
Line 2022... | Line 2022... | ||
2022 | mov ecx, [edi+28] |
2022 | mov ecx, [edi+28] |
2023 | jecxz .zero_size |
2023 | jecxz .zero_size |
2024 | @@: |
2024 | @@: |
2025 | sub ecx, 0x200 |
2025 | sub ecx, 0x200 |
2026 | jbe @f |
2026 | jbe @f |
2027 | mov eax, [eax*2+0x280000] |
2027 | mov eax, [eax*2+RAMDISK_FAT] |
2028 | and eax, 0xFFF |
2028 | and eax, 0xFFF |
2029 | jz .fat_err |
2029 | jz .fat_err |
2030 | cmp eax, 0xFF8 |
2030 | cmp eax, 0xFF8 |
2031 | jb @b |
2031 | jb @b |
2032 | .fat_err: |
2032 | .fat_err: |
Line 2035... | Line 2035... | ||
2035 | pop eax |
2035 | pop eax |
2036 | stc |
2036 | stc |
2037 | ret |
2037 | ret |
2038 | @@: |
2038 | @@: |
2039 | push eax |
2039 | push eax |
2040 | mov eax, [eax*2+0x280000] |
2040 | mov eax, [eax*2+RAMDISK_FAT] |
2041 | and eax, 0xFFF |
2041 | and eax, 0xFFF |
2042 | cmp eax, 0xFF8 |
2042 | cmp eax, 0xFF8 |
2043 | pop eax |
2043 | pop eax |
2044 | jb .fat_err |
2044 | jb .fat_err |
2045 | ; set length to full number of sectors and make sure that last sector is zero-padded |
2045 | ; set length to full number of sectors and make sure that last sector is zero-padded |
2046 | sub [edi+28], ecx |
2046 | sub [edi+28], ecx |
2047 | push eax edi |
2047 | push eax edi |
2048 | mov edi, eax |
2048 | mov edi, eax |
2049 | shl edi, 9 |
2049 | shl edi, 9 |
2050 | lea edi, [edi+0x100000+31*512+0x200+ecx] |
2050 | lea edi, [edi+RAMDISK+31*512+0x200+ecx] |
2051 | neg ecx |
2051 | neg ecx |
2052 | xor eax, eax |
2052 | xor eax, eax |
2053 | rep stosb |
2053 | rep stosb |
2054 | pop edi eax |
2054 | pop edi eax |
2055 | .start_extend: |
2055 | .start_extend: |
2056 | pop ecx |
2056 | pop ecx |
2057 | ; now do extend |
2057 | ; now do extend |
2058 | push edx esi |
2058 | push edx esi |
2059 | mov esi, 0x280000+2*2 ; start scan from cluster 2 |
2059 | mov esi, RAMDISK_FAT+2*2 ; start scan from cluster 2 |
2060 | mov edx, 2847 ; number of clusters to scan |
2060 | mov edx, 2847 ; number of clusters to scan |
2061 | .extend_loop: |
2061 | .extend_loop: |
2062 | cmp [edi+28], ecx |
2062 | cmp [edi+28], ecx |
2063 | jae .extend_done |
2063 | jae .extend_done |
2064 | ; add new sector |
2064 | ; add new sector |
Line 2073... | Line 2073... | ||
2073 | pop eax |
2073 | pop eax |
2074 | jnz .disk_full |
2074 | jnz .disk_full |
2075 | mov word [edi-2], 0xFFF |
2075 | mov word [edi-2], 0xFFF |
2076 | mov esi, edi |
2076 | mov esi, edi |
2077 | mov edx, ecx |
2077 | mov edx, ecx |
2078 | sub edi, 0x280000 |
2078 | sub edi, RAMDISK_FAT |
2079 | shr edi, 1 |
2079 | shr edi, 1 |
2080 | dec edi ; now edi=new cluster |
2080 | dec edi ; now edi=new cluster |
2081 | test eax, eax |
2081 | test eax, eax |
2082 | jz .first_cluster |
2082 | jz .first_cluster |
2083 | mov [0x280000+eax*2], di |
2083 | mov [RAMDISK_FAT+eax*2], di |
2084 | jmp @f |
2084 | jmp @f |
2085 | .first_cluster: |
2085 | .first_cluster: |
2086 | pop eax ; eax->direntry |
2086 | pop eax ; eax->direntry |
2087 | push eax |
2087 | push eax |
2088 | mov [eax+26], di |
2088 | mov [eax+26], di |
2089 | @@: |
2089 | @@: |
2090 | push edi |
2090 | push edi |
2091 | shl edi, 9 |
2091 | shl edi, 9 |
2092 | add edi, 0x100000+31*512 |
2092 | add edi, RAMDISK+31*512 |
2093 | xor eax, eax |
2093 | xor eax, eax |
2094 | mov ecx, 512/4 |
2094 | mov ecx, 512/4 |
2095 | rep stosd |
2095 | rep stosd |
2096 | pop eax ; eax=new cluster |
2096 | pop eax ; eax=new cluster |
2097 | pop edi ; edi->direntry |
2097 | pop edi ; edi->direntry |
Line 2184... | Line 2184... | ||
2184 | jz .zero_size |
2184 | jz .zero_size |
2185 | ; find new last sector |
2185 | ; find new last sector |
2186 | @@: |
2186 | @@: |
2187 | sub eax, 0x200 |
2187 | sub eax, 0x200 |
2188 | jbe @f |
2188 | jbe @f |
2189 | movzx ecx, word [0x280000+ecx*2] |
2189 | movzx ecx, word [RAMDISK_FAT+ecx*2] |
2190 | jmp @b |
2190 | jmp @b |
2191 | @@: |
2191 | @@: |
2192 | ; zero data at the end of last sector |
2192 | ; zero data at the end of last sector |
2193 | push ecx |
2193 | push ecx |
2194 | mov edi, ecx |
2194 | mov edi, ecx |
2195 | shl edi, 9 |
2195 | shl edi, 9 |
2196 | lea edi, [edi+0x100000+31*512+eax+0x200] |
2196 | lea edi, [edi+RAMDISK+31*512+eax+0x200] |
2197 | mov ecx, eax |
2197 | mov ecx, eax |
2198 | neg ecx |
2198 | neg ecx |
2199 | xor eax, eax |
2199 | xor eax, eax |
2200 | rep stosb |
2200 | rep stosb |
2201 | pop ecx |
2201 | pop ecx |
2202 | ; terminate FAT chain |
2202 | ; terminate FAT chain |
2203 | lea ecx, [0x280000+ecx+ecx] |
2203 | lea ecx, [RAMDISK_FAT+ecx+ecx] |
2204 | push dword [ecx] |
2204 | push dword [ecx] |
2205 | mov word [ecx], 0xFFF |
2205 | mov word [ecx], 0xFFF |
2206 | pop ecx |
2206 | pop ecx |
2207 | and ecx, 0xFFF |
2207 | and ecx, 0xFFF |
2208 | jmp .delete |
2208 | jmp .delete |
Line 2211... | Line 2211... | ||
2211 | .delete: |
2211 | .delete: |
2212 | ; delete FAT chain starting with ecx |
2212 | ; delete FAT chain starting with ecx |
2213 | ; mark all clusters as free |
2213 | ; mark all clusters as free |
2214 | cmp ecx, 0xFF8 |
2214 | cmp ecx, 0xFF8 |
2215 | jae .deleted |
2215 | jae .deleted |
2216 | lea ecx, [0x280000+ecx+ecx] |
2216 | lea ecx, [RAMDISK_FAT+ecx+ecx] |
2217 | push dword [ecx] |
2217 | push dword [ecx] |
2218 | and word [ecx], 0 |
2218 | and word [ecx], 0 |
2219 | pop ecx |
2219 | pop ecx |
2220 | and ecx, 0xFFF |
2220 | and ecx, 0xFFF |
2221 | jmp .delete |
2221 | jmp .delete |
Line 2332... | Line 2332... | ||
2332 | cmp dword [eax], 0 ; file size |
2332 | cmp dword [eax], 0 ; file size |
2333 | jz .eof |
2333 | jz .eof |
2334 | mov edx, [eax+4] ; cluster |
2334 | mov edx, [eax+4] ; cluster |
2335 | lea esi, [edx+31] |
2335 | lea esi, [edx+31] |
2336 | shl esi, 9 |
2336 | shl esi, 9 |
2337 | add esi, 0x100000 |
2337 | add esi, RAMDISK |
2338 | mov ecx, 512/4 |
2338 | mov ecx, 512/4 |
2339 | rep movsd |
2339 | rep movsd |
2340 | mov ecx, [eax] |
2340 | mov ecx, [eax] |
2341 | sub ecx, 512 |
2341 | sub ecx, 512 |
2342 | jae @f |
2342 | jae @f |
Line 2346... | Line 2346... | ||
2346 | xor eax, eax |
2346 | xor eax, eax |
2347 | rep stosb |
2347 | rep stosb |
2348 | pop eax |
2348 | pop eax |
2349 | @@: |
2349 | @@: |
2350 | mov [eax], ecx |
2350 | mov [eax], ecx |
2351 | mov dx, [edx*2+0x280000] |
2351 | mov dx, [edx*2+RAMDISK_FAT] |
2352 | mov [eax+4], dx ; high word is already zero |
2352 | mov [eax+4], dx ; high word is already zero |
2353 | popad |
2353 | popad |
2354 | xor eax, eax |
2354 | xor eax, eax |
2355 | ret |
2355 | ret |
2356 | .eof: |
2356 | .eof: |