The Haus

Saturday, December 18, 1999

Q3A VM & Coding Notes

Zoid made an appearance on the q3coders mailing list with this interesting tidbit on coding mods in Q3A:
From what I've read you write your Q3A-mod in ANSI C using an API similar to the build-in functions in QuakeC. Then you compile it with the modified version of LCC that is hopefully released soon. What you get is a .qvm-file containing bytecode just like in the progs.dat from Quake. This file can be interpreted by the engine or it can be compiled to native code on the fly (works like Java's JIT?).
This is exactly right.

There are three virtual DLLs in the game. cgame for the client, qagame for the server and ui for the menu user interface. They are all written in standard ANSI C.

Quake3 will run any of these DLLs in one of three modes:

  1. A native binary (DLL for Win32, .so file for Linux, etc).
  2. Interpreted QVM (this works on all platforms)
  3. JIT Compiled to native code (only works on i386 and PowerPC platforms).
John developed the JIT code because pure interpreted code was very slow. With interpreting the QVM, we saw as much as half your framerate going away to handling the QVM. But with JIT, it's only a three or four percent hit as compared to a native DLL. That's pretty damn amazing considering that the QVM is platform independant.

When doing development and debugging, its best do it as a native binary. That way you can use standard debugging tools on your code. Once you'vetested it an debugged it, you then use lcc combined with q3asm to convert the code into a .qvm file.

The QVM file is 100% portable across all platforms that Quake3 will be available on. The JIT features are up to the implementation of Quake3 on that platform, not your code.

This method has many benefits--you can use a standard language when development modifications (ANSI C), but not lose the benefit of cross-platform compatibliy such as QuakeC had. You can you use native binaries to allow use of state of the art debugging facilities whiledeveloping your code as well.

John choose LCC since its a freely available retargettable C compiler that is very simple to use and modify. Writing a back end to GCC is no small task--though when the specifications for q3asm is released, someone could very well write a back end to GCC. The VM bytecodes are pretty language independant. This would result in stuff like GNU C++ being able to be compiled to the VM for example (this is not unreasonable!). That would be a pretty cool hack job tho. :)

News for 12/18/1999

Recent Headlines

January 5, 2015: It Returns!
August 10, 2007: SCO SUCKS IT DOWN!
July 5, 2007: Slackware 12.0 Released
May 20, 2007: PhpBB 3.0 RC 1 Released
February 2, 2007: DOOM3 1.31 Patch

January 27, 2007: Join the World Community Grid
January 17, 2007: Flash Player 9 for Linux
December 30, 2006: Darkness over Daggerford 1.2
December 19, 2006: Pocket Tunes 4.0 Released
December 9, 2006: WRT54G 1.01.1 Firmware OK with Linux/Mac

All original information on this website is copyright © TheHaus.Net, 1999-2005. The use of original images, text, and/or code from this website without expressed written consent is prohibited. The authors of this site cannot be held responsible for any damage, real or imagined, which comes from the use of information presented on this site. All trademarks used are the properties of their respective owners. This site is not to be used as a floatation device (but if you try, I want a video tape of it).