This is the problem with OSR though. Here's what I found:
Running it without threads:
Simba Code:
{$DEFINE SMART8}
{$I SRL-OSR/SRL.Simba}
{$I SRL-OSR/SRL/misc/SmartGraphics.simba}
begin
SetupSRL;
SMART_SetupDebug();
SMART_DrawBoxEx(True, True, IntToBox(0, 0, 200, 200), clRed);
end.
Not only say:
Compiled successfully in 10125 ms.
But.. It didn't draw at all.. Even when I manually called
SMART_SetupDebug;
So I looked into SmartGraphics.Simba to see where the problem lies.. and I end up finding some of the dirtiest/hard to read patches I ever saw in Simba's includes.. What was once clean is now a mess:
This function:
Simba Code:
procedure SMART_SetupDebug;
begin
SmartSetDebug(smartCurrentTarget, True);
{$IFDEF LAPE}
SMART_Canvas.init();
{$ELSE}
SMART_Canvas := TMufasaBitmap.Create;
{$ENDIF}
SMART_Canvas.setSize(765, 503);
{$IFDEF LAPE}
SetPersistentMemoryBitmap(SMART_Canvas.getIndex(), SmartDebugArray(smartCurrentTarget), 765, 503);
SMART_Canvas.drawClear(0); //clear it in case of previous usage
{$ELSE}
SetPersistentMemoryBitmap(SMART_Canvas.index, SmartDebugArray(smartCurrentTarget), 765, 503);
SMART_Canvas.FastDrawClear(0); //clear it in case of previous usage
{$ENDIF}
SMART_DebugSetup := true;
if not SMART_Reset then
AddOnTerminate('SMART_FreeDebug');
end;
With that many pre-processor arguments, I gave up and cleaned it up:
So it now looks like:
Simba Code:
procedure SMART_SetupDebug;
begin
SmartSetDebug(smartCurrentTarget, True);
{$IFDEF LAPE}
SMART_Canvas.init(Client.GetMBitmaps);
SMART_Canvas.SetPersistentMemory(SmartDebugArray(smartCurrentTarget), 765, 503);
SMART_Canvas.drawClear(0);
{$ELSE}
SMART_Canvas := TMufasaBitmap.Create;
SMART_Canvas.setSize(765, 503);
SetPersistentMemoryBitmap(SMART_Canvas.index, SmartDebugArray(smartCurrentTarget), 765, 503);
SMART_Canvas.FastDrawClear(0);
{$ENDIF}
SMART_DebugSetup := true;
if not SMART_Reset then
AddOnTerminate('SMART_FreeDebug');
end;
With this, you can clearly see which section is Lape and which section is PS..
And the difference is that instead of Printing "
Bitmap at line 32 does not exist", it now draws on Smart.. The main difference is the
TMufasaBitmap.init(Client.GetMBitmaps). I don't mean to bash anyone here but whoever ported the old code to Lape missed a lot of things..
Client.GetMBitmaps is needed if you want to use
Bitmap.GetIndex() and garbage cleanup.. Otherwise it is your responsibility for everything. At least, that's what I was told.
Anyway, until the include itself is fixed, you cannot draw normally and you cannot draw with Threads as a consequence. I can try and help out and fix it up I guess.. I see my name in that include but with the code the way it is now, I don't recognize what portions I wrote or helped write..
It is also printing a lot of "
Bitmap not freed" stuff for me :S