The book of inspiration

October 19, 2010

Convert C Headers to .NET

Filed under: tech — Tags: — zproxy @ 12:19 pm

Alexandre Mutel has been busy generating a .NET wrapper for DirectX 11. From what I could gather he is reading .h files in and writing .cs files out.

Note that his post seems to be unavailable.

New OpCodes used by his tool:

  • instruction “calli
  • instruction “sizeof” for generic
  • instruction “cpblk“, memcpy in IL

For future reference to gather some of my thoughts:

It so happens to be that jsc is also providing some support for PInvoke to convert an application to java source code.

Could one at one point program a java application in C# which runs on JVM and uses DirectX via jni? Technically it is possible yes although while jsc uses a version of jni which seems to be bound to the CDecl calling convention.

The names of the exported native functions can be read as described on stackoverflow. For parameters a .h file is required.

What is Cdecl?

ANSI C or POSIX (see the API) portability is a goal

see also: http://en.wikipedia.org/wiki/Interix

__cdecl: caller pushes and pops args off stack, args passed right to left.
Older, unmanaged code that was developed by using the standard C libraries can implement functions that take variable numbers of parameters by using a technique that is known as varargs. Only the code that calls these functions knows for certain what it has placed on the stack, so it is the responsibility of the calling code to clean up the stack when the function completes. This is referred to as the Cdecl calling convention. It is the mechanism that unmanaged code that runs on Windows Embedded CE uses (you can use this as a point to select between Cdecl and StdCall nn your code).

 

See also:

July 23, 2010

Error loading jvm

Filed under: jsc — Tags: , , — zproxy @ 9:24 am

When I was trying to use jsc to build a flash component the mxmlc compiler failed to launch with this message:

[exec] Error loading: C:\Program Files\Java\jre6\bin\client\jvm.dll

Error loading: C:\Program Files\Java\jre6\bin\client\jvm.dll

To fix that I copied from:

“C:\Program Files\Java\jre6\bin\msvcr71.dll”

to (x86)

“C:\Windows\System32\msvcr71.dll”

to (x86) on 64bit windows

“C:\Windows\SysWOW64\msvcr71.dll”

Then I ran the generated swf file in the flash player which told me the following:

VerifyError: Error #1014: Class mx.core::BitmapAsset could not be found.

As this component was not part of the new BrowserApplication project template it had a custom build.bat which needed a new flag to be passed mxmlc.

-static-link-runtime-shared-libraries=true

Update from the future: While setting up a build environment in Amazon EC the same problem occurs.

See also:

March 4, 2010

FSharp Ultra Application

Filed under: jsc — Tags: , — zproxy @ 1:19 pm

JSC Ultra Application to Support FSharp

Filed under: jsc — Tags: , — zproxy @ 11:38 am

This is awesome 🙂

You will basically be able to write code for javascript, java applets and flash in F#!

February 22, 2010

JSC Ultra to reuse native source code

Filed under: jsc — Tags: , , , , , — zproxy @ 9:48 am

As advertised the developers will be able to seamlessly create flash sprites and java objects inside their javascript applications in C# via the jsc ultra offering. What if they could just drop some native source code and be able to reuse them in C#?

At the moment only the HTML web page is converted to DOM building code which looks like this under reflector.

In the future releases the native source codes could be parsed and placed in the correct location based on their namespace for their respective back-end compilers.

Seems like I will need source code parsers to pull it off. First step is to generate a stub. The next step would be to convert the native source to IL. If we go just for the first step, then one can surely benefit from some native language specific syntax constructs.

Update: The second pass would mean that the native back-end compiler does it’s job and jsc will go and decompile JVM or AVM to IL as jsc is not about compiling source to IL.

Then you could consume the AboutApplet.java  in your javascript code like this:

42 var Applet1 = new AboutApplet();

43

44 Applet1.Method1(“hello world”);

45

46 var Applet1Element = Applet1.AttachAppletToDocument();

47

48 Applet1Element.style.border = “1px solid red”;

This will create a red java applet in your browser.

The AboutApplet.java should could look something like this:

1 // PromotionWebApplication1.AboutApplet.dll

2 package PromotionWebApplication1;

3

4 import java.applet.Applet;

5 import java.awt.Component;

6 import java.awt.Container;

7 import java.awt.image.ImageObserver;

8 import java.awt.Panel;

9

10 public final class AboutApplet extends Applet implements ImageObserver

11 {

12

13

14 public AboutApplet()

15 {

16 super();

17 }

18

19

20 public final void Method1(String p)

21 {

22 }

23

24 }

Ch

