PDA

View Full Version : SvPascal



simvector
25-06-2011, 04:23 PM
SvPascal (http://simvector.com/index.php?page=svpascal)™ Game Development System is a modern, modular, object oriented programming language based on Object Pascal, a light-weight IDE (SvDevelop) and an advanced 2D game engine (SvEngine) for Windows¬Æ PC.

This video shows SvPascal in action:

http://www.youtube.com/watch?v=XwadqWBQNfs

Coming Soon!

WILL
25-06-2011, 05:23 PM
Very interesting... Will this be an interpreted or compiled language?

simvector
25-06-2011, 05:39 PM
Hi,

It's compiled, generating 32 bit machine code. You can import routines from DLLs, even create them (this will come much later in development). Coming sooner will be support for what I'm calling DLMs (dynamic loadable modules). It is the native binary image format generated from the compiler. What's cool about it is that it contains rich meta data. Once its loaded it into the address space of the calling process, you have access to all exports in the global space and in the interface section of units. You can access classes, variables, constants etc. You will also be able to use DLMs in other language compilers such as Delphi/C++. There will be a thin API exposed to manage DLMs in a generic way across all supported language bindings.

simvector
27-06-2011, 04:18 PM
The Testbed (http://simvector.com/index.php?action=downloads;sa=downfile&id=4;t=1309191267) example in SvEngine was ported to SvPascal (http://simvector.com/index.php?page=svpascal) with minimal changes.

http://simvector.com/MGalleryItem.php?id=47

paul_nicholls
28-06-2011, 06:51 AM
Looking good bro! Go Jarrod :)

SvPascal works nicely for me, I am using it for my PGmini compo entry :)

cheers,
Paul

WILL
28-06-2011, 08:26 AM
Some people were asking about your Simvector libraries on Facebook under the Delphi Developer (http://www.facebook.com/home.php?sk=group_137012246341854) group.

simvector
28-06-2011, 12:00 PM
@paul_nicholls - Thanks bro.

@WILL - Whoa, did not know about this group. Thanks man.

simvector
30-06-2011, 12:56 PM
SvPascal (http://simvector.com/index.php?page=svpascal) version 1.0-a1 (http://simvector.com/index.php?action=downloads;cat=2) (alpha) released.

VilleK
30-06-2011, 03:12 PM
Looks interesting! So let me see if I get this right, it features a built-in native compiler compatible with Delphi 7 level syntax?
Did you write this compiler from scratch or is it somehow based on FreePascal or something else?

simvector
30-06-2011, 03:17 PM
Hi, thanks. The compiler tech is based on a heavily modified version of PaxCompiler (http://paxcompiler.com/) by VIRT Laboratory. I'm using Syntax Editor SDK (http://www.econtrol.ru/syntedit.html) by EControl Ltd. for the syntax editor control and our own SvEngine (http://simvector.com/index.php?page=svengine) for the 2D game engine.

simvector
03-07-2011, 07:59 PM
Version 1.0-a2 has been released.

pstudio
04-07-2011, 05:39 PM
If I want to use a 3rd party dll (bass) will I have to register the dll with TSvDLL and manually bind all functions?

simvector
04-07-2011, 06:13 PM
You can do it dynamically if you like via TSvDLL or you can do like you do in Delphi:


procedure MyRoutine; stdcall; external 'MyDLL.dll';
...
MyRoutine;

pstudio
04-07-2011, 08:27 PM
yeah got it working.

It seems SvPascal didn't like a constant instead of a explicit string when declaring external methods.
I had



const
bassdll = 'bass.dll';

function BASS_SetConfig(option, value: DWORD): BOOL; stdcall; external bassdll;
...

and had to change it to:


function BASS_SetConfig(option, value: DWORD): BOOL; stdcall; external 'bass.dll';
...


And I wasn't sure you could use DLL's like this since 'external' wasn't highlighted as a keyword.

simvector
04-07-2011, 08:52 PM
Hi,

Ahh.... gotta get that fixed. Thanks for reporting.

wodzu
08-07-2011, 01:43 PM
Impressive! :)

simvector
08-07-2011, 03:16 PM
Cool, thanks.

pstudio
10-07-2011, 11:10 PM
Is TSvDirList meant for browsing folders/files? How would I go about doing that in SvPascal?

Some feedback:
I had (pseudo)


procedure Foo;
const // for some reason it wouldn't work if the const was declared in the procedure.
MAIN_TITLES: array [0..2] of widestring =
('Play Song',
'Options',
'Quit Game');
begin
Font.Draw(,,,,,, MAIN_TITLES[0] ,);
end;

Nothing would be written except for maybe a splash second in the beginning. If I move the const declaration outside the procedure then it works fine.

Some tabs for the units in the editor would be nice. It's annoying to use the dropbox to select a file when you have more than just a few units. Tabs would allow to quickly switch between units. Maybe even have the ability to have two units shown at the same time side by side.

Also it seems that sometimes when I choose a file in the dropdown box then it selects the project file instead.

If you want an add in your editor at least place it on the same panel as the dropdown box. Then I could see at least 3 lines of extra code instead of having that area filled with mostly nothing.

Save File As... doesn't seems to work.

Is there a way to add your own code folding marks? Some way so you can mark a section of code and fold it under a single header.

Rodrigo Robles
10-07-2011, 11:31 PM
Very impressive! Is nice to see that exists people doing development tools like this!

simvector
11-07-2011, 09:38 PM
@pstudio

1) Here is how you would use TSvDirList

var
dl: TSvDirList;
i : Integer;
begin

dl := TSvDirList.Create;
dl.ReadAllFiles('c:\temp\', '*.dll'); //scan for file mask including sub folders
//dl.ReadFiles('c:\temp\', '*.dll'); //scan for file mask in specified folder only
//dl.ReadName('c:\temp*.*'); // scan for folder names only
for i := 0 to dl.Count-1 do
begin
WriteLn(dl.ItemNames[i]);
end;
SvFreeNilObj(dl);

end;2) const not working inside routine. /Bug/ - Thanks.

3) dropdown not selecting correct file sometimes. /Bug/ - Thanks.

