Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- program MinimapCapture;
- (*
- Simple program to capture the minimap at 400x400 from the memory of RS.
- Requires: https://github.com/slackydev/Simba-MemScan/releases/tag/1.1
- Download the plugin (dll) named `memscan32`, add it to your "Plugins" folder in Simba
- Start RS, target RS, start the script
- *)
- {$loadlib memscan32.dll}
- type
- PInt32 = ^Int32;
- var
- mem: TMemScan;
- const
- _512: array of Int64 = [0,0,0,0,0,0,0,0];
- function BytesToTIA(data:TByteArray): TIntegerArray;
- begin
- SetLength(result, length(data) div 4);
- MemMove(data[0], result[0], Length(data));
- end;
- function ValidMapAddr(address:PtrUInt): Boolean;
- var
- data:Int32;
- tmp: TByteArray;
- begin
- data := PInt32(mem.CopyMem(address+8,4))^;
- if (data = 512 * 512) then
- begin
- tmp := mem.CopyMem(address+12, 64);
- Result := CompareMem(_512[0], tmp[0], 64); //row of black
- end;
- end;
- function GetMemBufferImage(scan:TMemScan; loc:PtrUInt; W,H:Int32): TMufasaBitmap;
- var
- data:TByteArray;
- ptr: PRGB32;
- begin
- data := scan.CopyMem(loc, W*H*SizeOf(TRGB32));
- Result.Init();
- Result.SetSize(W,H);
- ptr := Result.getData();
- MemMove(data[0], ptr^, Length(data));
- end;
- var
- res: TPtrIntArray;
- ptr: PtrUInt;
- raw: TByteArray;
- i,c: Int32;
- ints: TIntegerArray;
- image: TMufasaBitmap;
- begin
- mem.Init(GetTargetPID());
- while True do
- begin
- res := mem.FindInt32(512, 4);
- image := nil;
- for ptr in res do
- begin
- c := 0;
- raw := mem.CopyMem(ptr, 48);
- for i:=0 to 44 with 4 do
- if PInt32(raw+i)^ = 512 then Inc(c);
- if c >= 4 then
- begin
- ints := BytesToTIA(raw);
- for i in ints do
- if (i > $FFF) and ValidMapAddr(i) then begin
- image := GetMemBufferImage(mem, i+12, 512, 512);
- break;
- end;
- end;
- end;
- if image <> nil then
- ShowBitmap(image)
- else
- WriteLn('Process access error');
- image.Free();
- end;
- end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement