A lot being said above, and you need to start and fig deeper and learn why and how.
Anyway, this issue is also easy to fix, the cause is this declaration in GR32.pas
PColor32Array = ^TColor32Array;
TColor32Array = array [0..0] of TColor32; // pain in the back, and will trigger overflow check
TArrayOfColor32 = array of TColor32;
And the fix or another slap work around without testing but again using my extra power
procedure TRenderer.ApplyRemovedTerrain(X, Y, W, H: Integer);
type
TTempHackColor32Arr = array [0.. MaxInt div SizeOf(TColor32) -1 ] of TColor32;
PTempHackColor32Arr = ^TTempHackColor32Arr;
var
//PhysicsArrPtr, TerrLayerArrPtr: PColor32Array;
PhysicsArrPtr, TerrLayerArrPtr: PTempHackColor32Arr;
cx, cy: Integer;
MapWidth: Integer; // Width of the total PhysicsMap
begin
// This has two applications:
// - Removing all non-solid pixels from rlTerrain (possibly created by blending)
// - Removed pixels from PhysicsMap copied to rlTerrain (called when applying a mask from LemGame via RenderInterface)
PhysicsArrPtr := PTempHackColor32Arr(PhysicsMap.Bits);
TerrLayerArrPtr := PTempHackColor32Arr(fLayers[rlTerrain].Bits);
The best is to fix GR32 with the following, but don't do that on your own, this is up to Anders
PColor32Array = ^TColor32Array;
//TColor32Array = array [0..0] of TColor32;
TColor32Array = array [0.. MaxInt div SizeOf(TColor32) -1 ] of TColor32;
TArrayOfColor32 = array of TColor32;