4) Add vertical tabs. Noted. Thanks. ATM you can press F12 to bring up a list of project files.

5) Save File As not working. /Bug/ - Thanks

6) Add own code folding marks. At the moment you can not. I will check to see if the Editor SDK allows me to do so. If so I will try and get this added. Thanks for the suggestion.

Again, thanks for the feedback. Much appreciated.


@Rodrigo Robles
Coolness, thanks.

pstudio
12-07-2011, 06:53 PM
Thanks for the example.

One more thing. I tried writing:


SV.Utils.DottedFilePath(path, 8);

Result was that the program closed without any errors or similar.

The problems was solved by using a larger value in stead of 8.
I can imagine various reasons why 8 is too small a number, but I would recommend to give some better error feedback than just closing the program with no warning. The log wouldn't even reveal the problem.

simvector
12-07-2011, 07:59 PM
Hi... hmm.. interesting. I will have a look at this routine. It could be a bug in the routine and/or something going on with the call. But I will check it out. It does make a call the a Win32 API routine to do the work. Thanks for reporting.

pstudio
12-07-2011, 10:41 PM
One last question (or two) related to file browsing I swear :)

1. Is there an easy way in SvEngine or SvPascal to go up a directory when I have a path value? For instance if path := 'c:\foo\bar\' then I want path = 'c:\foo\'.
2. Is there a way to check if a path leads to a folder or file? I thought I could use TSvUtils.MatchStrings like this "SV.Utils.MatchStrings(path, '.mp3')" to see if path lead to a mp3 file but it dodn't work.

simvector
13-07-2011, 01:17 AM
Haha... no worries. Your feedback is help me find and fix bugs so thank you.

1) At the moment there is nothing. You can use the Pos routine to search for '\' which you can then use to find the last occurrence then back up to the previous.
2) You can use FileExists, but DirectoryExists is not currently available. Note to self... "be sure to bind DirectoryExist command."
3) MatchStrings... I think I added this to do some pattern matching for a string. So no, that will not help in this case.
4) if you call TSvDirList.ReadFile(path, '*.mp3') will pick up all the files in this path or ReadAll to get everything including sub folders, then you can walk the list and use FileExists to see if the file is actually there.

pstudio
13-07-2011, 10:50 PM
Thanks,
FileExists worked fine for my purpose and I quickly made my own function to get the parent directory.

Now a completely different kind of question. How do I register when my window loses focus? I've noticed that the window stops rendering and that's fine. However I'm playing music through the Bass library and music will continue to play when the app loses focus. So I need to know when the app loses and gains focus so I can manually pause and play music.

If it makes a difference I'm inheriting from TSvPrototypeGame.

simvector
13-07-2011, 11:37 PM
1) no prob... glad to hear you got it all working. Coolness.

