PopCap Sexy Framework

Monkey Targets Forums/User Targets/PopCap Sexy Framework

Ferdi(Posted 2013) [#1]
GitHub: https://github.com/Ferddi/psf-monkey

Original Framework: http://sourceforge.net/projects/popcapframework/

License: http://forum.fischeronline.de/

Requirements

1. MinGW is installed and setup correctly. And make sure the C++ Tool target is working. (You will need this for compiling trans)

2. Visual C++ is installed and setup correctly. Make sure GLFW target is working.

3. Monkey V69+

How to install the target

1. Download DirectX SDK December 2006: http://www.microsoft.com/en-au/download/details.aspx?id=10990 (448MB!)

You can use other version, as long as Direct X 7 is still there. That is, Direct Draw and Direct 3D 7.

Install the DirectX SDK into the directory C:\sdk\Microsoft DirectX SDK (December 2006). IF NOT YOU HAVE TO CHANGE IT IN THE VISUAL C++ SOLUTION FILE!

2. Download the target from github (https://github.com/Ferddi/psf-monkey), and copy the directory over into your monkey directory. Hopefully seeing the github you will realise where those directory should go.

3. In the directory monkey/src/transcc/ there is a batch file "c.bat". Double click on this file. It will do the following to your Monkey directory:
A) Rename transcc_winnt.exe to transcc_winnt_original.exe
B) Compile the new transcc_winnt.exe to be able to compile the sexy framework.

4. In the directory monkey/modules/mojo/, in the file app.monkey, you need to add:

TARGET="sexy" Or - into the line so it becomes:

#If TARGET="sexy" Or TARGET="android" Or TARGET="flash" Or TARGET="glfw" Or TARGET="html5" Or TARGET="ios" Or TARGET="psm" Or TARGET="win8" Or TARGET="xna"

so that it Import native/mojo.sexy.cpp. IF YOU DO NOT DO THIS STEP, YOU WILL GET 101 ERRORS and 19 WARNINGS!

5. That's it and hopefully when you open up Ted "PopCap Sexy Framework" will appear as a target. AND you can compile the bananas.

Important Notes (AT LEAST READ THE FIRST 3)

1. Everyone that uses this say BIG THANKS to Mark Sibly. Because 80% of mojo.sexy.cpp is mojo.glfw.cpp. Most of mojo is matrix transformation code. If I have to rewrite that chance are it will not be compatible with other targets! I have emailed him asking for permission to release and he has given me the go ahead.

2. Per Popcap license you have to say thanks to them in the credit. For example in the special thanks of the credit say, "PopCap for their great framework".

3. Per Popcap license you have to include their license text file in your game. That is the file "PopCap Framework License.txt".

4. I remove Bass library from the code altogether, this target is using DirectSound. If you want to put it back in, in file targets\sexy\template\SexyAppFramework\SexyAppBase.cpp, function CreateMusicInterface uncomment line:

return new BassMusicInterface(mInvisHWnd);


and comment line:

//return new MusicInterface;


You may need to add several functions to get Bass working. I forgot exactly what I did to get DirectSound going.

5. If ALOT of people want to be compatible up to Windows 98, we have to downgrade to Visual C++ 2005. Currently we are at Windows XP and above. I personally think it is good enough Windows XP and above.

6. I have run all the bananas twice, once in 3D and once in Software, all seems to be working ok. (Well ... read below) So I guess run your program with it, and let me know what problem arises?

7. I have included the banana screenmode, which show it can change screen size. But the framework was never meant to handle this. What I did, is more of a hack. I have bashed it during my testing, seems to be working. (Again I tested it in 3D and software mode.)

8. So if you want to test your game in software mode, in the file targets\sexy\modules\native\sexygame.cpp, in the function GameApp::GameApp() change:

mAutoEnable3D = true;


to

mAutoEnable3D = false;


2 known problems

1. When the framework goes into software rendering, and you need to draw a rotated image with additive blend, the framework will fail. I have looked into the code, I basically need to write a new SWTri.cpp. It is too hard.

IMO, if it goes into software rendering mode, it is probably OLD and SLOW computers. And at that stage you don't want to be doing rotation and additive blend on a slow computer.

So if you run the banana/charlie/blobmonster in software mode, it will NOT glow.

2. Don't keep on destroying and loading images in the main loop, this causes memory leak. And I don't know how to chase it down. In the bananas/mak/mojotest it does image.Discard and Loadstuff in the update loop. I have checked in my task manager, that the memory keeps going up.

