народ можете помоч с алгоритмом
uses dos; type ftype = file of byte; var var_2: Word; Buf: array[0..99] of Byte; Count : Word; tmpStr : String; word_One: Word; cur_Byte, byte_243C: Byte; fInf : ftype; fOut : ftype; tmp1 : Byte; tmp2 : Byte; tmp3 : Byte; tmp4 : Byte; wTmp1 : Word; wTmp2 : Word; lArr1 : array[1..20] of longint; lArr2 : array[1..20] of longint; var dword_2338 : longint; dword_233C : longint; dword_2340 : longint; dword_2344 : longint; dword_2348 : longint; dword_234C : longint; dword_2350 : longint; dword_2354 : longint; dword_2358 : longint; dword_235C : longint; dword_2360 : longint; dword_2364 : longint; dword_2368 : longint; dword_2390 : longint; dword_2394 : longint; dword_236C : longint; dword_2370 : longint; dword_2374 : longint; dword_2378 : longint; dword_237C : longint; dword_2380 : longint; dword_2384 : longint; dword_2388 : longint; dword_2398 : longint; procedure sub_0(var fin:ftype); begin dword_2350 := dword_233C shr 3; dword_2390 := dword_2338 + dword_2350; dword_2394 := dword_233C and 7; dword_2360 := 8; dword_2394 := dword_2360 - dword_2394; dword_2368 := 0; while (dword_2394 < dword_2340) do begin Inc(dword_2350); dword_2360 := $FF; dword_2364 := dword_2360 shl dword_2394; dword_235C := not dword_2364; if (dword_2398 < dword_2390) or (dword_2398 = 0) then begin Read(fin, byte_243C); dword_2398 := dword_2390; end; dword_2364 := byte_243C; Inc(dword_2390); dword_2358 := dword_2364 and dword_235C; dword_2368 := dword_2368 shl dword_2394; dword_2340 := dword_2340 - dword_2394; dword_2394 := 8; dword_2368 := dword_2368 or dword_2358; end; dword_2358 := dword_2368 shl dword_2340; dword_2368 := dword_2338 + dword_2350; if (dword_2398 < dword_2368) or (dword_2398 = 0) then begin Read(fin, byte_243C); dword_2398 := dword_2368; end; dword_235C := byte_243C; dword_2364 := dword_2394 - dword_2340; dword_2360 := dword_235C shr dword_2364; dword_2364 := $FF; dword_2368 := dword_2364 shl dword_2340; dword_235C := not dword_2368; dword_2368 := dword_2360 and dword_235C; dword_2390 := dword_2358 or dword_2368; end; procedure sub_2E4(var fI,fO:ftype); {var Buf: byte;} begin dword_236C := dword_2338; dword_2370 := dword_233C; dword_2374 := dword_2340; dword_237C := 0; dword_2338 := dword_2370; dword_233C := 0; dword_2340 := 8; sub_0(fI); dword_2388 := dword_2390; dword_2338 := dword_2370; dword_233C := 8; dword_2340 := 8; sub_0(fI); dword_2378 := 16; dword_2384 := dword_2390; while dword_237C < dword_2374 do begin dword_2338 := dword_2370; while true do begin dword_233C := dword_2378; dword_2340 := 1; sub_0(fI); dword_2394 := 1; Inc(dword_2378); if dword_2390 <> dword_2394 then break; dword_233C := dword_2378; dword_2340 := dword_2388; dword_2338 := dword_2370; sub_0(fI); dword_2380 := dword_2390; dword_2338 := dword_2370; dword_2378 := dword_2378 + dword_2388; dword_233C := dword_2378; dword_2340 := dword_2384; sub_0(fI); dword_2378 := dword_2378 + dword_2384; dword_2348 := dword_2390 + 3; if dword_237C < dword_2380 then begin Close(fI); Exit; end; dword_2364 := dword_237C + dword_2348; if dword_2374 < dword_2364 then begin dword_2390 := -1; Close(fI); Exit; end else dword_234C := dword_2348; if dword_234C <= 0 then dword_2358 := 1 else dword_2358 := 0; if dword_2358 <> 0 then dword_234C := 0; dword_2350 := dword_234C Shr 3; dword_2344 := 0; if dword_2350 <> 0 then begin dword_2394 := dword_237C - dword_2380 + dword_236C; dword_2390 := dword_236C + dword_237C; dword_2344 := dword_2350 Shl 3; repeat Seek(fO, dword_2394); Read(fO, Buf[1]); dword_2364 := Buf[1]; Seek(fO, dword_2390); Buf[1]:= dword_2364; Write(fO, Buf[1]); Seek(fO, dword_2394 + 1); Read(fO, Buf[1]); dword_2360 := Buf[1]; Seek(fO, dword_2390 + 1); Buf[1]:= dword_2360; Write(fO, Buf[1]); Seek(fO, dword_2394 + 2); Read(fO, Buf[1]); dword_235C := Buf[1]; Seek(fO, dword_2390 + 2); Buf[1]:= dword_235C; Write(fO, Buf[1]); Seek(fO, dword_2394 + 3); Read(fO, Buf[1]); dword_2358 := Buf[1]; Seek(fO, dword_2390 + 3); Buf[1]:= dword_2358; Write(fO, Buf[1]); Seek(fO, dword_2394 + 4); Read(fO, Buf[1]); dword_2360 := Buf[1]; Seek(fO, dword_2390 + 4); Buf[1]:= dword_2360; Write(fO, Buf[1]); Seek(fO, dword_2394 + 5); Read(fO, Buf[1]); dword_235C := Buf[1]; Buf[1]:= dword_235C; Seek(fO, dword_2390 + 5); Write(fO, Buf[1]); Seek(fO, dword_2394 + 6); Read(fO, Buf[1]); dword_2358 := Buf[1]; Buf[1]:= dword_2358; Seek(fO, dword_2390 + 6); Write(fO, Buf[1]); Seek(fO, dword_2394 + 7); Read(fO, Buf[1]); dword_2368 := Buf[1]; Buf[1]:= dword_2368; Seek(fO, dword_2390 + 7); Write(fO, Buf[1]); Inc(dword_2390, 8); Inc(dword_2394, 8); Dec(dword_2350); until dword_2350 = 0; end; dword_2350 := dword_234C And 7; dword_2394 := dword_237C - dword_2380; if dword_2350 <> 0 then begin dword_2394 := dword_2394 + dword_2344 + dword_236C; dword_2390 := dword_237C + dword_2344 + dword_236C; repeat Inc(dword_2390); Inc(dword_2394); Seek(fO, dword_2394 - 1); Read(fO, Buf[1]); dword_2360 := Buf[1]; Dec(dword_2350); Seek(fO, dword_2390 - 1); Buf[1]:= dword_2360; Write(fO, Buf[1]); until dword_2350 = 0; end; dword_237C := dword_237C + dword_2348; if dword_237C >= dword_2374 then begin Close(fI); Exit; end; dword_2338 := dword_2370; end; {while 1} dword_233C := dword_2378; dword_2340 := 8; dword_2338 := dword_2370; sub_0(fI); Inc(dword_2378, 8); dword_2380 := dword_236C + dword_237C; Inc(dword_237C); Buf[1]:= dword_2390; Seek(fO, dword_2380); Write(fO, Buf[1]); end; Close(fI); end; begin Assign(fInf, 'main.img'); Reset(fInf); Count := 0; while (true) do begin { loc_CFE } Read(fInf, cur_Byte); Inc(Count); if cur_Byte = $A0 then begin { loc_D25 } Read(fInf, cur_Byte); if cur_Byte = $2 then begin { loc_D4C } { нашли сигнатуру 02A0h } Seek(fInf, Count-2); Read(fInf, cur_Byte); Writeln(0, cur_Byte, ' ', Count); var_2 := cur_Byte; if var_2 > 1 then begin { loc_DD5 } for word_One := 1 to var_2 do begin Seek(fInf, (word_One shl 4)+(Count-$0D)); Read(fInf, tmp1, tmp2, tmp3, tmp4); wTmp1 := tmp2+(tmp1 shl 8); wTmp2 := tmp4+(tmp3 shl 8); lArr1[word_One] := wTmp1*$10000+wTmp2; Seek(fInf, (word_One shl 4) + (Count-9)); Read(fInf, tmp1, tmp2, tmp3, tmp4); wTmp1 := tmp2+(tmp1 shl 8); wTmp2 := tmp4+(tmp3 shl 8); lArr2[word_One] := wTmp1*$10000+wTmp2; Writeln('off=', lArr1[word_One], ' ', lArr2[word_One]); end; {for} end; { loc_F9E: } var_2 := cur_Byte; if var_2 > 1 then begin { loc_FB1 } for word_One := 1 to var_2 do begin Str(word_One, tmpStr); if word_One < 10 then tmpStr := '0'+tmpStr; tmpStr := 're.'+tmpStr; Assign(fOut, tmpStr); ReWrite(fOut); dword_2338 := 0; dword_233C := 0; dword_2340 := 0; dword_2344 := 0; dword_2348 := 0; dword_234C := 0; dword_2350 := 0; dword_2354 := 0; dword_2358 := 0; dword_235C := 0; dword_2360 := 0; dword_2364 := 0; dword_2368 := 0; dword_2390 := 0; dword_2394 := 0; dword_236C := 0; dword_2370 := 0; dword_2374 := 0; dword_2378 := 0; dword_237C := 0; dword_2380 := 0; dword_2384 := 0; dword_2388 := 0; dword_2368 := $0B; dword_236C := $28; dword_2364 := 1; dword_235C := 0; dword_2338 := 0; dword_233C := dword_2374 + dword_235C; { ! } dword_2340 := lArr2[word_One]; dword_2398 := 0; Reset(fInf); Seek(fInf, lArr1[word_One]); sub_2E4(fInf, fOut); Close(fOut); end; { for } end; { loc_11B2: } Halt(0); end else Inc(Count); end; end; {while(true)} end.