2) You can override the TSvPrototypeGame.OnAppEvent event handler. There you can check SV.Minimized and SV.Active to test the application state.

3) If you want the application window to continue rendering when it looses the focus, set RenderOnLostFocus to TRUE and if you ever need to control the audio playback of the default audio engine, set GlobalFocus property to TRUE and audio will continue playing when the focus is lost.

pstudio
14-07-2011, 12:10 AM
Ok, I was actually looking at OnAppEvent but I was missing some input on what event was triggered. Apparently that is placed in SV. Thanks.

pstudio
14-07-2011, 01:22 PM
I can't seem to make it work. It doesn't appear that OnAppEvent is called :?



type
TShooterGame = class(TSvPrototypeGame)
public
procedure OnAppEvent; override;
end;

procedure TShooterGame.OnAppEvent;
begin
inherited;

WriteLn('AppEvent');
WriteLn(SV.Active);
WriteLn(SV.Minimized);
if not SV.Active or SV.Minimized then
StopSong(Music)
else
PlaySong(Music, False);
end;

Nothing is written in the console window when the window loses focus or is minimized.

simvector
14-07-2011, 07:16 PM
Ahh your right, it's not working. Sigh. In investigating this I discovered it does not like Assigning the event handler which I'm sure is the source of this problem. If I try to manually assign it, I'm getting an incompatible type. I have to dig into it a bit more. Thanks for reporting. The SvEngine equivalent works as expected.

pstudio
16-07-2011, 05:35 PM
How can I disable that Escape quits the game. And how can I make sure that 'Alt' won't make the window loose focus so I can actually use that button in a game?
I've tried to overwrite UpdateInput(a: Single) without calling inherited but that doesn't change anything.

simvector
16-07-2011, 08:01 PM
Hi,

1) Override TSvPrototypeGame.ProcessTerminate; By default it does this:

procedure TSvPrototypeGame.ProcessTerminate;
begin
// ESC key terminated by default
if SV.Input.KeyHit(Key_Escape) then
begin
Terminated := True;
end;
end;2) You can get the KEY_LALT and/or the KEY_RALT keys but pressing ALT by itself will cause the window to loose the input focus. I have the system menu attribute added to the app window (so an icon can display) and I thinking maybe this is what's grabbing the focus. Pressing ALT will usually activate the window's menu.

You can override and capture ALT like what I've done below. I tried to call Win32 SetFocus but it does not seem to work. I will have to look into this. I never use ALT (alway in combination with another key) by itself is why I guess I've never ran into this issue.



function SetFocus(hWnd: Cardinal): Cardinal; stdcall; external 'User32.dll';

type

TGame = class(TSvPrototypeGame)
public
procedure UpdateInput(aElapsedTime: single); override;
end;

procedure TGame.UpdateInput(aElapsedTime: single);
begin
inherited;
if SV.Input.KeyHit(KEY_LALT) then
begin
Title := 'Jarrod';
SetFocus(SV.DisplayDevice.Handle);
end;
end;Thanks for reporting.

pstudio
16-07-2011, 08:07 PM
Ok, I'll look into it,

another question: how do I get the absolute application path in SvPascal?

simvector
16-07-2011, 09:18 PM
You can do this for now:

function GetModuleFileNameW(Module: Integer; Filename: PWideChar;
Size: Integer): Integer; stdcall; external 'kernel32.dll';

function SvStartupPath: string;
var
Buffer: array[0..260] of WideChar;
i: Integer;
begin
Result := '';
GetModuleFileNameW(0, Buffer, 260);
for i := 0 to 260 do
begin
if Buffer[i] = #0 then
break
else
Result := Result + Buffer[i];
end;
Result := ExtractFilePath(Result);
end;You have to copy the buffer this way ATM until I get string conversion working properly.

pstudio
16-07-2011, 09:43 PM
wow, seems more invovled than I would have expected . I'm gonna check it out now.

Could you list the order of how things are rendered in TSvPrototypeGame.
Right now it seems the TSvRenderScene.Render is called before TSvAIStateMachine.Render but I need it the other way round. I decided to use the state machine as a quick implementation for game screens. The result is that my background is drawn on top of the entities in the game.
My guess is that I'll have to make my own implementation of RenderFrame in TSvPrototypeGame so I would like to now which things are called in it so that I don't forget to call some render function.

