SRL Archive - FAQ

Simba -> Compiling


shadowrecon

2012-03-29 13:41:01

Im trying to port over the SPS walking system for SCAR. Im running Delphi XE2 and im trying to compile just the SPS lib. I have the Simba files for bitmaps, types ect. But for some reason i have errors flying from every file. What was/is the program you guys are using to compile this?

Sex

2012-03-29 14:06:24

Simba is compiled using Lazarus which uses FPC.

shadowrecon

2012-03-29 15:20:06

Im not familiar with that plugin/application. I do understand the Free Pascal Compiler part.
Let me explain what im trying to do:
Im trying to compile the SPS dll file so that it will work with SCAR. Right now the dll file will not register its functions in SCAR Im assuming because the memory manger and maybe because the lib uses registers and inlines and not stdcalls. Any help would be greatly appreciated.

EDIT:
After downloading and installing that program when i went to compile the simba project i got this error
"..\..\Units\MMLAddon\mmlpsthread.pas(94,11) Fatal: Can't find unit lpparser used by mmlpsthread"

Whats the problem?

Harry

2012-03-29 15:26:00

From: shadowrecon
trying to compile the SPS dll file so that it will work with SCAR

Then ask SCAR's forums. I don't think it is possible without massively modifying the SPS source to begin with. You have to compile SPS against Simba's source.

Markus

2012-03-29 15:30:45

As SPS uses a few Simba specific things (namely the internal Simba bitmap), you can not just compile it for SCAR. You'd need to modify it so it uses other kind of bitmaps which is a bit of work, not impossible though.
Official compiling uses FPC 2.4.4 + Lazarus fixes. Simba is NOT compatible with Delphi.

shadowrecon

2012-03-29 15:34:37

My main issue is with the muffusabitmaps the FData class, in the source states (Fake Data) but its being used all over the place. If i could get a grasp on that the rest i could easily port over. Do any of you guys know what is going on under the hood of the FData Class?

Wizzup?

2012-03-29 15:40:21

Simba was not written for Delphi. I doubt it will compile with Delphi. You should use Lazarus + Freepascal if anything. Aside from that, Simba is completely GPL, so anything using Simba (including SPS) is also GPL, which means you're not allowed to link against this in a proprietary program.

To further answer your question - FData is simply a pointer to bitmap data. It does not stand for Fake Data either. The F merely indicates it is a class member. It's some weird pascal standard. :)

You'd probably be better of rewriting SPS completely. Especially since you can't easily re-use any SCAR functions like you can with Simba.

