Demo (Byte)code interpreter, useful for updating games in real time, game mods and more!

Yambam

Member
GM Bytecode 0.1.0

GM Version:
Game Maker 8 currently (working on GM:Studio)
Target Platform: Windows currently
Home page: http://imanuelhab.mooo.com/gm-bytecode/changelog
Download: http://imanuelhab.mooo.com/gm-bytecode/builder/exe/0.1.0
Source: Coming soon, so you can use it in your own project. (GMZ format)

Summary:
Execute bytecode (a simple, portable and concise piece of code) and use any of GameMaker's functions in them. Don't worry, it's also supposed to work in it also works GM:Studio (tested a previous version already), since every function you need is wrapped in a seperate GML script, so that the main script can execute it. And you can automatically let the script convert GML to bytecode before you execute it. :)

Usage and more:
Coming soon...

Use cases:
  • Execute any code dynamically by compiling a higher-level language (e.g. GML) to their bytecode equivalent.
  • Make moddable games.
  • Make a plugin system for your program / game world editor.
  • Keep a game organized by having different sections of the engine in external files and folders. You can for example have the external images, sounds and code in subfolders, instead of having to search for the boss objects in the "Objects" group and the corresponding sprites in "Sprites", the sound effects in "Sounds", etc. Possibly encrypted.
  • More simple/efficient way to supply small game updates. Since you only have to send small pieces of code (and maybe some new images) using HTTP (bytecode is even smaller than "normal", more high-level languages such as GML), the updates load faster and more simply without the need of downloading whole game package (.exe/.apk) files.

Screenshots:
 
Last edited:

YellowAfterlife

ᴏɴʟɪɴᴇ ᴍᴜʟᴛɪᴘʟᴀʏᴇʀ
Forum Staff
Moderator
Curious to see where this'll go. Doesn't seem to support loops and branching (yet?), but displayed bytecode makes it seem like you generally know what you are doing with a stack-based "VM".
 

Yambam

Member
Curious to see where this'll go. Doesn't seem to support loops and branching (yet?), but displayed bytecode makes it seem like you generally know what you are doing with a stack-based "VM".
Well, there's no "go to" statement as of this version, I don't know exactly what you mean with branching though. Basically putting a piece of code between {} makes that bit parsed as a separate "block" which will be called to execute the lines one-by-one by the "parent" block. I guess that's not really standard 'bytecode', but it works! :)

The syntax for if statements and while statements is maybe a bit strange. Just put two blocks of code next to each other with a capital I in between, the one on the left should leave a value on the stack (the conditional), the other one will only be executed if popping the value from the stack evaluates to true (i.e. if it's >=.5). The while statement looks similar, except with a capital W in between.

Examples:
This will generate a little Mario jump SFX:
Code:
t=0;snd=sndstart(4410,true); <?gmbc {_snd t 0.005t* 0.995+ * _pi* 44* 44100/ _sin, _snddata tt1+=}U{0} ?>
Yes! <?gmbc...?> is the syntax for mixing GML and bytecode! :)

Here's a simple 440 Hz sine wave sound:
Code:
t=0;snd=sndstart(4410,true); <?gmbc {_snd t 2* _pi* 440* 44100/ _sin, _snddata tt1+=}U{0} ?>
The snd=sndstart(4410,true) part means this: make a buffer of size 4410 bytes and loop the sound whenever the next sound isn't available yet. In GML you could do something like snddata(snd,sin(t*2*pi/44100)) to add data to the buffer, but I haven't implemented loops in the GML to bytecode compiler yet.
 
Last edited:

Yambam

Member
Curious to see where this'll go. Doesn't seem to support loops and branching (yet?), but displayed bytecode makes it seem like you generally know what you are doing with a stack-based "VM".
Would it make sense to even implement a 'GOTO' statement though? I think it makes code less readable. I do plan on adding functions, both in-line declared functions and normal functions which are hoisted. Do you have any idea how I can start? Thanks in advance (anyone). :)
 

YellowAfterlife

ᴏɴʟɪɴᴇ ᴍᴜʟᴛɪᴘʟᴀʏᴇʀ
Forum Staff
Moderator
Would it make sense to even implement a 'GOTO' statement though? I think it makes code less readable. I do plan on adding functions, both in-line declared functions and normal functions which are hoisted. Do you have any idea how I can start? Thanks in advance (anyone). :)
"goto" (, "goto if", "goto unless") bytecode actions are used to implement if-then, loops, and switches. You can take a glance at how GameMaker handles this by right-clicking on a script tab in debugger and picking "View VMASM"
 

Yambam

Member
"goto" (, "goto if", "goto unless") bytecode actions are used to implement if-then, loops, and switches. You can take a glance at how GameMaker handles this by right-clicking on a script tab in debugger and picking "View VMASM"
I guess this then is some sort of mix of conventional higher-level programming languages and VM assembly. (Is that the same as bytecode?)
 
Top