Cool features ahead. Including HTML5 🙂 Including an actual installer!

jsc has now a twitter feed!

PS. What about .class, .jar, .swf, .swc? 🙂 I surely would like to pull media from online .swf files just to be able to recompile them into my own application.

Hey Compiler that flash game there has nice logo and sound, could you go ahead and make them accessible for me in the code? Thanks! 🙂

September 1, 2009

Windows Forms inside Opera Widget

Filed under: jsc — Tags: , , , , — zproxy @ 1:57 pm

Opera SoftwareIf you are like me then you probably have had a look at the new opera 10 browser. I liked the widget API so much that I just had to make a widget of my own.

>> Open my Windows Forms javascript example as opera widget!

Widget1

Cool huh? Note that this widget will only show on your primary display if you are one of the multi display citizen. Note that this widget needs a right click to close.

You may see the following warning when opening my widget:

jsc.sourceforge.net

You are installing a file which can alter the way Opera behaves. Opera may become unstable or less secure as a result.

You should only download setup and widgets from sources you know and trust. Do you want to proceed?

jsc.sourceforge.net
You are installing a file which can alter the way Opera behaves. Opera may become unstable or less secure as a result.
You should only download setup and widgets from sources you know and trust. Do you want to proceed?

July 13, 2009

Nobody likes the records that I play

Filed under: jsc — Tags: , , — zproxy @ 7:02 am

It is time to make yet another release of my jsc compiler. This time around you can finally use anonymous non generic delegates with java. Coolness! Subscribing to events and threading is now much easier. For applets you’d need to write a delegate to interface wrapper tho…

In the release you have a project template at C:\util\jsc\templates\OrcasJavaConsoleApplication.zip

At this time I modified it to show off the anonymous delegate support. In debug build mode this project can be debugged using F5 in Visual Studio on .net. If release build was selected the jsc compiler will be invoked as a post build event to generate java source code then javac and jar will be invoked. To run the new java package you need to start the tools/run.jar.bat.

javaevents by you.

How will that delegate keyword work out in java source code you ask? Here is the Program.java for you to inspect.

javaevents2 by you.

As you can see there is some magic involved, where magic is the compile time code generation. While jsc has been around for years – it took just that long to actually implement the delegate support. It is running via reflection and as such not really that performant, but at this time we cannot take a function pointer in java can we.

PS. It seems sourceforge is not showing statistics for me anymore – whats up with that?

June 29, 2009

Avalon Tycoon Mansion

Filed under: games — Tags: , , , , — zproxy @ 5:11 am

Yet another WPF powered flash game is ready for you to play. The game is written in C#. Let me know if you’d also want to see the source.

AvalonTycoonMansion by dadeval.
Update: There is now a forum thread at MochiAds and some good feedback by Newgrounds.
Update:
Here are the Impressions the game has made. As you can see it had reached 30k players in its best days.
avalontycoonmansion
See also:
Transport Tycoon 3D Project
Transport Tycoon 3D Project Trucks
Airport simulator

May 29, 2009

Using FLINT particle system from jsc

Filed under: jsc — Tags: , , , , , , — zproxy @ 6:00 pm
FLINT particle system

Moristar asked how to use an external libray from within a c# flash project. The short answer is yes you can, but you’d have to define stubs.

The long anwser…

In .net when you are talking to COM an interop assembly is used. The interop assembly defines types which represent the actual types to be used. That assembly is generated automatically at the time you reference the COM assembly.

It would be nice to be able to simply add a reference to a SWC file and use the features it defines, but currently it is not supported. A tool could be created which would read the SWC file and create the stub library. Currently this needs to be done manually.

Previous example

A year ago I did exactly this to get to use Google Maps with jsc. Today I updated its source to the latest Google Maps API version.

FlashGoogleMapsExample[source:svn]

In this post I am going to do this to demonstrate the same techniques for Flint and also comment on what I am doing.

(more…)

April 3, 2009

Awesomium

Filed under: life — Tags: , , , , — zproxy @ 12:28 pm

Today I learned, that there is a 3D internet explorer renderer out there.

This is what it looks like if you would be playing my treasure hunt multiplayer flash game.

What did I do to make it work?

  • Download Awesomium v1.0 demo
  • Add a link to the game in media\demo.html
  • Select Direct3D9 renderer

I guess there is room for more 3d browsers… and don’t forget Cooliris.

November 20, 2008

AvalonWebApplication with PHP backend

Filed under: jsc — Tags: , , , , , , , — zproxy @ 7:41 pm

I have created a new project template that demonstrates most of what jsc is capable of. Soon I will publish it on the sourceforge with a tutorial how to get started using it.