To be fair to the framework, it was never build for this. If you looked at all PopCap games they load it all in the beginning of the game. So as long as you load everything at the start of the game you should be fine.

BUT, if someone is a C++ expert and can help track this down for me, I would greatly appreciate it. Or you can point me to use the correct tool for the job.


MikeHart(Posted 2013) [#2]
...


Beaker(Posted 2013) [#3]
Ferdi - be careful, you might be breaking mojo licensing by sharing your target.


Ferdi(Posted 2013) [#4]
@Beaker - I have emailed Mark to look at the file, and he has given me the go ahead. Actually I am kinda surprise Mark gave me the go ahead, but I thought I tried my luck and email him.

To anyone else that may do this, Beaker is right, at the very least email Mark first, you are threading a fine line. Please don't go how come that target can, and this target can't.


Soap(Posted 2013) [#5]
This is really quite awesome.


Ferdi(Posted 2013) [#6]
Thanks Soap, I am glad you approve. =)


ImmutableOctet(SKNG)(Posted 2013) [#7]
I followed the installation process, but for some reason 'Trans' isn't actually working. 'Trans' compiles just fine, but it doesn't seem to want to run. I've even compiled it myself, and it gives me the same issue. When I launch 'Ted', the target area is completely blank, and I'm not sure why.

So does this work with V70e, or do I have to update to V71? If I have to update, it's not a big deal, but you'd definitely need to say something about that.

By the way, I haven't messed with DirectX in Visual C++, where do I go to change DirectX's the directory?


Ferdi(Posted 2013) [#8]
When I launch 'Ted', the target area is completely blank, and I'm not sure why.


That's not good. And I am pretty sure I know why. When my c.bat tries to compile transcc_winnt.exe it uses MinGW. I just changed my MinGW directory, and I get an empty target in Ted. Sorry I have to change the step above to include that you have MinGW installed.

When I double-click on c.bat in the directory src\transcc, this is what should happen:



And in the directory bin you should see transcc_winnt.exe AND transcc_winnt_original.exe. If you don't have transcc_winnt.exe, the target will be empty in Ted. So if you want to quickly fix it, just rename transcc_winnt_original.exe back to transcc_winnt.exe. This is what the bin directory should look like:



Since yours fail, install MinGW (Make sure in bin\config.winnt.txt you are pointing to the correct MinGW directory), and then run c.bat again.

So does this work with V70e, or do I have to update to V71? If I have to update, it's not a big deal, but you'd definitely need to say something about that.


Sorry I forgot to mention that. I kinda rushed the above post, because I wasn't expecting a reply from Mark =) I made it in V69. Before I release I test it was working on V71C. I just check on V70G, it is working. I don't have V70e, sorry.

I'll answer your DirectX question in the next post need to take some screen capture.


Ferdi(Posted 2013) [#9]
1. Double click on the file targets\sexy\template\vc2010\MonkeyGame.sln.

2. Right click on SexyAppBase and click on Properties:



3. Set the configuration to All Configuration:



NOTE] The way all configurations works is that if you place the directory in here, it will place it in debug, debug - incremental, debug - zylom, release etc etc Now if type the same directory in all configurations, it will place the same directory in debug, debug - incremental debug - zylom etc etc again, so you have 2 of the same directory in each of the configuration. Microsoft at its finest =) So just becareful when using it, may get annoying.

4. In the SexyAppBase Property Pages window, click on VC++ Directories. And the Direct X directory is in "Include Directories" (Direct X header file for compiling) and "Library Directories" (Direct X library for linking). Shown in this image:



On the side note when you finish closing VC++ you probably notice MonkeyGame.sdf file which is 53MB! You can just delete it if you like, not important.


ImmutableOctet(SKNG)(Posted 2013) [#10]

Ferdi: That's not good. And I am pretty sure I know why. When my c.bat tries to compile transcc_winnt.exe it uses MinGW. I just changed my MinGW directory, and I get an empty target in Ted. Sorry I have to change the step above to include that you have MinGW installed.

When I double-click on c.bat in the directory src\transcc, this is what should happen: INSERT IMAGE HERE



I don't use MinGW very often (With Monkey), but I've had it installed for a while. Like I said, the EXE compiles, and it tells me that it worked, but the program just doesn't do anything.

I looked into this further, and it turns out it's a linking issue with my copy of MinGW. For some reason my version of MinGW doesn't statically link all of its dependencies, and 'Ted' wasn't saying anything. So sorry about that, it was my fault.

I've had this kind of issue before, and I have no idea why MinGW needs to link "libstdc++-6.dll" on runtime. If you know what's going on there, by all means tell me. That issue's been driving me nuts. I may just reinstall it if this continues.

Anyway, thanks for telling me about the lib and include fixes for DirectX. I think I'm a bit too used to doing everything with a console or make file.

EDIT: I just wasted 30 minutes wondering why the target wasn't seeing the DirectX location. Turns out I forgot to change the configuration to "All Configurations" or "Release", you might want to mention that above. I really hate that about Visual Studio.


Ferdi(Posted 2013) [#11]
why MinGW needs to link "libstdc++-6.dll" on runtime.


I have never run into that problem before. I am like you I hardly use it, I only use it to compile trans.

I just wasted 30 minutes wondering why the target wasn't seeing the DirectX location.


Sorry forgot to mention that. Will update the above post. You are right debug and release can have different directory.

Yes VS is getting worse and worse with each release, I remember you can set directory globally in 2005 but now in 2010 they already remove it =(

Are you ok now?


Ferdi(Posted 2013) [#12]
Release mode was not compiling, I just uploaded a fix for that. JPEG2000 in the image lib was not included during compile time, I had to add those in.


ImmutableOctet(SKNG)(Posted 2013) [#13]
I'm having some trouble getting the target to work with release mode, but I'm pretty sure I can fix it pretty easily. Never mind, I just read your last post.

Also, I tried running my project with the target, and I apparently can't use 'BeginRender' without it crashing (Haven't tried it since your most recent version was uploaded). Apparently the native debugger is saying that the crash has something to do with 'SetScissor'.

EDIT: After running the program in release mode, I got this (Pay no attention to Windows 7 screwing up my GUI elements):



And strangely enough, Visual Studio 2012's debugger works perfectly with Visual C++ 2010 programs.

By the way, is filtered mode supposed to be forced with this target? (This seems to only be an issue with DirectX)

EDIT: I forgot to mention this before, but you might want to make the window centered by default. And for some reason release mode has a ton of warnings.

Sorry I'm not using Git for all of this, the forums are just more convenient for me.

I know this is a bit off-topic, but is Git GUI any good? I've only messed with the console stuff.


ImmutableOctet(SKNG)(Posted 2013) [#14]
Oh right, I forgot about this before, but the OS module seems to work pretty well with this target. All you really have to do is edit the preprocessor code at the beginning.

Sorry about all of the bug reports, but at least they're getting ironed out quickly.


Ferdi(Posted 2013) [#15]
1. The crash.

I tried reproducing it over here to no avail. I know this is a REALLY BIG ask. Can you send your project over to ferddi [at] gmail.com (yes double d). I promise I will delete everything once the bug is fix. I will look into it after my day job.

Or can you reproduce it with a shorter code?

2. Filtered mode.

Yes this might be impossible. Can you do a screen cap of one of the banana to show me the difference? But I have a feeling I might not be able to turn it off in Direct3D.

3. Git

I am no Git expert. I think it will be a little hard actually, just grab the zip from GitHub and away you go.

I am using the software GitHub for Windows, even for my local repos, which doesn't get uploaded to GitHub. This seems to be good enough for me, I don't use branches etc, which you definitely need if you work in a team or may be even when you doing a release.

There was a post in this forum about Git which was really good.

http://www.monkeycoder.co.nz/Community/posts.php?topic=4864

Read what Corum has to say. So basically read this:

http://www.atlassian.com/git/workflows

and download this:

http://www.sourcetreeapp.com/

As for Git GUI, I used it may be once or twice, then I went back to GitHub for Windows.

4. Preprocessor code for the OS Module

Show me the preprocessor code?

5. Warnings

I have removed most of the warnings. But I put it in my todo list to go back and look at it carefully. Just incase MS may be right.

6. Centering

I'll put it in as a config, just incase other people doesn't want it. But I have to go into PopCap code to change this. Not a 5 minute job.


ImmutableOctet(SKNG)(Posted 2013) [#16]

Ferdi: 1. The crash.


That would require a lot of explanation, not to mention a decent bit of work... I wrote my own wrapper library for graphics, it can support a number of frameworks, but right now it's just Mojo and MiniB3D (Haven't tested MiniB3D in a while). Plus, all of the source code is dependent on my modules, and my modifications of modules. Plus, I don't know you very well, so giving you my source code just doesn't feel right.

I made a separate program to test 'BeginRender/EndRender', and it crashed just like my project did. Assuming this isn't my problem, my guess is that it's not initializing things properly.




Ferdi: 2. Filtered mode.


Software renderer:


DirectX-based renderer:



Ferdi: 3. Git


Thanks, I'll definitely look into what you suggested.


Ferdi: 4. Preprocessor code for the OS Module

Show me the preprocessor code?



It's right at the top, you can't miss it:
[monkeycode]
#If TARGET="stdcpp" Or TARGET="glfw" Or TARGET="sexy"

Import "native/os.cpp"

Extern

' Etc...
[/monkeycode]I've had no problems with the OS module so far, but some things may not actually function.


Ferdi: 6. Centering

I'll put it in as a config, just in case other people doesn't want it. But I have to go into PopCap code to change this. Not a 5 minute job.


Something tells me it isn't exactly complicated to change this. Either way, having it as an option would be fine by me.


Ferdi(Posted 2013) [#17]
1. The Crash

I have fixed the crash. But you can't draw anything in OnUpdate.

This is the problem. When OnRender is called I have a pointer to the graphics class. Once that frame(OnRender) is finished, that pointer is gone.

Now in that example, you put the draw into the update. So when the update is called the pointer from OnRender is long gone, and that's why it is crashing.

I really need to think about this one. I did notice that only image is drawn in GLFW (DrawText and DrawCircle was not working), while on HTML5 everything seems to be working.


Ferdi(Posted 2013) [#18]
2. The Filtered Mode.

I have added another function in mojo.graphicssexy called SetLinearBlend. You used it as follow:


Import mojo.graphicssexy

...

	Method OnRender:Int()
		' Nothing needs to be here.
	
		SetLinearBlend(False) 'Blocky
		DrawImage(image, 100, 100, 0, 4, 4)
		SetLinearBlend(True) 'Smooth
		DrawImage(image, 100, 200, 0, 4, 4)
	
		Return 0
	End

...



4. You know it took me a while for me to figure out what you are talking about OS Module, until I saw OS in the module directory. Not sure how long I have Monkey, but I never knew it existed until you told me ... pretty sad. Good to know it is there now =)


Ferdi(Posted 2013) [#19]
6. Centering

I think I didn't explain it right why I say it is hard. When I made this target, my motto has always been to not touch PopCap code as much as possible, ESPECIALLY the initialization code. I believe that is where most things will/can go wrong! The reason is that PopCap has tested this framework on millions of computers, and we know that init code works. So if we start changing it, we might start introducing bugs to it. That's why I am so scared of changing any PopCap code, for example init code.

Anyway, I have added a function called CenterWindow. You called it in the Main before you new the application like this:


Import mojo.graphicssexy

Function Main:Int()

	CenterWindow(False)
	New Application

	Return 0

End Function



I am going back to problem 1 now.


Ferdi(Posted 2013) [#20]
1. The Crash

I have made a banana called updatedraw.monkey. That does drawing in the update.

Ok, you gotta remember the framework was never design to do this. So probably this is going to take a while to make it robust, and works smoothly.

[Edit] Forgot to mention, instead of using BeginRender and EndRender you need to use BeginRenderSexy and EndRenderSexy, because I need to get the pointer to the Graphics class and Redraw the screen at the end.


ImmutableOctet(SKNG)(Posted 2013) [#21]
Couldn't you technically use 'Alias' to clear that issue up?

Anyway, I was testing the screen-mode functionality, and apparently while you're in fullscreen it restricts your cursor (MouseX and MouseY) based on the initial resolution, not the current resolution.

Also, you might want to say that the screen-mode example uses the new DrawPoly overload.


Ferdi(Posted 2013) [#22]
Couldn't you technically use 'Alias' to clear that issue up?


What is Alias? Can you show me an example?

Anyway, I was testing the screen-mode functionality, and apparently while you're in fullscreen it restricts your cursor (MouseX and MouseY) based on the initial resolution, not the current resolution


Fix

Also, you might want to say that the screen-mode example uses the new DrawPoly overload.


Done.


ImmutableOctet(SKNG)(Posted 2013) [#23]
'Alias' is essentially Monkey's version of typedef, but after looking into it, it seems to only really work with classes and files/modules.