mirror of
https://github.com/softdorothy/Glider4.git
synced 2024-09-23 07:55:41 +00:00
1 line
13 KiB
OpenEdge ABL
1 line
13 KiB
OpenEdge ABL
|
unit GlobalUtils;
interface
uses
SMS, Palettes, Globals;
procedure SetPage (secondPage: Boolean);
procedure SpinBall;
procedure GenericAlert (whatGives: Integer);
procedure DoTheSound (whichOne: Integer);
procedure DoTheBass (whichOne: Integer);
procedure DoTheMusic (whichOne: Integer);
function Randomize (range: Integer): Integer;
procedure CalcRoomScore;
procedure DoErrorSound (soundNumber: Integer);
procedure DissBlocks;
procedure DrawHiScores;
procedure HideMenuBar;
procedure ShowMenuBar;
procedure FatalError;
procedure RedrawWindowFrame;
implementation
{=================================}
procedure SetPage (secondPage: Boolean);
EXTERNAL;
{=================================}
procedure SpinBall;
var
tempByte: SignedByte;
begin
if (ballList = nil) then
Exit(SpinBall);
tempByte := HGetState(Handle(ballList));
HLock(Handle(ballList));
with ballList^^ do
begin
if (whichBall = -1) then
Exit(SpinBall);
if (whichBall >= kCursCount) then
whichBall := 1
else
whichBall := whichBall + 1;
if (useColorCursor) then
SetCCursor(ballC[whichBall])
else
SetCursor(ball[whichBall]^^);
end;
HSetState(Handle(ballList), tempByte);
end;
{=================================}
procedure GenericAlert;
var
dummyInt: Integer;
line1, line2: Str255;
alertHandle: AlertTHndl;
alertRect: Rect;
begin
if ((areFlipping) and (mainScreenHidden)) then
begin
mainScreenHidden := FALSE;
SetPage(mainScreenHidden);
end;
UseResFile(gliderResNum);
InitCursor;
if (whatGives > 0) then
begin
GetIndString(line1, rAlertStrIDs, whatGives);
line2 := '';
end
else
begin
GetIndString(line1, rAlertStrIDs, 1);
NumToString(whatGives, line2);
line2 := CONCAT('Error = ', line2);
end;
ParamText(line1, line2, '', '');
alertHandle := AlertTHndl(Get1Resource('ALRT', rAlertID));
if (alertHandle <> nil) then
begin
HNoPurge(Handle(alertHandle));
alertRect := alertHandle^^.boundsRect;
OffsetRect(alertRect, -alertRect.left, -alertRect.top);
dummyInt := (screenBits.bounds.right - alertRect.right) div 2;
OffsetRect(alertRect, dummyInt, 0);
dummyInt := (screenBits.bounds.bottom - alertRect.bottom) div 3;
OffsetRect(alertRect, 0, dummyInt);
alertHandle^^.boundsRect := alertRect;
HPurge(Handle(alertHandle));
end;
dummyInt := Alert(rAlertID, nil);
end;
{=================================}
procedure DoTheMusic;
begin
if (musicOn and soundOn) then
SMSStartChan(whichOne, 1);
end;
{=================================}
procedure DoTheBass;
begin
if (musicOn) then
SMSStart(whichOne);
end;
{=================================}
procedure DoTheSound;
begin
if (soundOn) then
SMSStart(whichOne);
end;
{=================================}
function Randomize;
var
rawResult: LongInt;
begin
rawResult := ABS(Random);
Randomize := (rawResult * range) div 32768;
end;
{=================================}
procedure CalcRoomScore;
var
index: Integer;
begin
roomScore := 0;
for index := 1 to 40 do
if (roomVisits[index]) then
roomScore := roomScore + (500 * (index div 10 + 1)) + (roomsPassed div 41) * 2000;
end;
{=================================}
procedure DoErrorSound;
var
dummyLong: LongInt;
tempVolume, i: Integer;
begin
GetSoundVol(tempVolume);
if (tempVolume <> 0) then
for i := 0 to soundNumber do
begin
FlashMenuBar(0);
Delay(8, dummyLong);
FlashMenuBar(0);
end;
end;
{=================================}
procedure DissBlocks;
var
h, v: Integer;
value: LongInt;
maskR: Rect;
begin
value := 1;
repeat
if (BTST(value, 0)) then
begin
value := BSR(value, 1);
value := BitXor(value, $240);
end
else
begin
value := BSR(value, 1);
end;
h := (value mod 32) * 16;
v := (value div 32) * 16;
SetRect(maskR, h, v, h + 16, v + 16);
if (inColor) then
CopyBits(BitMapPtr(virginCPtr^.portPixMap^)^, GrafPtr(mainWndo)^.portBits, maskR, maskR, srcCopy, wholeRgn)
else
CopyBits(offVirginMap, m
|