Long story short – Here is an application which demonstrates the following features all written in C#:

  1. PHP Backend
  2. JavaScript (WPF)
  3. ActionScript (WPF)
  4. Java Applet

Update: Moved the example to sourceforge and removed the querystring switch.

November 5, 2008

Avalon FreeCell

Filed under: jsc — Tags: , , , , , , , , , , — zproxy @ 7:41 pm

The next game powered by jsc has been released. This game works on .net, on javascript and on flash player.

The game is also available at Newgrounds over here and at WidgetBox.

Use Internet Explorer to open the Windows Presentation Foundation (XBAP) version.

Use Internet Explorer or Safari to open the JavaScript version.

The sourcecode is at google code.

October 26, 2008

AvalonExampleGallery Carousel

Filed under: jsc — Tags: , , , , , — zproxy @ 4:34 pm

AvalonGalleryExample project demonstrates how jsc compiler can be used in software development.

The entire project was written in c# and here are it’s versions for the web:

PHP + JavaScript Version – renders a static view for the user and uses javascript to gain interactivity.

XBAP Version – runs as a .net application via ClickOnce
Flash Version – runs as a flash application
JavaScript Version – runs as javascript application

October 22, 2008

jsc October Refresh

Filed under: jsc — Tags: , , , , , , — zproxy @ 8:24 pm

Some updates to the compiler and the framework.

Download jsc here. (Others already have!) Older releases are here.

Visit our google groups and the google site.

Tutorials to read when just starting with jsc:

This release contains the following Project Templates:

OrcasAvalonApplicationWPF Application, C# to JavaScript, C# to ActionScript

OrcasAppletApplication – C# to Java Applet
OrcasFlashApplication – C# to ActionScript
OrcasScriptApplication – C# to JavaScript
OrcasVisualBasicFlashApplication – VB.NET to ActionScript
OrcasVisualBasicScriptApplication – VB.NET to JavaScript
OrcasWebApplication – C# to JavaScript as Microsoft Web Application
OrcasWebSite – C# to JavaScript as Microsoft ASP.NET Web Site
OrcasJavaConsoleApplication – C# to Java as Console Application
OrcasNativeJavaConsoleApplication – C# to Java as Console Application with JNI bindings

Have a look at some old screencasts:

Have a look at the Avalon Gallery, note that it is actually a WPF Application.






October 4, 2008

Feedback for jsc

Filed under: jsc — Tags: , , — zproxy @ 8:56 am

Which one is better ? My heart goes to JSC as I’m fond of LINQ, it’s anonymous delegates syntax and extension methods, even if Script# seems better documented.
I’ve successfully created my first Flash application using JSC and I’m very proud ! So it really works ! Even if there are syntax tricks and the needs to know basic flash programming to make it work.

Read a post “Script# or JSC ?” by SoftLion

Update: JSC has been mentioned on Diary of the GX999.

Update: JSC has been mentioned back in April at Hide-Takata.

Update: JSC has been mentioned on livedoor.

Update: JSC has been mentioned by sanjay.

Update: JSC has been mentioned by steve at joelonsoftware.

September 25, 2008

jsc september 2008 refresh 2

Filed under: jsc — Tags: — zproxy @ 8:10 am

Some updates to the compiler and the framework.

Download jsc here. (Others already have!) Older releases are here.

Visit our google groups and the google site.

Tutorials to read when just starting with jsc:

This release contains the following Project Templates:

OrcasAvalonApplication – WPF Application, C# to JavaScript, C# to ActionScript

OrcasAppletApplication – C# to Java Applet
OrcasFlashApplication – C# to ActionScript
OrcasScriptApplication – C# to JavaScript
OrcasVisualBasicFlashApplication – VB.NET to ActionScript
OrcasVisualBasicScriptApplication – VB.NET to JavaScript
OrcasWebApplication – C# to JavaScript as Microsoft Web Application
OrcasWebSite – C# to JavaScript as Microsoft ASP.NET Web Site
OrcasJavaConsoleApplication – C# to Java as Console Application
OrcasNativeJavaConsoleApplication – C# to Java as Console Application with JNI bindings

Have a look at some old screencasts:

September 4, 2008

jsc september 2008 refresh

Filed under: jsc — Tags: , , , , , , , — zproxy @ 7:04 am

Some updates to the compiler and the framework.

Download jsc here. (Others already have!)

Added a WPF template.

Visit our google groups and the google site.

Tutorials to read when just starting with jsc:

This release contains the following Project Templates:

OrcasAvalonApplication – WPF Application, C# to JavaScript, C# to ActionScript

