Jump to content

Wherigo Foundation: WF.Compiler


charlenni

Recommended Posts

I want to devide the thread for WF.Compiler and WF.Player into two threads, because WF.Player belongs to the "Wherigo Hardware" forum, while the WF.Compiler is better hosted in this forum.

 

What's going on with the compiler for the Wherigo Foundation? In the last weeks, I droped the old compiler and created a new one. This leads to smaller code, better results and shorter compilation times.

 

The compilation processes of a cartridge consists of different parts.

 

1. Upload to website

When uploading a cartridge to the website, the cartridge should be checked. First, if it contains a Lua file. Second, if this Lua file consists of valid Lua code. Third, if all media files mentioned in the Lua file are included in the GWZ file. The compiler can now do this. If there is any problem in the Lua code, you get a message with the Lua error message, the line, where the error occures and the line above, the line itself and the line below of the error. So you could see, where and what problem Lua has. All this works.

 

2. Download from website

When downloading the cartridge from the website, the compiler has to extract, which medias go into the GWC file, change the medias according to the device, change the Lua code if necessary, compile the Lua code to a binary chunk and create a valid GWC file.

 

The first two parts are to get valid medias for a given device. Each device could use different types of medias. Garmins could not use PNGs, but JPGs. So we try to find for a given media a file with a valid format, the string "garmin" in the filename or the string "garmin" in the medias Directives. This file is than converted from the given format to JPG, resized to 230 pixel width and 24 bpp and saved to the GWC file. For other devices other conversions take place.

 

The second part is to change the Lua code, if necessary. For Garmins, we had to replace newlines to "<BR>\n" so that newlines work correct. Some other things had to be done with text (replace "<" with "&lt. For Urwigo files, special characters had to be converted from UTF-8 to Win-1252 encoding, so that you get some special characters also on Garmins (see screenshot "SpecialCharacters" from the cartridge "Wherigo Testsuite" from Jonny65). Also a workaround for the "ShowScreen" bug of Garmins is inserted. Other things could also be done. For other devices other conversions take place.

 

At the end the changed Lua code is compiled to a binary chunk and with the changed medias written to a valid GWC file.

 

The advantage over the native GS compiler is

- detailed error message, when there are errors in the Lua code

- conversion of images to a valid image format and size

- workarounds for bugs

- special characters with Urwigo (Earwigo can this by its own)

- complete open source for further development (code at https://github.com/WFoundation/WF.Compiler)

 

Todo:

- more workarounds for problems of different devices

- conversion of different audio formats

- converting to a stand alone compiler or a DLL

post-1322185-088772400 1396269907_thumb.png

Link to comment

Added today workarounds for the following problems:

 

Timer stop in OnTick

 

Belongs to: Garmin/Emulator/PocketPC

Problem: You couldn't stop a interval timer in its own OnTick event. It starts always again.

Status: Solved by Lua code, which is inserted while compiling.

 

Crash when input is open

 

Belongs to: Garmin/Emulator/PocketPC

Problem: If an input is open and a message box or a dialog appear on screen, the above devices are crashing

Status: Solved by Lua code, which is inserted while compiling. If the result of the input is nil, the OnGetInput event isn't called.

 

ShowScreen with a list

 

Belongs to: Garmin/Emulator/PocketPC

Problem: If you call ShowScreen with LOCATIONSCREEN, ITEMSCREEN, INVENTORYSCREEN or TASKSCREEN, the above player are crashing

Status: Solved by Lua code, which is inserted while compiling.

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...