Archive

Archive for the ‘MHEG’ Category

BBC Open Sources MHEG+ Toolkit

August 20, 2010 23 comments

MHEG Player showing the Freesat Red Button homepage

Some very good news for all the MHEG developers out there, the BBC have this week open sourced the MHEG+ toolkit and it can be downloaded over at the MHEG+ SourceForge page.

The release comes with little in the way of tutorials and so it might all seem a little daunting at first. But having used (and worked on) the toolkit for a couple of years I think it is worth the initial effort and recommend you give it a try.

I intend to write a full getting started guide to help new users over on the MHEG+ SourceForge forum, but for now here are some code examples and an ultra-quick guide to getting the toolkit up & running…

Code Examples

There is a simple “Hello World” MHEG+ application downloadable from the MHEG+ subversion repository.

This blog also has two examples of MHEG+ code, see these posts #1, #2.

Ultra-quick MHEG+ getting started guide

The toolkit contains a compiler and an emulator. Currently both are available for download as a separate Java .jar files. You will need Java installed to use them.

To use the emulator/debugger, download the file named MhegPlus.MhegPlayer-1.0.1.jar and issue the command:

java -jar MhegPlus.MhegPlayer-1.0.1.jar

This will launch the Mheg Player GUI.

To use the compiler first download the file named MhegPlus.Compiler-1.0.1.jar. The compiler can invoked with the following command, but you will need to pass command-line options to get anything meaningful out of it:

java -jar MhegPlus.Compiler-1.0.1.jar

You can get help on the various compiler options by passing –help, e.g.:

java -jar MhegPlus.Compiler-1.0.1.jar --help
usage: mhegplus
-p,--output-app output application file? (optional)
-d,--output-dir output directory (optional)
-P,--output-app-sans-extension output application file as a or startup
(optional)
-l,--log-level log level
(FINE|INFO|WARNING|ERROR|SEVERE)
-a,--asn1 select ASN.1 output (default)
-f,--application application file
-h,--help print this help
-t,--text select text output
-v,--version report version number

Happy MHEG+ing!

MHEG+ Game Development Tutorial, Part #2 — Animation

December 14, 2008 6 comments

In part #1 of this series we built a basic MHEG+ scene which was capable of firing timer events at a consistent rate.  In this part we will look to extend the code by adding an animating graphic to the scene.

A further aim of this part is to explain some more of the language features exclusive to MHEG+, including foreach loops, sequential blocks and ifs.

Adding our graphics to the scene

I have hand crafted the following 5 png graphics to use for this tutorial:

pacs

Using an MHEG+ foreach loop, we can add all these graphics to our scene in one fell swoop:

  foreach num (0..4) {
    {:Bitmap bmpPac<num> = [constPacObjectIdOffset + <num>]
     :OrigPosition          [(720 - 32) / 2] [(576 - 32) / 2]
     :OrigBoxSize           32 32
     :OrigContent           :ContentRef ('/tut/<num>.png')
     :InitiallyActive       false
    }
  } endfor

There a number of subtleties of this loop which are probably worth discussing:-

  • foreach loops are preprocessor instructions, not run-time loops.  Because of this we can use foreach loops around object declarations, or in fact any code section at all.
  • In this case, the contents of the foreach loop will be duplicated 5 times, this is controlled by the (0..4) range on the first line.  This range need not be numeric, text may also be used, for example: foreach key (red, green, yellow, blue) is allowed.
  • The Bitmaps we declare will be named bmpPac0 through bmpPac4, <num> is substituted with each value in the range.
  • The object identifiers for the Bitmaps will be 100 through 104, assuming constPacObjectIdOffset has the value 100.  We use the MHEG+ notation: objectname = objectid to declare both names and object identifiers for our Bitmaps.
  • <num> is also substituted in the png filename

Read more…

MHEG+ Game Development Tutorial, Part #1 — Timing

November 26, 2008 5 comments

Introduction to this Series

One of the joys of my job at the BBC is staying back after hours and trying to nut out how best to write real-time games on current interactive television platforms.  That is, trying to write the kind of games that you might have once played in an arcade, or maybe on your BBC Micro, but allowing you to play them via the ‘Red Button’.  See this post for a video of some of my efforts so far.

Here in these tutorials I hope to share with you some of my findings in trying to get the best out of the MHEG platform.  I also hope to demonstrate the power of the MHEG+ programming language, an extension to MHEG.  MHEG+ has been developed in-house at the BBC and compiles down to traditional MHEG/ASN, but is a far richer langauge than its predecessor.

For these tutorials I will assume you have some background in programming generally and hopefully some experience writing MHEG or interactive TV applications (MHP, OpenTV, etc.).  The code samples will all be in MHEG+ which at time of writing is not available outside the BBC, however efforts are being made to attempt to open source MHEG+ development tools, so watch this space…

I guess for the time being then you most likely won’t be able to compile or run these applications, but hopefully one day soon you will be able to.  Therefore I suppose the code herein is currently just for educational purposes, but then that is the point of the series 🙂

So, without further ado…

Part #1: Timing

The first significant challenge that I came across when writing MHEG games was that of timing.  How could I ensure my game would run at virtually the same speed on any set top box?

Unlike more sophisticated languages (yes, I openly admit that MHEG is not the most sophisticated language, but then it was never designed to be) MHEG does not provide the developer with a means of retrieving accurate clock information.  The most fine-grained time information you can retrieve (achieved by a call to the GetCurrentDate resident program) provides no better than whole second precision. Read more…

Video: Games I’ve written in MHEG

September 19, 2008 4 comments

MHEG is a programming language & middleware found in digital set top boxes in the UK and elsewhere around the world.  This video briefly shows a few games I have written in MHEG while working at the BBC.

The games shown in the video are:-

  1. ‘Nibbler’ – a Snake clone.
  2. ‘Bounce!’ – really more of a tech demo than a finished game, but surprisingly fun.  Catch the green blobs but avoid the red one.
  3. ‘Ping Pong’ – pretty self explanatory I think.

The games have never been broadcast.  I am hoping the powers that be at the BBC will let them go to air.  What do you think?  Would you like to be able to ‘Press Red’ and play games such as these?

Obviously the graphics could do with some work, but these games do at least prove the technology…

Leave a comment if you’d like to see the BBC do classic arcade style games on interactive TV.