Or even better, just use Simba for whatever it is you want to do. (Or file a feature request if Simba can't do it)

E: If we're nitpicking, then you wouldn't even legally be allowed to ship or _dynamically_ load GPL code in a non-gpl program. (Which includes SMART)

Markus

2012-03-29 15:43:58

@ lpparser: git submodule init, you need to have Lape else it can't compile Lape ;)

Sex

2012-03-29 17:42:33

From: shadowrecon
Im not familiar with that plugin/application. I do understand the Free Pascal Compiler part.
Let me explain what im trying to do:
Im trying to compile the SPS dll file so that it will work with SCAR. Right now the dll file will not register its functions in SCAR Im assuming because the memory manger and maybe because the lib uses registers and inlines and not stdcalls. Any help would be greatly appreciated.

EDIT:
After downloading and installing that program when i went to compile the simba project i got this error
"..\..\Units\MMLAddon\mmlpsthread.pas(94,11) Fatal: Can't find unit lpparser used by mmlpsthread"

Whats the problem?
You need to download Lape. If you used git, try git submodule init && git submodule update.

Edit: :ninja:'d. Btw, you can disable Lape support by editing Simba.inc and commenting out {$DEFINE USE_LAPE} :).

shadowrecon

2012-03-29 20:20:21

Thanks for all the responses you guys seem to have a very active community. I Would love to switch to simba but when i first got back into scripting i turned to scar and as of now there includes are clearly labeled and easier to follow. Not that i cant tell time was put into your guys includes but alot fo the functions at the time were broken and had not been updated in years. ( I assume because color based scripting was left in the dark for a while as reflection had taken over )

Back on topic here is a quote from the bitmap unit about FData
public
OnDestroy : procedure(Bitmap : TMufasaBitmap) of object;
//FakeData : array of TRGB32;
FData : PRGB32;


This is why i was confused as what was FakeData? lol. As wizzup? stated its a pointer which i assume points to a data set of RBG values? If its not RGB values then whats being passed in this function? Is there another way to pass the information in a separate variable?

 
function SPS_MakeColorBoxEx(bmp: TMufasaBitmap; x1, y1: integer): TIntegerArray;
var
x, y, width: integer;
C: TRGB32;
begin
SetLength(Result, 3);
width := bmp.Width; // may not be necessary, but should help a bit.

for x := (x1 + 4) downto x1 do // flipped these to downto since order is irrelevant
for y := (y1 + 4) downto y1 do // downto will calc the initial only once rather than each time.
begin
try
C := bmp.FData[y * width + x];
Result[0] := Result[0] + C.R;
Result[1] := Result[1] + C.G;
Result[2] := Result[2] + C.B;
except end;
end;
end;

shadowrecon

2012-03-29 20:28:08

From: Sex
You need to download Lape. If you used git, try git submodule init && git submodule update.

Edit: :ninja:'d. Btw, you can disable Lape support by editing Simba.inc and commenting out {$DEFINE USE_LAPE} :).

After commenting that out i got another error. Heres the decription ->


C:\Users\C\Desktop\MerlijnWajer-Simba-simba-0.99-rc3-31-gbc53339\MerlijnWajer-Simba-bc53339\Units\Misc\superobject.pas(131,18) Error: No matching implementation for interface method "IUnknown.QueryInterface(constref TGuid,out <Formal type>):LongInt; StdCall;" found
C:\Users\C\Desktop\MerlijnWajer-Simba-simba-0.99-rc3-31-gbc53339\MerlijnWajer-Simba-bc53339\Units\Misc\superobject.pas(823,1) Fatal: There were 1 errors compiling module, stopping

Brandon

2012-03-29 20:36:16

TRGB32 is defined as:


Struct TRGB
{
Byte B;
Byte G;
Byte R;
Byte A;
}

In pascal:

type TRGB32 = packed record
B: Byte;
G: Byte;
R: Byte;
A: Byte;
end;

AND PRGB is a pointer to this struct/class..

Sex

2012-03-29 20:45:46

From: shadowrecon
After commenting that out i got another error. Heres the decription ->


C:\Users\C\Desktop\MerlijnWajer-Simba-simba-0.99-rc3-31-gbc53339\MerlijnWajer-Simba-bc53339\Units\Misc\superobject.pas(131,18) Error: No matching implementation for interface method "IUnknown.QueryInterface(constref TGuid,out <Formal type>):LongInt; StdCall;" found
C:\Users\C\Desktop\MerlijnWajer-Simba-simba-0.99-rc3-31-gbc53339\MerlijnWajer-Simba-bc53339\Units\Misc\superobject.pas(823,1) Fatal: There were 1 errors compiling module, stopping


Are you using FPC 2.4.x?

shadowrecon

2012-03-29 20:54:49

From: Sex
Are you using FPC 2.4.x?

I just downloaded it this morning this is what i downloaded "lazarus-0.9.30.4-fpc-2.6.0-win32" so i guess the answer to your question is no.

And as far as the TRGB32 i do understand that i just dont understand

bmp.FData[y*Width + X] <- is this going to a certain pixel and getting the RGB values of that pixel? And if its just a pointer how does the "Y*Width+X" Affect the pointing location. This has been my problem for the last month ive stopped working on this and came back to it a couple of times now. =/

Sex

2012-03-29 21:21:58

From: shadowrecon
I just downloaded it this morning this is what i downloaded "lazarus-0.9.30.4-fpc-2.6.0-win32" so i guess the answer to your question is no.

And as far as the TRGB32 i do understand that i just dont understand

bmp.FData[y*Width + X] <- is this going to a certain pixel and getting the RGB values of that pixel? And if its just a pointer how does the "Y*Width+X" Affect the pointing location. This has been my problem for the last month ive stopped working on this and came back to it a couple of times now. =/


You need FPC 2.4.x to compile Simba. You may be able to get the fpc-2.6.0-support branch working with what you have now though.

shadowrecon

2012-03-29 21:23:43

From: Sex
You need FPC 2.4.x to compile Simba. You may be able to get the fpc-2.6.0-support branch working with what you have now though.
okay thanks ill try just finding an older release. Do you have any knowledge on the FData property what is the data within the [ ] actually doing to the bitmap ?

Brandon

2012-03-29 21:36:55

K.. I suggest before diving into something like Bitmaps and GDI.. you should learn the file format first..

Bitmaps consist of a file header and info header.. these store the size and all sorts of info about the bitmap..
Bitmaps can be padded meaning that they must have a boundary of multiples of 4 at all times..

Example: If your bitmap in width x height = 253 then you have to pad it 3 bits so that it becomes 256.. etc.. Bits per pixel can be: 1, 2, 4, 8, 16, 32..

1 Bpp bitmaps: Every bit will represent a colour in the colour table/map
2 Bpp bitmaps: Every 2 bits will represent a colour in the colour table/map
4 Bpp bitmaps: Every 4 bits will represent a colour in the colour table/map
8 Bpp bitmaps: Every byte (8 bits) will represent a colour in the colour table/map
16 Bpp bitmaps: First 5 bits are blue, next 5 are green, after that the next 5 are red and the 16th is no considered.

At 16 Bpp bitmaps and onwards, you should note that R and B are flipped so the format is BGR.. thus you have to flip them yourself so it becomes RGB.. ALL bitmaps before (including this type) have colour tables and the bits represent a colour in that table.

24 Bpp bitmaps: First Byte (8 bits) are blue, next byte is green and the next is red.. There are no colour maps for this type of bmp..

Every byte in a 32 bit bmp will represent a colour aka COLORREF which is a 32 bit DWORD.. It's the same as the 24 Bpp bitmap except that it has an extra 8 bits (1 byte) which holds the alpha channel.. which can be used for masking or transparency.

Now in the above, the first loop will iterate over all rows and the inner loop will iterate over all those pixels.. it's because it is essentially a 2D array.

A pointer to the RGB struct that will either get populated by the pixels that you read from the loaded bitmap.. OR it can be a pointer to an RGB struct that you wish to flip vertically and store in another RGB struct such as C.

shadowrecon

2012-03-29 21:58:13

From: ggzz
K.. I suggest before diving into something like Bitmaps and GDI.. you should learn the file format first..

Bitmaps consist of a file header and info header.. these store the size and all sorts of info about the bitmap..
Bitmaps can be padded meaning that they must have a boundary of multiples of 4 at all times..

Example: If your bitmap in width x height = 253 then you have to pad it 3 bits so that it becomes 256.. etc.. Bits per pixel can be: 1, 2, 4, 8, 16, 32..

1 Bpp bitmaps: Every bit will represent a colour in the colour table/map
2 Bpp bitmaps: Every 2 bits will represent a colour in the colour table/map
4 Bpp bitmaps: Every 4 bits will represent a colour in the colour table/map
8 Bpp bitmaps: Every byte (8 bits) will represent a colour in the colour table/map
16 Bpp bitmaps: First 5 bits are blue, next 5 are green, after that the next 5 are red and the 16th is no considered.

At 16 Bpp bitmaps and onwards, you should note that R and B are flipped so the format is BGR.. thus you have to flip them yourself so it becomes RGB.. ALL bitmaps before (including this type) have colour tables and the bits represent a colour in that table.

24 Bpp bitmaps: First Byte (8 bits) are blue, next byte is green and the next is red.. There are no colour maps for this type of bmp..

Every byte in a 32 bit bmp will represent a colour aka COLORREF which is a 32 bit DWORD.. It's the same as the 24 Bpp bitmap except that it has an extra 8 bits (1 byte) which holds the alpha channel.. which can be used for masking or transparency.

Now in the above, the first loop will iterate over all rows and the inner loop will iterate over all those pixels.. it's because it is essentially a 2D array.

A pointer to the RGB struct that will either get populated by the pixels that you read from the loaded bitmap.. OR it can be a pointer to an RGB struct that you wish to flip vertically and store in another RGB struct such as C.

Thanks for the explanation. I still dont quite understand all of that. Im familiar with RGB and longword being with bit-wise operations you can break the 32 bit color down to a number like we use in SCAR/Simba. Let me ask my initial question a different way. What do i need to do to make a function to do what the FData class is doing?

Wizzup?

2012-03-30 06:08:33

From: shadowrecon
After commenting that out i got another error. Heres the decription ->


C:\Users\C\Desktop\MerlijnWajer-Simba-simba-0.99-rc3-31-gbc53339\MerlijnWajer-Simba-bc53339\Units\Misc\superobject.pas(131,18) Error: No matching implementation for interface method "IUnknown.QueryInterface(constref TGuid,out <Formal type>):LongInt; StdCall;" found
C:\Users\C\Desktop\MerlijnWajer-Simba-simba-0.99-rc3-31-gbc53339\MerlijnWajer-Simba-bc53339\Units\Misc\superobject.pas(823,1) Fatal: There were 1 errors compiling module, stopping


Yeah… We don't usually get compiling errors, but you should probably use FPC 2.4.4 for now. Reason is that several Simba component aren't fully FPC 2.6.0 ready. (PascalScript needs changes, amongst some other things)