* Dyn array for interference bitmap

This commit is contained in:
Michaël Van Canneyt 2025-03-17 18:00:30 +01:00
parent b3a8fd009a
commit b67e6ed75e

View File

@ -42,22 +42,25 @@ unit rgobj;
aasmtai,aasmdata,aasmsym,aasmcpu, aasmtai,aasmdata,aasmsym,aasmcpu,
cclasses,globtype,cgbase,cgutils; cclasses,globtype,cgbase,cgutils;
const
interferenceBitmap2Size = 256;
type type
{ {
The interference bitmap contains of 2 layers: The interference bitmap contains of 2 layers:
layer 1 - 256*256 blocks with pointers to layer 2 blocks layer 1 - 256*256 blocks with pointers to layer 2 blocks
layer 2 - blocks of 32*256 (32 bytes = 256 bits) layer 2 - blocks of 32*256 (32 bytes = 256 bits)
} }
Tinterferencebitmap2 = array[byte] of set of byte;
Pinterferencebitmap2 = ^Tinterferencebitmap2; Tinterferencebitmap2 = array of set of byte;
Tinterferencebitmap1 = array[byte] of Pinterferencebitmap2; Tinterferencebitmap1 = array[byte] of Tinterferencebitmap2;
pinterferencebitmap1 = ^tinterferencebitmap1; tinterferencebitmap1Array = array of tinterferencebitmap1;
Tinterferencebitmap=class Tinterferencebitmap=class
private private
maxx1, maxx1,
maxy1 : byte; maxy1 : byte;
fbitmap : pinterferencebitmap1; fbitmap : tinterferencebitmap1Array;
function getbitmap(x,y:tsuperregister):boolean; function getbitmap(x,y:tsuperregister):boolean;
procedure setbitmap(x,y:tsuperregister;b:boolean); procedure setbitmap(x,y:tsuperregister;b:boolean);
public public
@ -367,7 +370,7 @@ unit rgobj;
begin begin
inherited create; inherited create;
maxx1:=1; maxx1:=1;
fbitmap:=AllocMem(sizeof(tinterferencebitmap1)*2); SetLength(fbitmap,2);
end; end;
@ -379,21 +382,21 @@ unit rgobj;
for i:=0 to maxx1 do for i:=0 to maxx1 do
for j:=0 to maxy1 do for j:=0 to maxy1 do
if assigned(fbitmap[i,j]) then if assigned(fbitmap[i,j]) then
dispose(fbitmap[i,j]); fbitmap[i,j]:=nil;
freemem(fbitmap); fbitmap:=nil;
end; end;
function tinterferencebitmap.getbitmap(x,y:tsuperregister):boolean; function tinterferencebitmap.getbitmap(x,y:tsuperregister):boolean;
var var
page : pinterferencebitmap2; page : TInterferencebitmap2;
begin begin
result:=false; result:=false;
if (x shr 8>maxx1) then if (x shr 8>maxx1) then
exit; exit;
page:=fbitmap[x shr 8,y shr 8]; page:=fbitmap[x shr 8,y shr 8];
result:=assigned(page) and result:=assigned(page) and
((x and $ff) in page^[y and $ff]); ((x and $ff) in page[y and $ff]);
end; end;
@ -405,21 +408,19 @@ unit rgobj;
y1:=y shr 8; y1:=y shr 8;
if x1>maxx1 then if x1>maxx1 then
begin begin
reallocmem(fbitmap,sizeof(tinterferencebitmap1)*(x1+1)); Setlength(fbitmap,x1+1);
fillchar(fbitmap[maxx1+1],sizeof(tinterferencebitmap1)*(x1-maxx1),0);
maxx1:=x1; maxx1:=x1;
end; end;
if not assigned(fbitmap[x1,y1]) then if not assigned(fbitmap[x1,y1]) then
begin begin
if y1>maxy1 then if y1>maxy1 then
maxy1:=y1; maxy1:=y1;
new(fbitmap[x1,y1]); SetLength(fbitmap[x1,y1],interferenceBitmap2Size);
fillchar(fbitmap[x1,y1]^,sizeof(tinterferencebitmap2),0);
end; end;
if b then if b then
include(fbitmap[x1,y1]^[y and $ff],(x and $ff)) include(fbitmap[x1,y1][y and $ff],(x and $ff))
else else
exclude(fbitmap[x1,y1]^[y and $ff],(x and $ff)); exclude(fbitmap[x1,y1][y and $ff],(x and $ff));
end; end;