OrcasAppletApplication – C# to Java Applet
OrcasFlashApplication – C# to ActionScript
OrcasScriptApplication – C# to JavaScript
OrcasVisualBasicFlashApplication – VB.NET to ActionScript
OrcasVisualBasicScriptApplication – VB.NET to JavaScript
OrcasWebApplication – C# to JavaScript as Microsoft Web Application
OrcasWebSite – C# to JavaScript as Microsoft ASP.NET Web Site
OrcasJavaConsoleApplication – C# to Java as Console Application
OrcasNativeJavaConsoleApplication – C# to Java as Console Application with JNI bindings. (missing)

Have a look at some old screencasts:

FlashAvalonQueryExample

This is a WPF application based on the new OrcasAvalonApplication template. In debug mode jsc is not invoked and you can develop and debug the application as a regular one yet in release mode, the jsc is invoked at the post build event effectivly creating a javascript and an actionscript version for you. This example uses LINQ. See it in SVN here.

What does this example do? Based on a list of flickr images and a filter that defines a part of the image to be matched it returns a list of images and loads them over the network.

While developing with jsc, one must keep in mind the limits as only a minimum featureset is supported.

August 5, 2008

Extend your ASP.NET with C# to JavaScript tutorial

Filed under: jsc — Tags: , , , — zproxy @ 9:37 am

I have added a new tutorial for those of you who would like to extend existing ASP.NET web sites with jsc compiler.

Read the tutorial over here.

Update: This tutorial is now a part of the google jsc site.

July 17, 2008

Two New Examples

Filed under: jsc — Tags: , , , , , , — zproxy @ 3:11 pm




The RayCaster is based on this source and is just what you need to when you start making one of these Wolf3D games. The ZIndex demo shows how you could emulate the missing z-index property in flash 9.

July 5, 2008

FlashTowerDefense1 Versions

Filed under: jsc — Tags: , , , , , — zproxy @ 7:37 pm

For the past two months I’ve been busy developing this game. There are a total of three versions of this game.

SinglePlayer

SplitScreen

MultiPlayer

A screenshot of the SplitScreen version:

splitscreen

PS. The game does not have an ultimate objective, just not yet atleast 🙂

June 29, 2008

FlashTowerDefense1:MP Version 9

Filed under: jsc — Tags: , , , , , , , , — zproxy @ 2:18 am

Yet another screencast of my sheep rampage. This time you can kill coplayers, and we can change weapons. GTA style 🙂 Do you remmeber the keys? Oh, and I had to drop the wave by days feature for this version…

And look what happened when I submitted this game to Newgrounds 🙂

http://nonoba.com/zproxy/flashtowerdefense1mp

Play at Googlepages.

Game published on Newgrounds.

Embed it as Google Gadget here or here or here. View all videos of this game.

Add to Google

View source. Remember this is still flash, but the application is written in C#.

June 15, 2008

FlashTowerDefense1 v6.1

Filed under: examples, games, jsc — Tags: , , , , , , — zproxy @ 9:55 pm
Game updated to version 6. Player can now exit the machinegun and chase those sheep with a shotgun.

FlashTowerDefense1

You are in the command of a machine gun tower and you are raided by mad sheep and enemy warriors. Your mission is to shoot them down.

  • Size: 800×600
  • Category: Shooting
  • Tags: machinegun, sheep, blood
  • Content Rating: Everyone

Instructions: Aim at the enemy unit and hold down the mouse until the unit is terminated by gunfire.

Game published on Nonoba.
Game published on Multigames.
Game published on Newgrounds.

View older blog post or video post..

June 12, 2008

Jsc June Refresh 2

Filed under: jsc — Tags: , , , , , , , , , , — zproxy @ 4:29 pm

Some updates to the compiler and the framework: Download jsc here. (Others already have!)

Added two Java project templates.

Visit our google groups.

Tutorials to read when just starting with jsc:

This release contains the following Project Templates:

OrcasAppletApplication – C# to Java Applet
OrcasFlashApplication – C# to ActionScript
OrcasScriptApplication – C# to JavaScript
OrcasVisualBasicFlashApplication – VB.NET to ActionScript
OrcasVisualBasicScriptApplication – VB.NET to JavaScript
OrcasWebApplication – C# to JavaScript as Microsoft Web Application
OrcasWebSite – C# to JavaScript as Microsoft ASP.NET Web Site
OrcasJavaConsoleApplication – C# to Java as Console Application
OrcasNativeJavaConsoleApplication – C# to Java as Console Application with JNI bindings.

Have a look at some old screencasts:

June 11, 2008

jsc:actionscript Google Maps

