Advertisement
WarPie90

RS Minimap capture tool

Apr 1st, 2024 (edited)
863
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Delphi 1.99 KB | None | 0 0
  1. program MinimapCapture;
  2. (*
  3.   Simple program to capture the minimap at 400x400 from the memory of RS.
  4.   Requires: https://github.com/slackydev/Simba-MemScan/releases/tag/1.1
  5.  
  6.   Download the plugin (dll) named `memscan32`, add it to your "Plugins" folder in Simba
  7.  
  8.   Start RS, target RS, start the script
  9. *)
  10. {$loadlib memscan32.dll}
  11.  
  12. type
  13.   PInt32 = ^Int32;
  14.  
  15. var
  16.   mem: TMemScan;
  17.  
  18. const
  19.   _512: array of Int64 = [0,0,0,0,0,0,0,0];
  20.  
  21. function BytesToTIA(data:TByteArray): TIntegerArray;
  22. begin
  23.   SetLength(result, length(data) div 4);
  24.   MemMove(data[0], result[0], Length(data));
  25. end;
  26.  
  27. function ValidMapAddr(address:PtrUInt): Boolean;
  28. var
  29.   data:Int32;
  30.   tmp: TByteArray;
  31. begin
  32.   data := PInt32(mem.CopyMem(address+8,4))^;
  33.   if (data = 512 * 512) then
  34.   begin
  35.     tmp := mem.CopyMem(address+12, 64);
  36.     Result := CompareMem(_512[0], tmp[0], 64); //row of black
  37.   end;
  38. end;
  39.  
  40. function GetMemBufferImage(scan:TMemScan; loc:PtrUInt; W,H:Int32): TMufasaBitmap;
  41. var
  42.   data:TByteArray;
  43.   ptr: PRGB32;
  44. begin
  45.   data := scan.CopyMem(loc, W*H*SizeOf(TRGB32));
  46.   Result.Init();
  47.   Result.SetSize(W,H);
  48.   ptr := Result.getData();
  49.   MemMove(data[0], ptr^, Length(data));
  50. end;
  51.  
  52. var
  53.   res: TPtrIntArray;
  54.   ptr: PtrUInt;
  55.   raw: TByteArray;
  56.   i,c: Int32;
  57.   ints: TIntegerArray;
  58.   image: TMufasaBitmap;
  59. begin
  60.   mem.Init(GetTargetPID());
  61.  
  62.   while True do
  63.   begin
  64.     res := mem.FindInt32(512, 4);
  65.  
  66.     image := nil;
  67.     for ptr in res do
  68.     begin
  69.       c   := 0;
  70.       raw := mem.CopyMem(ptr, 48);
  71.  
  72.       for i:=0 to 44 with 4 do
  73.         if PInt32(raw+i)^ = 512 then Inc(c);
  74.  
  75.       if c >= 4 then
  76.       begin
  77.         ints := BytesToTIA(raw);
  78.         for i in ints do
  79.           if (i > $FFF) and ValidMapAddr(i) then begin
  80.             image := GetMemBufferImage(mem, i+12, 512, 512);
  81.             break;
  82.           end;
  83.       end;
  84.     end;
  85.  
  86.     if image <> nil then
  87.       ShowBitmap(image)
  88.     else
  89.       WriteLn('Process access error');
  90.  
  91.     image.Free();
  92.   end;
  93. end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement