unit Advanced;
{ Advanced Routines Unit, Version 1.0, Copyright 1996 by George M. Tzoumas }
interface
procedure BSave(FN: String; P: Pointer; Length: Word);
procedure BLoad(FN: String; var P: Pointer);
implementation
const
MaxWidth = 2047;
type
BLine = Array [0..MaxWidth] of Byte;
WLine = Array [0..MaxWidth] of Word;
TPImgRec = Record
width,height : word;
Buf : array[0..10000] of byte;
end;
FPImgRec = Record
width,height,reserved : longint;
Buf : array[0..10000] of word;
end;
var
BorlandColorMap : array[0..15] of Word = (0,8,4,12,2,10,6,14,1,9,5,13,3,11,7,15);
Function BitOn(Position,Testbyte : Byte) : Boolean;
Var
Bt : Byte;
Begin
Bt :=$01;
Bt :=Bt Shl Position;
Biton :=(Bt And Testbyte) > 0;
End;
Function BytesPerRow(width : word) : Word;
begin
BytesPerRow :=(width+7) div 8;
end;
Procedure mpTOsp(Var mPlane : bLine;Var splane : wLine;BPR : Word);
Var
i,j : Word;
xpos : Word;
Col : Word;
ImgOff2,ImgOff3,ImgOff4 : Word;
begin
ImgOff2:=BPR;
ImgOff3:=BPR*2;
ImgOff4:=BPR*3;
xpos:=0;
FillChar(splane,SizeOf(sPlane),0);
For i:=0 to ImgOff2-1 do
begin
For j:=7 downto 0 do
begin
Col:=0;
if biton(j,mPlane[i]) then
begin
Inc(Col,1);
end;
if biton(j,mPlane[i+ImgOff2]) then
begin
Inc(Col,2);
end;
if biton(j,mPlane[i+ImgOff3]) then
begin
Inc(Col,4);
end;
if biton(j,mPlane[i+ImgOff4]) then
begin
Inc(Col,8);
end;
// Splane[xpos]:=Col;
Splane[xpos]:=BorlandColorMap[Col];
Inc(xpos);
end;
end;
end;
procedure BSave(FN: String; P: Pointer; Length: Word);
var
F: File;
begin
Assign(F, FN);
Rewrite(F, Length);
BlockWrite(F, P^, 1);
Close(F);
end;
Procedure TPImageToFPImage(var P : Pointer;PSize : LongInt);
var
FPImgPtr : ^FPImgRec;
TPImgPtr : ^TPImgRec;
bbuf : bline;
wbuf : wline;
pos,pos2 : word;
width,height : word;
BPR : word;
NP : Pointer;
NPSize : longint;
i,j : word;
begin
TPImgPtr:=P;
width:=TPImgPtr^.width+1;
height:=TPImgPtr^.height+1;
BPR:=BytesPerRow(width);
NPSize:=12+ (BPR*4*2)*height;
GetMem(NP, NPSize);
FPImgPtr:=NP;
FPImgPtr^.width:=width;
FPImgPtr^.height:=height;
FPImgPtr^.reserved:=0;
pos:=0;
pos2:=0;
For i:=1 to height do
begin
Move(TPImgPtr^.Buf[pos],bbuf,BPR*4);
mpTosp(bbuf,wbuf,BPR);
Move(wbuf,FPImgPtr^.Buf[pos2],width*2);
inc(pos,BPR*4);
inc(pos2,width);
end;
FreeMem(P,PSize);
P:=NP;
end;
procedure BLoad(FN: String; var P: Pointer);
var
F: File;
FSize : LongInt;
begin
Assign(F, FN);
Reset(F, 1);
FSize:= FileSize(F);
GetMem(P, FSize );
BlockRead(F, P^, FSize);
Close(F);
TPImageToFPImage(P,FSize);
end;
end.
Loading ...An unhandled exception occurred at $0000000000422608:
EAccessViolation: Access violation
$0000000000422608
$0000000000474991 BLOAD, line 155 of advanced.pas
I was able to compile the original TP code to the point where it was displaying the pacman and ghost properly but the maze was messed up.
Fixed loading of maze data. The game works now. :)
Very nice :)Indeed. :)
Wow! I didn't think you would be so quick.It was easy. The solution was to use the original BLoad procedure for loading the maze data.
It looks like you commented out all the cleardevice statements in the act procedures when you were debugging. You need to uncomment them for the act scenes to look right.
Anyway good job on porting this!
So I decided to create a repository on GitLab: Ghost Invasion (https://gitlab.com/rchastain/ghost-invasion)
Thank you for sharing it.
But I can't compile it using Lazarus GTK2, Ubuntu Mate 22.04.