Filed under: jsc — Tags: , , — zproxy @ 11:11 am

A new example project FlashGoogleMapsExample has been added to the homepage. The purpose of this example is to show how to use the new Google Maps Flash API within your OrcasFlashApplication¹.



Grab the latest version from the svn.

¹OrcasFlashApplication – An application written in C# inside Visual Studio 2008 IDE, compiled to MSIL, recompiled to ActionScript by jsc compiler and then finally compiled to flash by mxmlc.

June 7, 2008

FlashTowerDefense On YouTube

Filed under: jsc — Tags: , , , , , , — zproxy @ 2:29 pm

June 6, 2008

Jsc June Refresh

Filed under: jsc — Tags: , , , , , , , , , , — zproxy @ 2:43 pm

Some updates to the compiler and the framework: Download jsc here.

Most important update was fixing the virtual + override semantics for jsc:actionscript. It’ did not allow to combine multiple events for example.

Visit our google groups.

Tutorials to read when just starting with jsc:

This release contains the following Project Templates:

OrcasAppletApplication – C# to Java Applet
OrcasFlashApplication – C# to ActionScript
OrcasScriptApplication – C# To JavaScript
OrcasVisualBasicFlashApplication – VB.NET to ActionScript
OrcasVisualBasicScriptApplication – VB.NET to JavaScript
OrcasWebApplication – C# to JavaScript as Microsoft Web Application
OrcasWebSite – C# to JavaScript as Microsoft ASP.NET Web Site

Writing code in VB.NET for flash looks like this:

June 4, 2008

ASP.NET Web Site Template

Filed under: jsc — Tags: , — zproxy @ 2:24 pm

The new download – ASP.NET Web Site Template is available here. It includes the jsc compiler thus no need to install it. Download the zip and extract it under your ‘My Documents\Visual Studio 2008\Templates\ProjectTemplates‘. Create a new Web Site and view the ‘Default.aspx‘ in the browser. It should also work with the Visual Web Developer Express.

Create new project

Explore your solution

View in browser

See the generated HTML

It just works doesn’t it 🙂

FlashTowerDefense1 v2.1

Filed under: actionscript, examples, games, jsc — Tags: , , , , , , — zproxy @ 1:16 pm

A month has passed and $0.20 money has been made. I published this project to try this new trend to monetize your flash game I’ve read about on Emanuel’s blog. My idea is simple – use c# (view source) for coding, translate the project to a actionscript equivalent via jsc and draw yourself some graphics for the game. So far so good. I am now a member of GameBalance, MochiAds and Newsground where you can even visit my profile.

FlashTowerDefense1

You are in the command of a machine gun tower and you are raided by mad sheep and enemy warriors. Your mission is to shoot them down.

  • Size: 640×480
  • Category: Shooting
  • Tags: machinegun, sheep, blood
  • Content Rating: Everyone

Instructions: Aim at the enemy unit and hold down the mouse until the unit is terminated by gunfire.

You can see the stats for MochiAds and Newsground below:


What do you think I should add as a next feature? I’ve already read some of the suggestions and am considering adding them.

  • enemies come as waves
  • powerups
  • building multiple cannons
  • more doodads like trees and bushes

Visit older blog post here.

Update: Game published on Nonoba. View my profile.

Update: Game published on Multigames. View my profile.

May 2, 2008

Shoot that sheep!

Filed under: jsc — Tags: , , , , , , — zproxy @ 3:04 pm

This is a simple game written with in c# with jsc for flash. It includes Mochiads. Developers can download this example project here (includes .dll and generated .as files) or just browse the source here.

FlashTowerDefense1

You are in the command of a machine gun tower and you are raided by mad sheep and enemy warriors. Your mission is to shoot them down.

  • Size: 320×240
  • Category: Shooting
  • Tags: machingun, sheep, blood
  • Content Rating: Everyone

Instructions: Aim at the enemy unit and hold down the mouse until the unit is terminated by gunfire.

April 30, 2008

jsc april refresh 4

Filed under: jsc — Tags: , , , — zproxy @ 2:30 pm

Some minor updates to the compiler and the framework: Download jsc here.

Visit our google groups.

Previous releases contained a serious bug when jsc was being used on a machine without the DIA SDK. It comes with the Visual Studio retail version and I did not realized it before. Now jsc wont crash when the DIA SDK is not installed and method variable names will be autogenerated instead of beeing looked up in the pdb file.

Tutorials to read when just starting with jsc:

How things releate:
jsc

This is how it looks like when writing c# instead of actionscript:
flash

Older Posts »

Blog at WordPress.com.