]> 4ch.mooo.com Git - 16.git/blobdiff - 16/v2/VERGEC.TXT
refresh wwww
[16.git] / 16 / v2 / VERGEC.TXT
diff --git a/16/v2/VERGEC.TXT b/16/v2/VERGEC.TXT
new file mode 100755 (executable)
index 0000000..bfa80f2
--- /dev/null
@@ -0,0 +1,1625 @@
+                      +----------------------------------+\r
+                      Ý    VergeC 2.0  Reference File    Ý\r
+                      Ý      Language Specification      Ý\r
+                      Ý      VC Built-ins reference      Ý\r
+                      +----------------------------------+\r
+\r
+Current as of 5.9.99\r
+\r
+=============================================================================\r
+\r
+I. Language Specification\r
+\r
+A. Comments\r
+-----------\r
+Just as in VC1, both C and C++ style comment conventions are supported.\r
+\r
+    1. Comments: Comments are not required in your VergeC code, but smart\r
+       event coders will use them to help organize and make their event\r
+       scripts readable for future reference. They are ignored by the\r
+       compiler. There are two ways to use comments:\r
+\r
+      a. If you type a double slash (//) in your code, everything on that\r
+         line after the slashes will be ignored.\r
+\r
+         Event  // #75: When Dexter joins\r
+         {\r
+          Addcharacter(3);\r
+         }\r
+\r
+      b. The second method is to use /* and */. When the compiler encounters\r
+         a /*, everything will be ignored until it sees a */. Example:\r
+\r
+         Event\r
+         {\r
+         /* This is the part where Dexter joins after\r
+            being seen on the path of Jujube mountains.\r
+            The event below is number 75. */\r
+          addcharacter(3);\r
+         }\r
+\r
+         The // is preferred for simple phrases that you wish commented, while\r
+         the /* */ method is best for large areas of text to be left commented.\r
+\r
+         NOTE: Try using commenting if you have a problematic area of your\r
+               event script that refuses to compile. Use // before the lines\r
+               that create errors and try recompiling until you can isolate\r
+               the problem.\r
+\r
+B. Code control structures\r
+---------------------------\r
+VergeC 2.0 supports most of the code control structures that genuine ANSI C\r
+does, with some differences that are explained below:\r
+\r
+    1. IFs: if statements are the most basic form of code execution control.\r
+       They have been much improved since VC1, primarily from the addition\r
+       of OR conditionals as well as the ELSE branching statement.\r
+       The basic format of an IF is:\r
+\r
+       if (condition <list>)\r
+       {\r
+         (code to be executed if condition is true)\r
+       }\r
+       else\r
+       {\r
+         (code to be executed if condition is false)\r
+       }\r
+\r
+    2. SWITCHs: switch/case statements basically replace a series of IF\r
+       statements. Cases are yet another method of simplifying and\r
+       empowering your VC code's flexibility. They are most useful in\r
+       situations where you wish to provide multiple results based on the\r
+       condition of some variable. Here's how they're used:\r
+\r
+       Switch(<variable to be tested>)\r
+       {\r
+         Case <result 1>: <command>;\r
+         Case <result 2>: <command>;\r
+         Case <result 3>: <command>;\r
+       }\r
+\r
+       When the interpreter encounters this construct, it will test the value\r
+       of what is given in the Switch parentheses, then run the Case statement\r
+       that matches it, if any. Note that unlike C, no break; statements are\r
+       in the below example; break statement in VC are not only unnecessary but\r
+       will cause an error if they are present. Example:\r
+\r
+       switch (PartyIndex(1))\r
+       {\r
+         case 1: Text(1,"My name's Darin and I'm leading this party!","","");\r
+         case 2: Text(2,"I'm Sara and I'm here to pump you up!","","");\r
+         case 3: Text(3,"Dexter is leading this party.","","");\r
+       }\r
+\r
+    3. WHILE loops:\r
+       It works much the same as a FOR loop, but can use nearly any condition\r
+       to control how long it executes. The syntax is such:\r
+\r
+       while (<condition>)\r
+       {\r
+         commands;\r
+       }\r
+\r
+       The condition inside the parentheses after WHILE can be anything you can\r
+       stuff in an IF statement. When the engine encounters a WHILE loop, it will\r
+       repeatedly execute the commands inside the curly braces until the condition\r
+       inside the parentheses is NOT true. Therefore, your WHILE loop should\r
+       contain some commands that affect that condition, or else your loop will\r
+       run endlessly.\r
+\r
+    4. FOR loops:\r
+       FOR loops are perhaps more commonly used than WHILE, altho I personally\r
+       dig WHILE loops greatly. Anyhow, FOR loops in VergeC 2.0 are much closer\r
+       to their true C counterparts than they were in VC1. The syntax now is:\r
+\r
+       for (init; condition; post)\r
+       {\r
+          commands;\r
+       }\r
+\r
+       To clarify, an example would be:\r
+\r
+       for (i=0; i<5; i++)\r
+       {\r
+         printstring(i,"This is font "+str(i)+".");\r
+       }\r
+\r
+C. system.vc, map-based VC, and the relationship thereof\r
+--------------------------------------------------------\r
+There are two distinct types of VC in V2, and that is the system.vc, and\r
+everything else, which are MAP-based VC files. MAP based VC is very similar\r
+to how VC was in V1. You cannot declare your own functions or variables in\r
+a MAP vc. They use the familiar event { } style scripts. When they are\r
+compiled their pcode is attached directly into the MAPfile itself.\r
+\r
+The other type is system.vc, which is compiled into the files system.vcs and\r
+system.idx, respectively. system.vc allows you to declare your own functions\r
+and variables - the trick comes in that any of your map VC can access any\r
+and all of the functions and variables set up in system.vc.\r
+\r
+The only real problem arises that, because of the new relationship between\r
+system.vc and map-based VC, it's conceivable (quite likely, actually) that\r
+if you modify system.vc you'll break MAPs that you've already compiled. As\r
+such, VCC now has a 'vcc all' option, that will compile system.vc, and then\r
+recompile all maps it can find in the given directory. ME2 has a shortcut\r
+to do this right from inside MapEd - Just hit F6 and it'll rebuild all of\r
+your VC files. (of course, this means you can't have an ALL.MAP. Oh well,\r
+live with it. ^_-)\r
+\r
+There is nothing like startup.vc or startup.scr in V2. When you execute\r
+verge.exe, it always starts execution at a MAP file. Which mapfile it starts\r
+at is determined in user.cfg, by the 'startmap' command. Additionally, you can\r
+start verge.exe at a specific map by specifying the mapfile on the command\r
+line, which MapEd makes use of to directly test out the mapfile you're\r
+currently working on.\r
+\r
+D. Syntax for user-declared variables and functions\r
+---------------------------------------------------\r
+\r
+    1. Funtions\r
+       There are two types of user declared functions, ones that return a\r
+       value and those that don't. The simplist declaration for a function\r
+       would be:\r
+\r
+       void MyFunc()\r
+       { }\r
+\r
+       You can add passed parameters like so:\r
+\r
+       void MyFunc(int a, string b)\r
+       { }\r
+\r
+       These parameters would be accessed inside this function as any other\r
+       variable would be, but it only exists inside the function. You would\r
+       call this function from map or other system.vc code with something\r
+       like this: MyFunc(5, "Hello.");\r
+\r
+       To make your function return a value, you'd declare it like so:\r
+\r
+       int MyAdd(int a, int b)\r
+       {\r
+          return a+b;\r
+       }\r
+\r
+       You cannot currently have a function return a string type. This may\r
+       change in a future version of V2/VC.\r
+\r
+    2. Variables\r
+       There are only two variable types in VC, int (integer) and string.\r
+       Both are declared the same basic way:\r
+\r
+       int num;\r
+       string name;\r
+\r
+       You can define multiple variables of the same type onto a single line:\r
+\r
+       int x1, y1, x2, y2;\r
+\r
+       You can also declare arrays of variables:\r
+\r
+       int flags[8000];\r
+\r
+       You can declare arrays of both ints and strings. You can only declare\r
+       them in SYSTEM.VC (and any #included sub-files). Variables declared\r
+       outside of any function are global and can be accessed by any system.vc\r
+       OR map-based VC event at all. Variables declared inside a given\r
+       system.vc function are local variables, which only exist during the\r
+       duration of that function's execution, and can't be accessed outside\r
+       of that function.\r
+\r
+       Limits of passed parameters and local variables: For any given system.vc\r
+       function, the total number of passed parameters and local variables\r
+       cannot exceed 20, and the total number of passed and locally declared\r
+       strings cannot exceed 10. However, if you have 10 strings, you can only\r
+       have 10 ints, otherwise the total limit of 20 variables\r
+       (int and otherwise) would be exceeded.\r
+\r
+       If there is a global variable and local variable of the same name,\r
+       inside the function the local variable will be used instead. But in\r
+       a function where that local var isn't declared, or a map-vc event,\r
+       the global variable will be used instead.\r
+\r
+       We may add the ability to declare local variables in map-vc events in\r
+       a later release.\r
+\r
+E. Special string operators\r
+---------------------------\r
+\r
+We strived to make VC2 closer to "real" C in most aspects, but strings is not\r
+one of them. In real C, string manipulation is fairly clunky, and not very\r
+easy for beginners to pick up. So, we have created a string system that's\r
+somewhat like a mix of Pascal and BASIC.\r
+\r
+Any string can be combined any number of times, altho the total length of\r
+any one string cannot exceed 255 characters. For instance, if you had a string\r
+variable named OurHero, and it contained the main character's name, you\r
+could do something like:\r
+\r
+  Text(0,"Greetings, "+OurHero+". We",\r
+         "have been expecting you.", "");\r
+\r
+Additionally, there are 4 other commands which can be used during string\r
+combination: str(), left(), right(), and mid():\r
+\r
+  str(int) - converts a numerical value into string form.\r
+  left(string, n) - returns the leftmost n characters of string.\r
+  right(string, n) - returns the rightmost n characters of string.\r
+  mid(string, start, run) - returns a section of string, starting at the\r
+                            start character, run characters long.\r
+\r
+And lastly, the val(string) attempts to convert a string back to an\r
+interger value. If the string has too many non-numerical characters in it,\r
+however, it may not be able to.\r
+\r
+F. Preprocessor directives\r
+--------------------------\r
+\r
+As in the original VC, VC2 emulates two primary C preprocessor directives,\r
+#include and #define. #include has been expanded, while #define has been\r
+scaled back.\r
+\r
+#include is more stable than before, and you can have nested #includes without\r
+any problems. The primary purpose of #includes in VC2 is to allow you to break\r
+up your system.vc into sub-files such as menu.vc, battle.vc, or similar\r
+divisions, and just #include those units into your main system.vc.\r
+\r
+Since VC2 now has proper functions, the macro-like behavior of #define in the\r
+VC1 preprocessor is no longer necessary, and since it was rather highly\r
+unstable, it was taken out. The primary purpose of #defines in VC2 is to\r
+allow an unlimited number of simple symbolic constants. An example would be:\r
+\r
+#define k_ESC 1\r
+if (key[k_ESC]) Text(0,"ESC has been pressed.","","");\r
+\r
+We may also later add conditional compilaton if there is a request for it.\r
+\r
+G. Pointers and direct memory access\r
+------------------------------------\r
+\r
+If you are not a native C programmer, you are more than welcome to skip over\r
+this section. I would not dare attempt to teach the principals of pointers\r
+to those who aren't programmers in their own right, and you don't really need\r
+to understand VC2's implementation using pointers for direct memory access for\r
+the vast majority of things you could ever want to do in VergeC.\r
+\r
+Since VC deals with all numeric variables as integers (signed, 32-bit values),\r
+it would not really make sense for us to implement the standard * and &\r
+operators, since you'd only be able to operate on data of type int.\r
+\r
+So, we have 6 builtins which aren't quite functions, and they aren't quite\r
+variables, but whatever they are, they're there. They are:\r
+\r
+(unsigned) byte[ptr]\r
+(unsigned) word[ptr]\r
+(unsigned) quad[ptr]\r
+  (signed) sbyte[ptr]\r
+  (signed) sword[ptr]\r
+  (signed) squad[ptr]\r
+\r
+Note: signed allows for negative numbers.\r
+\r
+Using the convention:\r
+ byte = 8 bits\r
+ word = 16 bits\r
+ quad = 32 bits\r
+\r
+The main reason these don't quite qualify as C functions is that you can also\r
+assign them values. Ie:\r
+\r
+  byte[myptr]=5;\r
+  if (byte[myptr] != 5)\r
+    Exit("Your computer is smoking crack, my friend.");\r
+\r
+H. Misc\r
+-------\r
+1. Alternate ways of expressing numbers\r
+   VC has three ways that it recognizes an immediate numerical value.\r
+\r
+   a. Standard/Decimal\r
+      The first is a standard, base-10 number. Just 65 or something. ex:\r
+\r
+      myval=65;\r
+      if (myval != 65)\r
+        Exit("Woe to thee, for thine computer smoketh crack, verily.");\r
+\r
+   b. Hexademical\r
+      VC uses Pascal's convention for handling hexademinal numbers, which\r
+      is to preceed a hexadecimal numerical delcaration with a $ sign. ex:\r
+\r
+      myval=255;\r
+      if (myval != $FF)\r
+        Exit("For thus sayeth the Lord, that thine processor was created by"+\r
+             "those darwinists who would believe that a CPU can be created"+\r
+             "by putting silicon in a frying pan and shaking it around a lot."+\r
+             "Well, either that, or you're running a Microsoft OS.");\r
+\r
+   c. ASCII character conversions\r
+      You can use C style single tick marks to denote an ASCII char conversion.\r
+      However, it does not support C's \ codes. Whats in between the tick\r
+      marks is taken directly. ex:\r
+\r
+      myval=65;\r
+      if (myval != 'A')\r
+        Exit("A stroke from the brush does not guarantee art from the bristles.");\r
+    \r
+2. Order of Operations\r
+   Does not exist.  Use parentheses gratuitously.  \r
+   Oftentimes you will want to do something like this: putpixel(x+y*320\r
+   This will not work!  V2 will add x and y, then multiply the result by 320.\r
+   As always, any order of operations expression can be rewritten with\r
+   parentheses.  In the example: putpixel(x+(y*320)\r
+\r
+=============================================================================\r
+\r
+II. Builtin Functions\r
+\r
+---------------------------\r
+void AllowConsole(int flag)\r
+---------------------------\r
+Controls whether or not the ` key will summon the console or not. 0 will\r
+disallow the console, 1 will activate it. Disabling the console is a good\r
+way to prevent cheating, however having it enabled will make developing\r
+and testing the game easier.\r
+\r
+Example:\r
+  AllowConsole(1);\r
+\r
+-------------------------------\r
+int CacheSound(string filename)\r
+-------------------------------\r
+Loads a specified sound effect (8-bit, mono, un-compressed WAV file), and\r
+returns the slot number that you'll access this sound with for PlaySound.\r
+\r
+See also: FreeAllSounds(), PlaySound()\r
+\r
+Example:\r
+  snd_shriek = CacheSound("SHRIEK.WAV");\r
+\r
+-----------------------\r
+void CD_Play(int track)\r
+-----------------------\r
+Begins playing CD audio at the specified track number.\r
+\r
+Example:\r
+  CD_Play(6);\r
+\r
+--------------\r
+void CD_Stop()\r
+--------------\r
+Stops all CD audio playing.\r
+\r
+Example:\r
+  CD_Stop();\r
+\r
+------------------------------------------------\r
+void Circle(int x, int y, int radius, int color)\r
+------------------------------------------------\r
+Draws a circle (outline only) of the given radius, centered at the given\r
+coordinates, in the given color.\r
+\r
+See also: CircleFill()\r
+\r
+Example:\r
+  Circle(screenx/2, screeny/2, 50, 128);\r
+\r
+----------------------------------------------------\r
+void CircleFill(int x, int y, int radius, int color)\r
+----------------------------------------------------\r
+Draws a filled circle of the given radius, centered at the given\r
+coordinates, in the given color.\r
+\r
+See also: Circle()\r
+\r
+Example:\r
+  CircleFill(screenx/2, screeny/2, 50, 128);\r
+\r
+---------------------------------------------------------------\r
+void CopySprite(int x, int y, int width, int height, int image)\r
+---------------------------------------------------------------\r
+Blits the image pointed to by image with the given dimensions at the\r
+given location on screen. No transparency, clipping is performed.\r
+\r
+See also: TCopySprite\r
+\r
+Example:\r
+  im = LoadImage("VECNA.PCX");\r
+  CopySprite(0, 0, image_width, image_height, im);\r
+  free(im);\r
+\r
+-------------------\r
+int cos(int degree)\r
+-------------------\r
+Returns the cosine of the given degree of measure (0-360) in 16.16 fixed\r
+point.\r
+\r
+See also: sin(), tan()\r
+\r
+Example:\r
+  result = cos(45);\r
+\r
+----------------------------------------------\r
+void EntityMove(int entity, string movescript)\r
+----------------------------------------------\r
+Sets the given entity to the specified movement script. As in V1,\r
+you cannot use 'B', the loop command, in an EntityMove given script.. But\r
+I should be able to work around that so that it will work eventually.\r
+\r
+Example:\r
+  ent = EntitySpawn(0, 1, "VECNA.CHR");\r
+  EntityMove(ent, "D2R2");\r
+\r
+---------------------------------------------\r
+int EntitySpawn(int x, int y, string chrname)\r
+---------------------------------------------\r
+Allocates a new entity at the given coordinates, using the specified CHR file.\r
+The entity index of the new entity is returned.\r
+\r
+See also: SetPlayer()\r
+\r
+Example:\r
+  ent = EntitySpawn(0, 1, "VECNA.CHR");\r
+\r
+-------------------------\r
+void Exit(string message)\r
+-------------------------\r
+Completely exits out of the engine leaving the user with the specified\r
+message.\r
+\r
+Example:\r
+  Exit("Thank you for playing!");\r
+\r
+---------------------------\r
+void fclose(int filehandle)\r
+---------------------------\r
+Closes the file given by the specified file handle.\r
+\r
+See also: fopen()\r
+\r
+Example:\r
+  file = fopen("EXAMPLE.DAT");\r
+  // ** use file here **\r
+  fclose(file);\r
+\r
+----------------------------\r
+int fgetbyte(int filehandle)\r
+----------------------------\r
+Gets a single byte from the specified file and returns it's value.\r
+\r
+Example:\r
+  file = fopen("TEST.DAT");\r
+  Message("First byte in TEST.DAT is: "+str(fgetbyte(file)), 200);\r
+  fclose(file);\r
+\r
+----------------------------\r
+int fgetword(int filehandle)\r
+----------------------------\r
+Gets a single word (2 bytes) from the specified file and returns it's value.\r
+\r
+Example:\r
+  file = fopen("TEST.DAT");\r
+  Message("First word in TEST.DAT is: "+str(fgetword(file)), 200);\r
+  fclose(file);\r
+\r
+----------------------------\r
+int fgetquad(int filehandle)\r
+----------------------------\r
+Gets a single quad (4 bytes) from the specified file and returns it's value.\r
+\r
+Example:\r
+  file = fopen("TEST.DAT");\r
+  Message("First quad in TEST.DAT is: "+str(fgetquad(file)), 200);\r
+  fclose(file);\r
+\r
+----------------------------------------------\r
+void fgetline(string variable, int filehandle)\r
+----------------------------------------------\r
+Grabs the next line from the specified text file handle and returns it in the\r
+string variable passed.\r
+\r
+Example:\r
+  file = fopen("EXAMPLE.TXT");\r
+  fgetline(my_string, file);\r
+  Message("First line in EXAMPLE.TXT is: "+my_string, 200);\r
+  fclose(file);\r
+\r
+Note: String support is a bit sketchy in V2 at the moment, and this command,\r
+      along with fgettoken(), only accept global strings as valid parameters.\r
+      It also will not read correctly into string arrays.\r
+\r
+-----------------------------------------------\r
+void fgettoken(string variable, int filehandle)\r
+-----------------------------------------------\r
+Grabs the next token (space delimited) from the specified text file handle\r
+and returns it in the string variable passed.\r
+\r
+Example:\r
+  file = fopen("EXAMPLE.TXT");\r
+  fgettoken(my_string, file);\r
+  Message("First token in EXAMPLE.TXT is: "+my_string, 200);\r
+  fclose(file);\r
+\r
+---------------------------\r
+int FontHeight(int fontidx)\r
+---------------------------\r
+Returns the height of the font at the given font index.\r
+\r
+See also: FontWidth()\r
+\r
+Example:\r
+  height = FontHeight(0);\r
+\r
+--------------------------\r
+int FontWidth(int fontidx)\r
+--------------------------\r
+Returns the width of the font at the given font index.\r
+\r
+See also: FontHeight()\r
+\r
+Example:\r
+  width = FontWidth(0);\r
+\r
+--------------------------\r
+int fopen(string filename)\r
+--------------------------\r
+Opens the given file and returns a unique file handle integer.\r
+\r
+See also: fclose()\r
+\r
+Example:\r
+  file = fopen("EXAMPLE.TXT");\r
+  fclose(file);\r
+\r
+--------------------------------------------------\r
+void fread(int buffer, int length, int filehandle)\r
+--------------------------------------------------\r
+Reads in a given amount of data from the specified file into the given buffer.\r
+Thus buffer must be pre-allocated by the user.\r
+\r
+Example:\r
+  file = fopen("TEST.DAT");\r
+  buffer = malloc(100);\r
+  fread(buffer, 100, file);\r
+  fclose(file);\r
+\r
+----------------------\r
+void free(int pointer)\r
+----------------------\r
+Frees the memory space pointed to by the given pointer. (ie, you would pass\r
+the same value returned by malloc for a memory segment)\r
+\r
+Example:\r
+  buffer = malloc(100);\r
+  // ** use buffer here **\r
+  free(buffer);\r
+\r
+--------------------\r
+void FreeAllSounds()\r
+--------------------\r
+Frees all sound effect slots.\r
+\r
+See also: CacheSound(), PlaySound()\r
+\r
+Example:\r
+  FreeAllSounds();\r
+\r
+-----------------------------\r
+void fdelete(string filename)\r
+-----------------------------\r
+Deletes the specified file. (uhm.. obviously, be careful with this command.\r
+This doesn't send it to the recycle bin or anything, the file is GONE after\r
+this command is executed. Like all the other file I/O vc commands, this\r
+will ONLY work on files in the main directory VERGE is being run from)\r
+\r
+Example:\r
+  fdelete("EXAMPLE.TXT");\r
+\r
+---------------------------------------------\r
+void frename(string filename, string newname)\r
+---------------------------------------------\r
+Renames the specified file to the new name.\r
+\r
+Example:\r
+  frename("EXAMPLE.TXT", "TEST.TXT");\r
+\r
+----------------------------------------\r
+void fseekline(int line, int filehandle)\r
+----------------------------------------\r
+Moves the file pointer to the given line number in a pre-opened text file.\r
+\r
+Example:\r
+  file = fopen("EXAMPLE.TXT");\r
+  fseekline(3, file);\r
+  fgetline(my_string, file);\r
+  Message("Line #3 in EXAMPLE.TXT is: "+my_string, 200);\r
+  fclose(file);\r
+\r
+--------------------------------------\r
+void fseekpos(int pos, int filehandle)\r
+--------------------------------------\r
+Moves the file pointer to the given byte position in a pre-opened binary file.\r
+\r
+Example:\r
+  file = fopen("TEST.DAT");\r
+  fseekpos(20, file);\r
+  Message("Byte #20 in TEST.DAT is: "+str(fgetbyte(file)), 200);\r
+  fclose(file);\r
+\r
+----------------------------\r
+void fwclose(int filehandle)\r
+----------------------------\r
+Closes the given file that was open for writing. Be *sure* not to mix\r
+file handles that were opened for reading and those that were opened\r
+for writing.\r
+\r
+See also: fwopen()\r
+\r
+Example:\r
+  file = fwopen("EXAMPLE.TXT");\r
+  // ** use file here **\r
+  fwclose(file);\r
+\r
+------------------------\r
+int fwopen(string fname)\r
+------------------------\r
+Opens the specified filename for writing.\r
+\r
+See also: fwclose(), fwrite(), fwritestring()\r
+\r
+Example:\r
+  file = fwopen("EXAMPLE.TXT");\r
+  // ** use file here **\r
+  fwclose(file);\r
+\r
+------------------------------------------------\r
+void fwrite(int ptr, int length, int filehandle)\r
+------------------------------------------------\r
+Writes the data at the given data pointer to the specified file.\r
+\r
+Example:\r
+  file = fwopen("EXAMPLE.TXT");\r
+  buffer = malloc(screenx * screeny);\r
+  GrabRegion(0,0, screenx-1,screeny-1, buffer);\r
+  fwrite(buffer, screenx * screeny, file);\r
+  fwclose(file);\r
+  free(buffer);\r
+\r
+----------------------------------------------\r
+void fwritestring(string text, int filehandle)\r
+----------------------------------------------\r
+Writes the passed string to the specified file. The string is written in\r
+text mode format, with a CR/LF pair at the end.\r
+\r
+Example:\r
+  file = fwopen("EXAMPLE.TXT");\r
+  my_string = "VERGE 2";\r
+  fwritestring(my_string, file);\r
+  fwclose(file);\r
+\r
+--------------------------\r
+int GetPixel(int x, int y)\r
+--------------------------\r
+Returns the color of the specified pixel coordinate.\r
+\r
+See also: SetPixel();\r
+\r
+Example:\r
+  color = GetPixel(screenx/2, screeny/2);\r
+\r
+------------------------------------\r
+int GetTile(int x, int y, int layer)\r
+-----------------------------------\r
+Returns the value of the given map layer at the given coordinates. For\r
+layer, 0 through 5 are the first 6 possible map layers, a value of 6\r
+will always denote the obstruction field, and 7 denotes zone information.\r
+\r
+See also: SetTile()\r
+\r
+Example:\r
+  tile = GetTile(0, 0, 0);\r
+\r
+-------------------------\r
+void GotoXY(int x, int y)\r
+-------------------------\r
+Sets the current text output "cursor" to the given location. This is where\r
+calls to PrintString will be displayed at.\r
+\r
+See also: PrintString()\r
+\r
+Example:\r
+  GotoXY(screenx/2, screeny/2);\r
+  PrintString(0, "Hyuck.");\r
+\r
+-----------------------------------------------------------\r
+void GrabRegion(int x1, int y1, int x2, int y2, int buffer)\r
+-----------------------------------------------------------\r
+This routine captures a region of the screen and copies it into\r
+a bitmap buffer. The main trick with using this routine is that you are\r
+responsible for creating and destroying this buffer with the malloc/free\r
+commands, and to be sure that you allocate enough memory in your malloc call\r
+to contain the image. For instance, if you capture the region from (0,0) to\r
+(49,49), this is a 50x50 square, and you will need to allocate 2500 bytes.\r
+\r
+Example:\r
+  save_screen = malloc(screenx * screeny);\r
+  GrabRegion(0, 0, screenx-1, screeny-1, save_screen);\r
+  // ** use save_screen here **\r
+  free(save_screen);\r
+\r
+-------------------------------------------\r
+void HLine(int x, int y, int x2, int color)\r
+-------------------------------------------\r
+Draws a horizontal line using the specified coordinates in the given color.\r
+\r
+See also: VLine(), Line()\r
+\r
+Example:\r
+  HLine(0, screeny/2, screenx-1, 128);\r
+\r
+-----------------------------------------\r
+void HookKey(int scancode, system script)\r
+-----------------------------------------\r
+Binds an event to a specified keypress. This allows you to create menus and\r
+other types of key-based events easily.\r
+\r
+ex: HookKey(1, Menu);\r
+When Escape is pressed (key scancode 1), the function Menu() in system.vc\r
+will be executed.\r
+\r
+See also: HookTimer(), HookRetrace()\r
+\r
+Example:\r
+  HookKey(1, menu_script);\r
+\r
+-------------------------------\r
+void HookRetrace(system script)\r
+-------------------------------\r
+Given a non-zero event number, it will execute the given VergeC event (from the\r
+Map VC) each time a frame is rendered. Note that it will be called at the 'R'\r
+position in the Renderstring, so if there *is* no 'R' position, then it will\r
+never be executed. As in verge 1, HookRetrace is quite stable, and should be\r
+used instead of HookTimer whenever possible. You can pass zero to this event\r
+to turn off the HookRetrace.\r
+\r
+See also: HookTimer(), HookKey()\r
+\r
+Example:\r
+  HookRetrace(my_script); // hook script\r
+  HookRetrace(1);         // hook event\r
+\r
+-----------------------------\r
+void HookTimer(system script)\r
+-----------------------------\r
+Given a non-zero event number, it will execute the given VergeC event (from the\r
+Map VC) each timer tick (ie, 100 times per second). Note that, like verge 1,\r
+this is the more volatile of the Hook* family of functions, and HookRetrace\r
+should be used in place of HookTimer whenever possible. When using HookTimer,\r
+you should never call any rendering functions, and in general you should do as\r
+little as possible inside the hooked event as you can. As with HookRetrace,\r
+passing 0 to this function will turn off the HookTimer.\r
+\r
+See also: HookRetrace(), HookKey()\r
+\r
+Example:\r
+  HookTimer(my_script); // hook script\r
+  HookTimer(1);         // hook event\r
+\r
+---------------------\r
+int InitMosaicTable()\r
+---------------------\r
+If you wish to use the Mosaic() routine, you must call this function to\r
+generate a mosaic palette-matching table (store the value returned by this\r
+function and pass it to Mosaic each time you call it). We would precompute\r
+this table, however, it depends on the palette. The table calculations can\r
+take a while, it takes about 12 seconds on my P200. It is possible, of course,\r
+to precompute the table in VC and load it at runtime for people that want\r
+to use this feature and wish to avoid the long table computation time.\r
+\r
+See also: Mosaic()\r
+\r
+Example:\r
+  table = InitMosaicTable();\r
+\r
+--------------------------------------------------\r
+void Line(int x, int y, int x2, int y2, int color)\r
+--------------------------------------------------\r
+Draws an arbitary-angled line from any two sets of coordinates in the\r
+given color.\r
+\r
+See also: HLine(), VLine()\r
+\r
+Example:\r
+  Line(0,0, screenx-1,screeny-1, 128);\r
+\r
+-----------------------------\r
+int LoadFont(string filename)\r
+-----------------------------\r
+Loads the specified font file and returns the font slot which is used by\r
+PrintString.\r
+\r
+See also: GotoXY(), PrintString()\r
+\r
+Example:\r
+  my_font = LoadFont("MYFONT.FNT");\r
+\r
+----------------------------\r
+int LoadRaw(string filename)\r
+----------------------------\r
+Loads the specied file as raw data into an allocated buffer and returns\r
+a pointer to that buffer.\r
+\r
+Example:\r
+  raw = LoadRaw("SPEECH.SPC");\r
+  // ** use raw here **\r
+  free(raw);\r
+\r
+------------------------------\r
+int LoadImage(string filename)\r
+------------------------------\r
+Loads the specified image, allocating enough memory for it, and returns\r
+a pointer to the image. If you no longer need the image, you should\r
+free() it. The image can be any of the supported V2 image types, which\r
+are currently PCX, BMP, and GIF.\r
+\r
+Example:\r
+  im = LoadImage("CHEESE.GIF");\r
+  // ** use im here **\r
+  free(im);\r
+\r
+---------------------\r
+void Log(string text)\r
+---------------------\r
+Outputs a message to VERGE.LOG, assuming verge.log is enabled by the user.\r
+This can be useful for debugging.\r
+\r
+Example:\r
+  Log("VERGE 2");\r
+\r
+----------------------\r
+int malloc(int amount)\r
+----------------------\r
+Allocates the given amount of memory and returns a pointer to the memory\r
+space allocated.\r
+\r
+Example:\r
+  buffer = malloc(100);\r
+  free(buffer);\r
+\r
+------------------------\r
+void Map(string mapname)\r
+------------------------\r
+Loads the specified MAP file as the current map. Upon encountering this\r
+command, VC execution is immediately terminated completely and resumed at\r
+the new map's Autoexec event.\r
+\r
+Example:\r
+  Map("TEST.MAP");\r
+\r
+------------------------------------------\r
+void Message(string message, int duration)\r
+------------------------------------------\r
+Issues the specified system message, lasting the given duration in hundreths\r
+of a second. This message is displayed in the upper left corner of the screen\r
+for the given duration, and noted in the verge.log file.\r
+\r
+Example:\r
+  Message("VERGE 2", 200);\r
+\r
+-------------------------------------------------------------------------\r
+void Mosaic(int xfocus, int yfocus, int tablepointer, int x1, y1, x2, y2)\r
+-------------------------------------------------------------------------\r
+"Mosaics" the screen so far; The best way to describe it is as the mode7\r
+effect used in FF2 and such to make the screen "blur out" during screen\r
+transitions. xfocus and yfocus control the "granularity" of this blurring,\r
+tablepointer must be the value returned by InitMosaicTable or a pointer\r
+to a precomputed table loaded in memory. The x1,y1,x2,y2 values specify\r
+the section of the screen to apply the mosaic effect to.\r
+\r
+So, to apply the mosaic effect with a 3-to-1 pixel ratio to the whole screen,\r
+you'd use Mosaic(3, 3, MyMosaicTable, 0, 0, ScreenX, ScreenY);\r
+\r
+See also: InitMosaicTable()\r
+\r
+Example:\r
+  table = InitMosaicTable();\r
+  Mosaic(4,4, table, 0,0, screenx-1, screeny-1);\r
+\r
+-------------------------------------------------------------\r
+void PaletteMorph(int r, int g, int b, int mix, int lighting)\r
+-------------------------------------------------------------\r
+This command alters the entire game palette, which will effect the entire\r
+screen. It changes the 'tint' of the screen; the RGB values are the color\r
+you want to tint the screen with, and range from 0 to 63. So, 63,0,0 would\r
+be red, 0,63,0 is green, and 0,0,63 is blue. 0,0,0 is black and 63,63,63\r
+is white. The mix value controls how 'thickly' the screen is tinted\r
+with this color. 0 would mean no mix whatsoever, while 100 would change\r
+the screen to be the color you specified solidly. The lighting value simply\r
+controls how light or dark the screen will be as a whole; 63 is normal\r
+brightness, 0 is black.\r
+\r
+Example:\r
+  PaletteMorph(0,0,0,0, 63);\r
+\r
+---------------------------------\r
+void PartyMove(string movescript)\r
+---------------------------------\r
+This command will have the party follow the specified movement script; player\r
+control will resume after the script is completed.\r
+\r
+Example:\r
+  PartyMove("U1R1D1L1");\r
+\r
+-----------------------------\r
+void PlayFLI(string filename)\r
+-----------------------------\r
+Plays the specified FLI or FLC file. Does not loop. The timing in the V2\r
+playback may be slightly off, but it should be so slight as to be completely\r
+unnoticable in the vast majority of cases. Also, it would be a good idea to\r
+set the video mode beforehand to something appropriate to fit the resolution of\r
+the FLI.\r
+\r
+SeeAlso: SetResolution()\r
+\r
+Example:\r
+  PlayFLI("INTRO.FLC");\r
+\r
+-------------------------------\r
+void PlayMusic(string filename)\r
+-------------------------------\r
+Plays the specified music file. In this version of V2, only MODs, MTMs, S3Ms,\r
+and XMs are supported.\r
+\r
+See also: StopMusic();\r
+\r
+Example:\r
+  PlayMusic("AURORA.MOD");\r
+\r
+--------------------------------------------------\r
+void PlaySound(int soundslot, int volume, int pan)\r
+--------------------------------------------------\r
+Plays the specified sound effect at the given slot index; volume is a value\r
+from 0 to 64 indicating the volume the sound file will be played at, and pan\r
+is a value from 0 to 255; 0 is all the way left, and 255 is all the way right,\r
+128 is in the center.\r
+\r
+See also: CacheSound(), FreeAllSounds()\r
+\r
+Example:\r
+  shriek = CacheSound("SHRIEK.WAV");\r
+  PlaySound(shriek, 64, 128);\r
+\r
+--------------------------\r
+int pow(int base, int exp)\r
+--------------------------\r
+Raises base to the exp power and returns that value.\r
+\r
+Example:\r
+  result = pow(16, 3); // 4096\r
+\r
+----------------------\r
+void ProcessEntities()\r
+----------------------\r
+Processes one tick worth of entity movement. If you call this 100 times a\r
+second it will keep the game moving as normal. For example, the following code\r
+could be used to draw something on top of the normal map view:\r
+\r
+Example:\r
+  while (!done)\r
+  {\r
+    while (timer)\r
+    {\r
+      timer--;\r
+      ProcessEntities();\r
+    }\r
+    Render();\r
+    // Put additional things to be drawn per frame here\r
+    ShowPage();\r
+  }\r
+\r
+---------------------------------------\r
+void PrintString(int font, string text)\r
+---------------------------------------\r
+Displays the given string in the specified font index, at the location\r
+last given by GotoXY.\r
+\r
+See also: LoadFont(), GotoXY()\r
+\r
+Example:\r
+  PrintString(0, "VERGE 2");\r
+\r
+---------------------\r
+int Random(int range)\r
+---------------------\r
+Returns a random number between 0 and the range given.\r
+\r
+Example:\r
+  if (Random(100) < 50)\r
+    PrintString(0, "Heads!");\r
+  else PrintString(0, "Tails!");\r
+\r
+----------------\r
+void ReadMouse()\r
+----------------\r
+Updates the mouse status variables mx, my, and mb.\r
+\r
+See also: SetMousePos()\r
+\r
+Example:\r
+  ReadMouse();\r
+\r
+------------------------------\r
+void ReadVars(int filepointer)\r
+------------------------------\r
+Reads all the global variables that have been written to a file by WriteVars().\r
+You're responsible for opening and closing the file for reading, mainly used\r
+for savegames.\r
+\r
+See also: WriteVars(), fopen(), fclose()\r
+\r
+Example:\r
+  file = fopen("SAVE.DAT");\r
+  ReadVars(file);\r
+  fclose(file);\r
+\r
+----------------------------------------------\r
+void Rect(int x, int y, int x2, int y2, int c)\r
+----------------------------------------------\r
+Draws an outlined rectangle of the given coordinate set in the specified\r
+color.\r
+\r
+See also: RectFill()\r
+\r
+Example:\r
+  Rect(0, 0, screenx-1, screeny-1, 128);\r
+\r
+--------------------------------------------------\r
+void RectFill(int x, int y, int x2, int y2, int c)\r
+--------------------------------------------------\r
+Draws a filled rectangle of the given coordinate set in the specified\r
+color.\r
+\r
+See also: Rect()\r
+\r
+Example:\r
+  RectFill(0, 0, screenx-1, screeny-1, 128);\r
+\r
+-------------\r
+void Render()\r
+-------------\r
+Performs a render, per the render string, but does not copy the screen\r
+buffer to the visible screen, allowing you to draw additional items on top\r
+of the game screen.\r
+\r
+See also: ShowPage()\r
+\r
+Example:\r
+  Render();\r
+\r
+----------------------------\r
+void RestoreRenderSettings()\r
+----------------------------\r
+Restores the default clipping window for the given video mode, and restores\r
+the render destination to the video buffer.\r
+\r
+See also: SetClipRect(), SetRenderDest()\r
+\r
+Example:\r
+  RestoreRenderSettings();\r
+\r
+----------------------------------------------------------------------------\r
+void ScaleSprite(int x, int y, int iw, int ih, int dw, int dh, int imageptr)\r
+----------------------------------------------------------------------------\r
+Draws a scaled image. A bit more complex than the other blitters to use.\r
+The x,y values give the upper-left corner of where the blit will start.\r
+iw,ih are the width and height of the *source* image. dw, dh are the width\r
+and height that the image should appear on screen. (ie, the end result\r
+bounding box of the image would be, x, y, x+dw, y+dh) Imageptr is, as with\r
+the other blit routines, a pointer to the image graphic.\r
+\r
+See also: TScaleSprite()\r
+\r
+Example:\r
+  im = LoadImage("VECNA.PCX");\r
+  ScaleSprite(0,0, image_width,image_height, image_width*2,image_height*2, im);\r
+  free(im);\r
+\r
+----------------------\r
+void SetClip(int clip)\r
+----------------------\r
+Determines whether clipping versions of general VC graphics routines are\r
+used. Defaults to 1; You will never need to turn this off, turn it offers\r
+no functional difference, except faster blitting routines, however, great care\r
+must be used when turning it off that no part of any blit or graphics call\r
+draws off screen boundaries.\r
+\r
+Example:\r
+  SetClip(1);\r
+\r
+------------------------------------------------\r
+void SetClipRect(int x1, int y1, int x2, int y2)\r
+------------------------------------------------\r
+Sets the rectangle that image drawing will be clipped to.\r
+\r
+See also: RestoreRenderSettings()\r
+\r
+Example:\r
+  im = LoadImage("PATTERN.PCX");\r
+  SetClipRect(screenx/4, screeny/4, screenx-(screenx/4), screeny-(screeny/4));\r
+  WrapBlit(0, 0, image_width, image_height, im);\r
+  RestoreRenderSettings();\r
+  free(im):\r
+\r
+-----------------------------------------------------\r
+void SetRenderDest(int width, int height, int buffer)\r
+-----------------------------------------------------\r
+This sets the video buffer that all VC video functions will draw into.\r
+\r
+See also: RestoreRenderSettings()\r
+\r
+Example:\r
+  buffer = malloc(32 * 32);\r
+  SetRenderDest(32, 32, buffer);\r
+  Line(0,0, 15,15, 128);\r
+  Line(0,15, 15,0, 128);\r
+  Rect(0,0, 15,15, 128);\r
+  RestoreRenderSettings();\r
+  CopySprite(0, 0, 32, 32, buffer);\r
+  free(buffer);\r
+\r
+--------------------------\r
+void SetLucent(int lucent)\r
+--------------------------\r
+Determines whether translucent versions of general VC graphics routines are\r
+used. Defaults to 0.\r
+\r
+Example:\r
+  SetLucent(1);\r
+\r
+------------------------------\r
+void SetMousePos(int x, int y)\r
+------------------------------\r
+Sets the current mouse position to the given x and y coordinates. Does no\r
+checking to make sure the coordinates are valid, so check that yourself, they\r
+should between 0 and screenx and 0 and screeny, respectively.\r
+\r
+See also: ReadMouse()\r
+\r
+Example:\r
+  SetMousePos(screenx/2, screeny/2);\r
+\r
+----------------------------------\r
+void SetPixel(int x, int y, int c)\r
+----------------------------------\r
+Sets the specified pixel coordinate to the given color.\r
+\r
+See also: GetPixel();\r
+\r
+Example:\r
+  SetPixel(screenx/2, screeny/2, 128);\r
+\r
+-------------------------------\r
+void SetPlayer(int entityindex)\r
+-------------------------------\r
+Sets the specified entity index as the active player.\r
+\r
+See also: EntitySpawn()\r
+\r
+Example:\r
+  ent = EntitySpawn(0, 1, "VECNA.CHR");\r
+  SetPlayer(ent);\r
+\r
+-------------------------------------\r
+int SetResolution(int xres, int yres)\r
+-------------------------------------\r
+Sets the video mode to the specified resolution. Returns 1 if successful, 0\r
+if the mode set failed.\r
+\r
+Common video modes:\r
+-------------------\r
+                     DOS                         Windows\r
+                     ---                         -------\r
+                   320x200                       320x200\r
+                   320x240                       320x240\r
+                   360x240                       512x384\r
+                   256x256                       640x480\r
+                   640x480                       800x600\r
+                                                 1024x768\r
+\r
+Example:\r
+  SetResolution(320, 240);\r
+\r
+-------------------------------\r
+void SetRString(string rstring)\r
+-------------------------------\r
+Updates the RenderString to the specified string.\r
+\r
+Example:\r
+  SetRString("1E2");\r
+\r
+------------------------------------------------\r
+void SetTile(int x, int y, int layer, int value)\r
+------------------------------------------------\r
+Sets a new value to the given map layer at the given coordinates. For\r
+layer, 0 through 5 are the first 6 possible map layers, a value of 6\r
+will always denote the obstruction field, and 7 denotes zone information.\r
+\r
+See also: GetTile()\r
+\r
+Example:\r
+  SetTile(0, 0, 0, 2);\r
+\r
+---------------\r
+void ShowPage()\r
+---------------\r
+Copys the screen buffer to the visible screen.\r
+\r
+See also: Render(), CopySprite(), TCopySprite()\r
+\r
+Example:\r
+  ShowPage();\r
+\r
+--------------------------------------------------------------------------\r
+void Silhouette(int x, int y, int width, int height, int color, int image)\r
+--------------------------------------------------------------------------\r
+Renders a silhouette of the specified image.  The silhouette is generated\r
+by looking for all non-zero pixels in the image and replacing them with\r
+the specified color.\r
+\r
+Example:\r
+  im = LoadImage("GOAT.PCX");\r
+  Silhouette(0, 0, image_width, image_height, 128, im);\r
+  free(im);\r
+\r
+-------------------\r
+int sin(int degree)\r
+-------------------\r
+Returns the sine of the given degree of measure (0-360) in 16.16 fixed\r
+point.\r
+\r
+See also: cos(), tan()\r
+\r
+Example:\r
+  result = sin(180);\r
+\r
+----------------\r
+void StopMusic()\r
+----------------\r
+Stops currently playing music.\r
+\r
+See also: PlayMusic()\r
+\r
+Example:\r
+  StopMusic();\r
+\r
+------------------------------------\r
+int strcmp(string str1, string str2)\r
+------------------------------------\r
+Compares the two passed strings. Returns 0 if they're identical, or\r
+a nonzero number porportional to the difference between the strings.\r
+\r
+Example:\r
+  string_a = "alpha";\r
+  string_b = "zeta";\r
+  result = strcmp(string_a, string_b);\r
+  if (!result)\r
+    PrintString(0, "Strings are equal");\r
+  else if (result < 0)\r
+    PrintString(0, string_a+" comes before "+string_b);\r
+  else\r
+    PrintString(0, string_b+" comes before "+string_a);\r
+\r
+----------------------\r
+int strlen(string str)\r
+----------------------\r
+Returns the length of the passed string.\r
+\r
+Example:\r
+  my_string = "VERGE 2";\r
+  length = strlen(my_string);\r
+\r
+-------------------\r
+int tan(int degree)\r
+-------------------\r
+Returns the tangent of the given degree of measure (0-360) in 16.16 fixed\r
+point.\r
+\r
+See also: sin(), cos()\r
+\r
+Example:\r
+  result = tan(270);\r
+\r
+----------------------------------------------------------------\r
+void TCopySprite(int x, int y, int width, int height, int image)\r
+----------------------------------------------------------------\r
+Blits the image pointed to by image with the given dimensions at the\r
+given location on screen. Transparency and clipping are performed.\r
+\r
+See also: CopySprite\r
+\r
+Example:\r
+  im = LoadImage("SLIME.PCX");\r
+  TCopySprite(0, 0, image_width, image_height, im);\r
+  free(im);\r
+\r
+-----------------------------------------------------------------------------\r
+void TScaleSprite(int x, int y, int iw, int ih, int dw, int dh, int imageptr)\r
+-----------------------------------------------------------------------------\r
+Draws a scaled image. A bit more complex than the other blitters to use.\r
+The x,y values give the upper-left corner of where the blit will start.\r
+iw,ih are the width and height of the *source* image. dw, dh are the width\r
+and height that the image should appear on screen. (ie, the end result\r
+bounding box of the image would be, x, y, x+dw, y+dh) Imageptr is, as with\r
+the other blit routines, a pointer to the image graphic. This routines draws\r
+the image with transparency, unlike ScaleSprite().\r
+\r
+See also: ScaleSprite()\r
+\r
+Example:\r
+  im = LoadImage("SLIME.PCX");\r
+  TScaleSprite(0,0, image_width,image_height, image_width*2,image_height*2, im);\r
+  free(im);\r
+\r
+--------------------------------------------------------------------\r
+void TWrapBlit(int xofs, int yofs, int width, int height, int image)\r
+--------------------------------------------------------------------\r
+Blits an image of any size repeatedly so that it fills the entire screen;\r
+This version is color-0 transparent unlike the normal WrapBlit version.\r
+\r
+See also: WrapBlit();\r
+\r
+Example:\r
+  im = LoadImage("PATTERN.PCX");\r
+  TWrapBlit(0, 0, image_width, image_height, im);\r
+  free(im);\r
+\r
+-------------------------\r
+void UnPress(int control)\r
+-------------------------\r
+This will read a control currently being pressed as not pressed until it\r
+is released and then pressed again. The values of control are:\r
+  0: All buttons, not directionals\r
+  1: b1                              5: up\r
+  2: b2                              6: down\r
+  3: b3                              7: left\r
+  4: b4                              8: right\r
+\r
+Example:\r
+  UnPress(0);\r
+\r
+---------------------\r
+void UpdateControls()\r
+---------------------\r
+Updates the control variables up, down, left, right, b1, b2, b3, and b4.\r
+\r
+Example:\r
+  UpdateControls();\r
+\r
+-------------------------------------------\r
+void VLine(int x, int y, int y2, int color)\r
+-------------------------------------------\r
+Draws a vertical line from the specified coordinates in the given color.\r
+\r
+See also: HLine(), Line()\r
+\r
+Example:\r
+  VLine(screenx/2, 0, screeny-1, 128);\r
+\r
+-------------------------------------------------------------------\r
+void WrapBlit(int xofs, int yofs, int width, int height, int image)\r
+-------------------------------------------------------------------\r
+Blits an image of any size repeatedly so that it fills the entire screen;\r
+\r
+See also: TWrapBlit();\r
+\r
+Example:\r
+  im = LoadImage("PATTERN.PCX");\r
+  WrapBlit(0, 0, image_width, image_height, im);\r
+  free(im);\r
+\r
+-------------------------------\r
+void WriteVars(int filepointer)\r
+-------------------------------\r
+Writes all global variables (ints and strings) to the specified file. You\r
+must take care of opening and closing the file for writing. Mostly used\r
+for savegames.\r
+\r
+See also: ReadVars(), fwopen(), fwclose()\r
+\r
+Example:\r
+  file = fwopen("SAVE.DAT");\r
+  WriteVars(file);\r
+  fwclose(file);\r
+\r
+=============================================================================\r
+\r
+III. Builtin Variables\r
+\r
+b1, b2, b3, b4\r
+--------------\r
+These represent four primary control buttons. They are updated by the\r
+UpdateControls() function. [read-only]\r
+\r
+Example:\r
+  UpdateControls();\r
+  if (b1) Message("Button 1!", 100);\r
+  if (b2) Message("Button 2!", 100);\r
+  if (b3) Message("Button 3!", 100);\r
+  if (b4) Message("Button 4!", 100);\r
+\r
+cameratracking, tracker\r
+-----------------------\r
+If cameratracking is 0, the camera is free to be altered by the xwin/ywin\r
+variables. If cameratracking is 1, the camera will always follow the player.\r
+If cameratracking is 2, the camera will always follow the entity specified in\r
+tracker. [read/write]\r
+\r
+Example:\r
+  ent = EntitySpawn(0, 1, "VECNA.CHR");\r
+  cameratracking = 2;\r
+  tracker = ent;\r
+  EntityMove("R2D2L2U2");\r
+\r
+entity.x, entity.y\r
+------------------\r
+x/y coordinates of the specified entity in world-coordinates (pixel-accurate).\r
+[read/write]\r
+\r
+Example:\r
+  Log("Player X="+str(entity.x[player])+", Y="+str(entity.y[player]));\r
+\r
+entity.tx, entity.ty\r
+--------------------\r
+x/y coordinates of the specified entity in tile coordinate. [read/write]\r
+\r
+Example:\r
+  Log("Player TX="+str(entity.tx[player])+", TY="+str(entity.ty[player]));\r
+\r
+entity.facing, entity.moving, entity.specframe, entity.speed, entity.movecode\r
+-----------------------------------------------------------------------------\r
+Various variables effecting the specified stats of the given entity.\r
+[read/write]\r
+\r
+Example:\r
+  Log("Player info");\r
+  Log("   Facing: "+str(entity.facing[player]));\r
+  Log("   Moving: "+str(entity.moving[player]));\r
+  Log("SpecFrame: "+str(entity.specframe[player]));\r
+  Log("    Speed: "+str(entity.speed[player]));\r
+  Log(" MoveCode: "+str(entity.movecode[player]));\r
+\r
+entsonscreen\r
+------------\r
+Array of entity indexes which are currently onscreen.\r
+\r
+Example:\r
+  // log all tile coordinates of entities onscreen\r
+  for (i=0; i<numentsonscreen; i++)\r
+    Log("X="+str(entity.tx[entsonscreen[i]])+", Y="+str(entity.ty[entsonscreen[i]]));\r
+\r
+key\r
+---\r
+Returns or set the on/off flag of the specified key scancode.\r
+\r
+Example:\r
+  if (key[1])\r
+    Message("ESC is pressed", 200);\r
+  else Message("ESC is not pressed", 200);\r
+\r
+lastent\r
+-------\r
+The last entity that called a VC event, either via movement script or\r
+activation.\r
+\r
+Example:\r
+  Message("Last entity: "+str(lastent), 200);\r
+  \r
+Note: Untested currently.\r
+\r
+mx, my, mb\r
+----------\r
+mx and my are the x and y coordinates of the mouse pointer. mb returns the\r
+mouse button status.\r
+\r
+Example:\r
+  Message("Mouse info: X="+str(mx)+", Y="+str(my)+", B="+str(mb), 200);\r
+\r
+numentsonscreen\r
+---------------\r
+Number of entities currently on screen, number of values in entsonscreen array\r
+that are valid.\r
+\r
+Example:\r
+  Message("Number of entities onscreen: "+str(numentsonscreen), 200);\r
+\r
+pal\r
+---\r
+Active palette array (256 RGB entries; 768 bytes). Changes made will only\r
+be enforced when PaletteMorph() is next called.\r
+\r
+Example:\r
+  // greyscale the active palette\r
+  for (i=0; i<256; i++)\r
+  {\r
+    r=pal[i*3+0];\r
+    g=pal[i*3+1];\r
+    b=pal[i*3+2];\r
+    average=(r+g+b)/3;\r
+    pal[i*3+0]=average;\r
+    pal[i*3+1]=average;\r
+    pal[i*3+2]=average;\r
+  }\r
+  PaletteMorph(0,0,0,0, 63);\r
+\r
+player\r
+------\r
+Returns which entity index number is currently the active player. [read-only]\r
+\r
+Example:\r
+  ent = EntitySpawn(0, 1, "VECNA.CHR");\r
+  SetPlayer(ent);\r
+  Message("Active entity index is #"+str(player));\r
+\r
+screen\r
+------\r
+Single-dimensional array access to the video virtual buffer. [read/write]\r
+\r
+Example:\r
+  SetResolution(320, 240);\r
+  screen[(120*320)+160]=128;\r
+\r
+screenx, screeny\r
+----------------\r
+Return the x and y dimensions of the current video mode. [read-only]\r
+\r
+Example:\r
+  Message("Current resolution is "+str(screenx)+"x"+str(screeny));\r
+\r
+timer\r
+-----\r
+This variable is incremented 100 times per second. It can be used to for\r
+timing purposes. [read/write]\r
+\r
+Example:\r
+  while (timer)\r
+  {\r
+    timer--;\r
+    ProcessEntities();\r
+  }\r
+\r
+up, down, left, right\r
+---------------------\r
+These represent the four directional controls. Also updated by\r
+UpdateControls(). [read-only]\r
+\r
+Example:\r
+  UpdateControls();\r
+  if (up)    Message("UP!", 100);\r
+  if (down)  Message("DOWN!", 100);\r
+  if (left)  Message("LEFT!", 100);\r
+  if (right) Message("RIGHT!", 100);\r
+\r
+vctrace\r
+-------\r
+This is a 0/1, off/on variable that defaults to 0; when it is turned on,\r
+VERGE.LOG will contain dumps tracing the code flow of system.vc function\r
+calls. However, this log can get very big very quickly, so it's recommended\r
+that you turn it on to track and debug a particular section of code and then\r
+turn it off afterwards.\r
+\r
+Example:\r
+  vctrace = 1;\r
+\r
+vsp\r
+---\r
+Array of tile image data. Sequential ordering of 256 byte (16*16) blocks.\r
+\r
+Example:\r
+  TCopySprite(screenx/2,screeny/2, 16,16, vsp+(slot*256));\r
+\r
+xwin, ywin\r
+----------\r
+These control the camera, if cameratracking is 0. Otherwise, the camera will\r
+follow the player. [read/write]\r
+\r
+Example:\r
+  xwin = 100;\r
+  ywin = 200;\r