simvector
16-07-2011, 11:40 PM
This is what ParamStr(0) does with the exception of the loop. In the end I will simply bind to ParamStr but in the current build this is not done so the only way to do it is to call on win32 to do it. The good thing is that SvPascal is able to do it in it's current state. I was pleasantly surprised that I actually got it to work. Normally you can typecast the buffer array to string which is currently not working correctly. So I had to loop and copy the buffer.

SvPascal binds directly to SvEngine.pas and SvEngineFramework.pas (SvEngine, bindings folder) so you can view directly what's going on from those units. Here is the current implementation:

procedure TSvPrototypeGame.RenderFrame;
begin
FScene.Render(FSceneAttr);
FStateMachine.Render;
end;You can override renderframe like this:

procedure TMyGame.RenderFrame;
begin
StateMachine.Render;
Scene.Render(SceneAttr);
end;You can also take advantage of the attribute feature and tell Scene.Render to only render specific objects with attributes set. Each TSvObject can have up to 256 attributes, numbered from 0-255. They can be on/off. So player can be 0, enemy can be 1, rocks 2 and so on. If you do not want to render anything, set MyGame.SceneAttr := [255] for example and nothing will be rendered in this case. If you only want to update certain object and not others, just tell game which ones and only they will render/update.

Glad to see you trying the AI stuff. What I've implemented is what I call an event driven state machine. Makes it very easy to organize your game into be and ran by states. I'm currently working on a game project that will be using them also. My goal for this game project is to make the code very data driven and build a level editor around it. I will be taking advantage of component based design. SvEngine framework is built around this principle already. Actors have children which can update/render, can have a state machine and the game classes has a state machine for use at the upper level.

simvector
29-07-2011, 03:14 AM
This is an early screenshot of the redesign we are doing to SvPascal. We got some great user feedback and we will try to incorporate as many as we can. Another big change is that SvPascal will be using a different compiler back end (FreePascal) which required some architectural changes to accommodate this. I've been experimenting with adding debugging support (GDB) and it's looking like it will happen too. I've now figured out how to talk to the debugger and control it from the IDE. Pretty cool stuff. First step will be to step through the code from the IDE and then later to add more advanced features. More information coming soon.

http://simvector.com/MGalleryItem.php?id=48

paul_nicholls
29-07-2011, 04:05 AM
yay! Go Jarrod :)

cheers,
Paul

pstudio
29-07-2011, 11:20 AM
That definitely looks like an improved editor IMO. Looking foreward to try it out sometime.

simvector
29-07-2011, 12:36 PM
@paul_nicholls, @pstudio

Thanks. Things are coming along well. Learning lots of great and new stuff especially with external debugging and interfacing to and controlling an external process. Capturing console output can be tricky, but I now think I've got that sorted out as you can see in the message output window. The first redesign release most likely will not have debugging yet. I want to get the core solid with minimal bugs then start to add more features from there. If you would like to try WIP builds, let me know. The feedback would invaluable. Thanks.

simvector
02-08-2011, 06:34 AM
This is what I've got working so far:



menus now work
you can change editor, syntax highlighting and key mapping
sync editing
will reload last project on start up
forcibly terminate a process
can run the FontStudio util (I forgot to add it to this build however, doh!)
now display info in the caption like Delphi
smart compile, full build and final build
run without debug info, run with debug info (in preparation for integrated debugging)
final build will pack executable using UPX (if enabled)
toggle run-time theme support
toggle version info
change editor options
change syntax highlighting options
change key mapping
toggle code folding
toggle visible line numbers
sync editing
tabs across top of edit window for quick access to files
project manager tree view
source structure tree view
print and print preview
feedback dialog
make program and dll projects
add units and include files in projects
minimalist freepascal now used for compiler back end
more bug fixes.


Screenshot
516

Download (http://simvector.com/temp/svpascal_wip.zip) (temp link only up for a few days)

simvector
10-08-2011, 11:55 AM
Here is a video of the redesigned SvPascal in action.



New codebase and redesigned IDE
IntelliSense like code completion
Context sensitive help (F1)
FreePascal compiler backend
Full SvEngine integration
Lots of bug fixes and more



http://www.youtube.com/watch?v=maOdL6AS7Og

More media (http://simvector.com/index.php?action=media;sa=album;in=8)

Coming Soon!

simvector
11-08-2011, 03:10 AM
SvPascal 1.0 (Alpha 1) (http://simvector.com/index.php?action=downloads;sa=view;id=7) released.

http://simvector.com/MGalleryItem.php?id=58