...
 
Commits (2)
......@@ -189,40 +189,7 @@ type
{$include sakufiber-header.pas}
var event : record
// Various callbacks triggered by user action or by timer.
// Must be separated by type for most efficient iteration.
area : array of record
namu : UTF8string;
inViewport : dword;
areaLoc : TEdgeCoords; // 32k relative to viewport, pixel value relative to game window
centerPoint : TCoordP; // precalculated area center, pixel value relative to game window
triggerLabel, mouseOnLabel, mouseOffLabel : UTF8string;
state : byte; // 1 if currently overed, 0 if not
mouseOnly : boolean;
end;
gob : array of record
namu : UTF8string;
gobNamu : UTF8string;
gobNum : dword;
triggerLabel, mouseOnLabel, mouseOffLabel : UTF8string;
state : byte; // 1 if currently overed, 0 if not
mouseOnly : boolean;
end;
timer : array of record
namu : UTF8string;
triggerFreq : dword; // timers trigger every x msecs
timerCounter : dword; // accumulates every frame
triggerLabel : UTF8string; // on trigger, this is run in a new fiber
end;
normalInterrupt : record
triggerLabel : UTF8string;
end;
escInterrupt : record
triggerLabel : UTF8string;
end;
hasTriggeredInterrupt : boolean; // TRUE if an interrupt was triggered this frame
end;
{$include sakuevents.pas}
// Commandline parameters.
var sakuparam : record
......@@ -337,9 +304,8 @@ procedure SpawnWindow; forward;
function PollKey(keyval : byte) : longint; forward;
{$include sakuconfig.pas}
{$include sakuviewports.pas}
{$include sakusavematic.pas}
// Uncomment this when compiling with HeapTrace. Call this whenever to test if at that moment the heap has yet been messed up.
{procedure CheckHeap;
......@@ -404,76 +370,6 @@ begin
result := (ARGB and $F0) + (ARGB and $F000) shr 4 + (ARGB and $F00000) shr 8 + (ARGB and $F0000000) shr 28;
end;
procedure ReadSeenGFX;
// Initialises the seengfx list, opens the .SAV file, reads previously seen graphics into the list.
var filu : file;
i, j : dword;
tux : string;
begin
exit;
j := 0; seenGfxItems := 0; seenGfxSize := 4096;
if seenGfxP <> NIL then begin freemem(seenGfxP); seenGfxP := NIL; end;
getmem(seenGfxP, seenGfxSize);
tux := sakuparam.workDir + sysvar.activeProjectName;
while (tux <> '') and (tux[length(tux)] <> '.') do dec(byte(tux[0]));
if tux = '' then halt(81);
tux := tux + 'sav';
assign(filu, tux);
filemode := 0; reset(filu, 1); // read-only access
i := IOresult;
if i = 0 then begin
// Read the signature.
blockread(filu, j, 4);
if j <> $CBCABAAB then
LogError('Wrong sig in SAV file')
else begin
// Read the list size.
blockread(filu, seenGfxItems, 2);
i := (seenGfxItems * 16 + 1024) and $FFFFFF00;
if i > seenGfxSize then begin
freemem(seenGfxP); seenGfxP := NIL;
seenGfxSize := i;
getmem(seenGfxP, seenGfxSize);
end;
blockread(filu, seenGfxP^, seenGfxItems * 16);
Log('Seen gfx in SAV: ' + strdec(seenGfxItems));
end;
close(filu);
end
else LogError('No SAV file found');
while IOresult <> 0 do ;
end;
procedure SaveGlobals;
// Attempts to write the seen graphics and strings lists into a SAV file.
var filu : file;
i, j : dword;
tux : string;
begin
tux := sakuparam.workDir + sysvar.activeProjectName;
while (tux <> '') and (tux[length(tux)] <> '.') do dec(byte(tux[0]));
if tux = '' then halt(81);
tux := lowercase(tux) + 'sav';
assign(filu, tux);
filemode := 1; rewrite(filu, 1); // write-only access
i := IOresult;
if i = 0 then begin
// Write the signature.
j := $CBCABAAB;
blockwrite(filu, j, 4);
// Write the seen graphics list.
blockwrite(filu, seenGfxItems, 2);
blockwrite(filu, seenGfxP^, seenGfxItems * 16);
// Write the seen strings lists.
close(filu);
end
else LogError(errortxt(i) + ' trying to write SAV');
while IOresult <> 0 do ;
end;
procedure ResetDefaults;
// Resets the engine state nearly completely to default values.
// Runscript calls this whenever someone wants to start executing the main script, to ensure returning to main menu will not
......@@ -510,11 +406,7 @@ begin
sysvar.metaState := MS_NORMAL;
// Reset events.
setlength(event.area, 0);
setlength(event.gob, 0);
setlength(event.timer, 0);
event.normalInterrupt.triggerLabel := '';
event.escInterrupt.triggerLabel := '';
ResetEvents;
// Reset fibers.
if FiberHub.fiberCount <> 0 then with FiberHub do begin
......
{ }
{ Copyright 2009 :: Kirinn Bunnylin / Mooncore }
{ }
{ This file is part of SuperSakura. }
{ }
{ SuperSakura is free software: you can redistribute it and/or modify }
{ it under the terms of the GNU General Public License as published by }
{ the Free Software Foundation, either version 3 of the License, or }
{ (at your option) any later version. }
{ }
{ SuperSakura is distributed in the hope that it will be useful, }
{ but WITHOUT ANY WARRANTY; without even the implied warranty of }
{ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the }
{ GNU General Public License for more details. }
{ }
{ You should have received a copy of the GNU General Public License }
{ along with SuperSakura. If not, see <https://www.gnu.org/licenses/>. }
{ }
var event : record
// Various callbacks triggered by user action or by timer.
// Must be separated by type for most efficient iteration.
area : array of record
namu : UTF8string;
inViewport : dword;
areaLoc : TEdgeCoords; // 32k relative to viewport, pixel value relative to game window
centerPoint : TCoordP; // precalculated area center, pixel value relative to game window
triggerLabel, mouseOnLabel, mouseOffLabel : UTF8string;
state : byte; // 1 if currently overed, 0 if not
mouseOnly : boolean;
end;
gob : array of record
namu : UTF8string;
gobNamu : UTF8string;
gobNum : dword;
triggerLabel, mouseOnLabel, mouseOffLabel : UTF8string;
state : byte; // 1 if currently overed, 0 if not
mouseOnly : boolean;
end;
timer : array of record
namu : UTF8string;
triggerFreq : dword; // timers trigger every x msecs
timerCounter : dword; // accumulates every frame
triggerLabel : UTF8string; // on trigger, this is run in a new fiber
end;
normalInterrupt : record
triggerLabel : UTF8string;
end;
escInterrupt : record
triggerLabel : UTF8string;
end;
hasTriggeredInterrupt : boolean; // TRUE if an interrupt was triggered this frame
end;
procedure ResetEvents;
begin
setlength(event.area, 0);
setlength(event.gob, 0);
setlength(event.timer, 0);
event.normalInterrupt.triggerLabel := '';
event.escInterrupt.triggerLabel := '';
end;
{ }
{ Copyright 2009 :: Kirinn Bunnylin / Mooncore }
{ }
{ This file is part of SuperSakura. }
{ }
{ SuperSakura is free software: you can redistribute it and/or modify }
{ it under the terms of the GNU General Public License as published by }
{ the Free Software Foundation, either version 3 of the License, or }
{ (at your option) any later version. }
{ }
{ SuperSakura is distributed in the hope that it will be useful, }
{ but WITHOUT ANY WARRANTY; without even the implied warranty of }
{ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the }
{ GNU General Public License for more details. }
{ }
{ You should have received a copy of the GNU General Public License }
{ along with SuperSakura. If not, see <https://www.gnu.org/licenses/>. }
{ }
procedure ReadSeenGFX;
// Initialises the seengfx list, opens the .SAV file, reads previously seen graphics into the list.
var filu : file;
i, j : dword;
tux : string;
begin
exit;
j := 0; seenGfxItems := 0; seenGfxSize := 4096;
if seenGfxP <> NIL then begin freemem(seenGfxP); seenGfxP := NIL; end;
getmem(seenGfxP, seenGfxSize);
tux := sakuparam.workDir + sysvar.activeProjectName;
while (tux <> '') and (tux[length(tux)] <> '.') do dec(byte(tux[0]));
if tux = '' then halt(81);
tux := tux + 'sav';
assign(filu, tux);
filemode := 0; reset(filu, 1); // read-only access
i := IOresult;
if i = 0 then begin
// Read the signature.
blockread(filu, j, 4);
if j <> $CBCABAAB then
LogError('Wrong sig in SAV file')
else begin
// Read the list size.
blockread(filu, seenGfxItems, 2);
i := (seenGfxItems * 16 + 1024) and $FFFFFF00;
if i > seenGfxSize then begin
freemem(seenGfxP); seenGfxP := NIL;
seenGfxSize := i;
getmem(seenGfxP, seenGfxSize);
end;
blockread(filu, seenGfxP^, seenGfxItems * 16);
Log('Seen gfx in SAV: ' + strdec(seenGfxItems));
end;
close(filu);
end
else LogError('No SAV file found');
while IOresult <> 0 do ;
end;
procedure SaveGlobals;
// Attempts to write the seen graphics and strings lists into a SAV file.
var filu : file;
i, j : dword;
tux : string;
begin
tux := sakuparam.workDir + sysvar.activeProjectName;
while (tux <> '') and (tux[length(tux)] <> '.') do dec(byte(tux[0]));
if tux = '' then halt(81);
tux := lowercase(tux) + 'sav';
assign(filu, tux);
filemode := 1; rewrite(filu, 1); // write-only access
i := IOresult;
if i = 0 then begin
// Write the signature.
j := $CBCABAAB;
blockwrite(filu, j, 4);
// Write the seen graphics list.
blockwrite(filu, seenGfxItems, 2);
blockwrite(filu, seenGfxP^, seenGfxItems * 16);
// Write the seen strings lists.
close(filu);
end
else LogError(errortxt(i) + ' trying to write SAV');
while IOresult <> 0 do ;
end;
......@@ -26,7 +26,7 @@
<FormatVersion Value="2"/>
<Modes Count="0"/>
</RunParams>
<Units Count="60">
<Units Count="62">
<Unit0>
<Filename Value="supersakura.pas"/>
<IsPartOfProject Value="True"/>
......@@ -270,6 +270,14 @@
<Filename Value="inc/sakurendermatic-sdl.pas"/>
<IsPartOfProject Value="True"/>
</Unit59>
<Unit60>
<Filename Value="inc/sakuevents.pas"/>
<IsPartOfProject Value="True"/>
</Unit60>
<Unit61>
<Filename Value="inc/sakusavematic.pas"/>
<IsPartOfProject Value="True"/>
</Unit61>
</Units>
</ProjectOptions>
<CompilerOptions>
......