code:
File format for the .MZX world file (w/o password protection)
-----------------------------------

This file format is for version 2.00. No attempt at compatibility with
version 1.0? is made within the format. Megazeux version 2.00 will,
however, recognize and load version 1.0? .MZX files.

Byte(s)		Is

00-24			Title of game (name of first board) w/terminating null. Padded
				with junk.
25				Protection method (0=none, 1=no-save/test, 2=no-edit, 3=total)
				If not a 0, followed by a fifteen character password
				(encrypted) The rest of the file, after the "MZ2", is entirely
				encrypted.
26-28			The letters "MZ2". If the last letter is an X, this is a ver
				1.0? file. If the last letter is anything else, it is a more
				recent, incompatible version file. 3-9 will represent versions
				3.00 to 9.00, and A-Z for anything after that.
29-3612		The character set (14 bytes per character, 256 characters)
				Each character is 14 bytes, from the top row to the bottom
				row, one byte per pixel row.
3613-4067	IdChars array (455 bytes) This is the info in Global Chars,
				as well as anything that can be edited with CHANGE CHAR ID.
4068-4157	The SIX status counters, IE those counters shown on the
				status screen. Each is 15 chars long, including a terminating
				null. Padded with junk.
4158			Color of edge border during play.
4159			Starting board number.
4160			Board for end game. (255 for no board)
4161			Board for death. (255 to restart screen, 254 for same pos)
4162-4163	X position for end game.
4164-4165	Y position for end game.
4166			1 if game over sfx are played.
4167-4168	X position for death.
4169-4170	Y position for death.
4171-4172	Starting number of lives. (word)
4173-4174   Limit to lives. (word)
4175-4176	Starting amount of health. (word)
4177-4178	Limit to health. (word)
4179			1 if enemies can hurt each other, 0 if not.
4180			1 if all messages and projectiles are cleared between screens.
4181			1 if the game is only playable via a robot SWAP WORLD command.
4182-4229	Palette- colors 0-15, R G B per. RGB are from 0 to 63.
4230-4233	Position within file of global robot.
4234			Code- 0 means SFXs follow. 1-150 means use normal SFX and this
				number is equal to the number of boards.

				SFXs- 50 of them (0-49) Each is any length up to 68, preceded by
				a length byte (1-69) of the string w/null termination. Normal
				SFX format. The very first two bytes is a WORD of how long
				this entire section is, not including the first WORD. After
				this section is a number for the number of boards.

4235-????	Per board- 25 char title, including null terminator. Padded
				with junk.
????-????	Per board- Length of board in bytes (dword) and position of
				board within file. (byte number, dword)

At location of board- The board itself. (see .MZB files, exactly the same)
At location of global robot- The robot itself. (See .MZB files)

A board of 0 length is a deleted board and has junk at it's "position
within the file".

Format for a .MZB board file
----------------------------

This file format is for version 2.00. No attempt at compatibility with
version 1.0? is made within the format. Megazeux version 2.00 will,
however, recognize and load version 1.0? .MZB files.

Note that INTERNAL storage of boards (other than the current board) is
very similar except there the four id bytes at the start are not present
and the board name is not repeated at the end.

Bytes 0-3:	An 0FFh, followed by the string "MB2" (not present in .MZX and
				.SAV files)
Byte 4:     0-4 for overall sizing of board- 60x166,80x125,100x100,200x50,
				or 400x25.

Then a byte code- if it is 0, it signifies that an overlay is present. It
is followed by the overlay mode as a byte (1=normal, 2=static, 3=transparent)
and the overlay, RLE2 encoded, and the overlay colors, RLE2 encoded. Blank
spots in the overlay are spaces (32) of any color. The overlay is the same
size of the board. This is followed as normal by the level ids, etc.

If the byte is NOT 0, it is the first encoded byte of the level ids, as
seen below.

Next-  Level ids, RLE2 encoded.
Then-  Level colors, RLE2 encoded.
Then-  Level params, RLE2 encoded.
Then-  Ids under stuff, RLE2 encoded.
Then-  Colors of ids under stuff, RLE2 encoded.
Last-  Params of ids under stuff, RLE2 encoded.

Level id/color/param is a number representing an object, a number for it's
color, (bk and fg) and a number representing it's stats. (IE robot id, or
enemy stats, or custom chars, or passage destination, etc) These are all
bytes. The "under stuff" is for things beneath other things, like floors and
carpets. All six sets are RLE2 encoded, a simple compression method. The
method works as follows- The first word is the x size (of the board) and the
second word is the y size. Then the actual data follows- Read a byte. If the
MSB (+128) is NOT set, then it is that byte. Otherwise, reset the MSB to get
the number of times to repeat the next byte. This is called a run. Single
bytes of values over 127 are represented as a run of 1. Runs can wrap around
lines. The board is over when X * Y bytes have been recovered.

After board design-

00-12    	Name of default MOD file, w/extension and null terminator.
				Padded with junk.
13				X position of upper left corner of the viewport.
14				Y position of upper left corner of the viewport.
15				X size of the viewport.
16				Y size of the viewport.
17				1 if you can shoot here, 0 otherwise.
18				1 if you can bomb here, 0 otherwise.
19				1 if fire burns through brown things, 0 otherwise.
20				1 if fire burns through spaces, 0 otherwise.
21				1 if fire burns through fakes, 0 otherwise.
22				1 if fire burns through trees, 0 otherwise.
23          Code for what an explosion leaves- 0 for nothing, 1 for ash,
				2 for fire.
24				1 if you can't save here, 2 if you can only save on a sensor,
				0 for normal saving.
25				0 if forest becomes empty, 1 if forest becomes floor.
26				1 if you collect bombs normally, 0 if they automatically light.
27          1 if fire burns forever, 0 otherwise.
28-31			Board numbers for boards to the N S E and W. 255 for no board.
32				1 if you restart the screen when zapped, 0 otherwise.
33-34			Time limit. (word) Current time is stored as a counter (TIME)
35				The last alphabetic key that was pressed. (A-Z or 0-9)
36-37			Numeric form of the last input. (word)
38				Size in characters of the last input.
39-119		81 char string (including null terminator and junk padding) of
				the last string inputted.
120			Last direction the player moved. (0=None, 1=N, 2=S, 3=E, 4=W)
				Upper nybble (*16) is the direction faced. (0-3=NSEW)
121-201		81 char string (including null terminator and junk padding) of
				current message at the bottom of the screen.
202			Number of cycles until the message at the bottom of the screen
				disappears.
203			Lazer wall timer, from 0 to 7. (increases once per cycle and
				loops from 7 to 0)
204			Row for the message row.
205			Column for the message row, 255 for centered.
206-207		X scroll of the screen, signed word. (From SCROLL VIEW)
208-209		Y scroll of the screen, signed word. (From SCROLL VIEW)
210-211		Locked X position for the screen. Used for the upper left corner.
				65535 for normal scrolling. Not affected by SCROLL VIEW.
212-213		Locked Y position for the screen.
214			1 if the player is locked in the ns direction.
215			1 if the player is locked in the ew direction.
216			1 if the player is locked from attacking.
217			Current MOD volume
218			Current MOD volume change amount
219			Current MOD volume target
220			Number of robots.

Per robot- (these robots start counting at ID #1. ID #0 is reserved internal
	use.)

0-1         (unsigned word) Length of robot program
2-3			Junk.
4-18			15 character robot name, including null terminator. Padded with
				junk.
19				Robot character.
20-21			(unsigned word) Location within program of current line
22				(unsigned byte) Location within current line, IE countdown
				for WAIT and GO commands.
23				(unsigned byte) Robot cycle number.
24				(unsigned byte) Robot cycle count. Reset to 0 after robot runs
				a program section, then each cycle counts up 1. When it reaches
				the Robot cycle number, program continues and this is again
				reset to 0.
25				Bullet type code- 0 player, 1 neutral, 2 enemy.
26				Set to one if robot is locked from recieving messages.
27				Set to one for a lava walking robot.
28				Current direction of walk. (1 North 2 South 3 East 4 West)
29				Last direction the robot was touched. (1-4)
30				Last direction the robot was shot. (1-4)
31-32			Robot's x position
33-34			Robot's y position
35				Reserved for internal use (Value of 0, 1, or 2)
36				Future expansion (0)
37				Future expansion (0)
38				Set to 1 if actually used onscreen, 0 if this robot is
				irrevelant. (even irrevelant robots store a program though)
39-40			Loop count for the robot's current loop. Not reset after the
				loop.

This is now followed by the robot's program according to it's length.

Next-
0				Number of scrolls (counting from id #1)

Per scroll-
0-1			(unsigned word) Number of lines in the scroll
2-3			Junk.
4-5			(unsigned word) Length in chars of the scroll.
6				Set to 1 if actually used onscreen, 0 if this one is irrevelant

This is now followed by the scroll's text. Signs count as scrolls.

Next-
0				Number of sensors (counting from id #1)

Per sensor-
0-14			15 char name of sensor, including null terminator. Padded with
				junk.
15				Sensor char.
16-30			15 char name of robot to send messages to, including null
				terminator. Padded with junk.
31				Set to 1 if actually used onscreen, 0 if this one is irrevelant

Finally, the board name (25 chars including null and junk padding) is at the
end of the board ONLY IN A .MZB FILE. Within a .MZX or .SAV file, this is not
present.

Format for a .SAV saved game file (Megazeux)
---------------------------------

This file format is for version 2.00. No attempt at compatibility with
version 1.0? is made within the format. Megazeux version 2.00 will NOT
recognize or load version 1.0? .SAV files.

00-05			The letters "MZSV2" and a null terminator.
06				Current board number.
07-3590		The character set (14 bytes per character, 256 characters)
				Each character is 14 bytes, from the top row to the bottom
				row, one byte per pixel row.
3591-4045	IdChars array (455 bytes) This is the info in Global Chars,
				as well as anything that can be edited with CHANGE CHAR ID.
4046-4105	The SIX status counters, IE those counters shown on the
				status screen. Each is 15 chars long, including a terminating
				null. Padded with junk.
4106-4121   Current keys held. Each byte is either 0-15 for a key or 127
				for no key.
4122-4125	(dword) Current score.
4126			Number of cycles remaining of blindness.
4127			Number of cycles remaining of firewalking.
4128			Number of cycles remaining of frozen time.
4129			Number of cycles remaining of slowed time.
4130			Number of cycles remaining of wind.
4131-4146	X positions of saved player positions. (SAVE PLAYER POSITION cmd)
4147-4162	Y positions of saved player positions. (one word each)
4163-4170	Board numbers (0-149) of saved player positions.
4171			Saved color of the player for when an energizer is active.
4172			Id under player's bomb/sensor
4173			Color under player's bomb/sensor
4174			Param under player's bomb/sensor
4175			1 if message edges are enabled
4176			Base color for scrolls.
4177			Corner color for scrolls.
4178			Pointer color for scrolls.
4179			Title color for scrolls.
4180			Arrow color for scrolls.
4181			Color of edge border during play.
4182			Starting board number.
4183			Board for end game. (255=none)
4184			Board for death. (255=restart, 254=same pos)
4185-86		X position for end game.
4187-88		Y position for end game.
4189			If sound fx play on game over.
4190-91		X position for death.
4192-93		Y position for death.
4194-95		Starting number of lives. (word)
4196-97 	  	Limit to lives. (word)
4198-99		Starting amount of health. (word)
4200-01		Limit to health. (word)
4202			1 if enemies can hurt each other, 0 if not.
4203			1 if all messages and projectiles are cleared between screens.
4204			1 if the game is only playable via a robot SWAP WORLD command.
4205-68		Palette- colors 0-15, R G B. Each is 0-63.
4269-84		Current intensity palette, colors 0-15, each 0 to 100%.
4285			Current faded bit- 0 if faded in, 1 if faded out.
4286-87		X position of player's entry point on this screen.
4288-89		Y position of player's entry point on this screen.
4290			ID of what is under the under of the player.
4291			Param of what is under the under of the player.
4292			Color of what is under the under of the player.
4293			Number of counters
Per counter-
00-14			15 char name of counter, including null terminator. Padded with
				junk.
15-16			(signed word) Value of counter.
Then-
00-01			Position within file of global robot. (Stored as ID #0)
02				Code- 0 means SFXs follow. 1-150 means use normal SFX and this
				number is equal to the number of boards.

				SFXs- 50 of them (0-49) Each is any length up to 68, preceded by
				a length byte (1-69) of the string w/null termination. Normal
				SFX format. The very first two bytes is a WORD of how long
				this entire section is, not including the first WORD. After
				this section is a number for the number of boards.

03-????		Per board- 25 char title, including null terminator. Padded
				with junk.
????-????	Per board- Length of board in bytes (dword) and position of
				board within file. (byte number, dword)

At location of board- The board itself. (see .MZB files, exactly the same)


code:
File format for the .MZX world file (w/o password protection)
-----------------------------------

This file format is only accurate up through version 1.03.

Byte(s)		Is

00-24			Title of game (name of first board) w/terminating null. Padded
				with junk.
25				Protection method (0=none, 1=no-save, 2=no-edit, 3=total)
				If not a 0, followed by the length of the password, then the
				fifteen character password (encrypted) The rest of the file is
				unaffected.
26-28			The letters "MZX"
29-3612		The character set (14 bytes per character, 256 characters)
				Each character is 14 bytes, from the top row to the bottom
				row, one byte per pixel row.
3613-3918	IdChars array (306 bytes) This is the info in Global Chars,
				as well as anything that can be edited with CHANGE CHAR ID.
3919-3978	The four status counters, IE those counters shown on the
				status screen. Each is 15 chars long, including a terminating
				null. Padded with junk.
3979-3982	Bullet characters- N S E W.
3983			Player character.
3984			X position of saved player position. (SAVE PLAYER POSITION cmd)
3985			Y position of saved player position.
3986			Board number (0-127) of saved player position.
3987			Color of edge border during play.
3988			Color of player.
3989			Color of bullets.
3990			Color of missiles.
3991			Starting board number.
3992			Board for end game. (128 for none)
3993			Board for death. (128 for restart board, 129 for same pos)
3994			X position for end game.
3995			Y position for end game.
3996			X position for death.
3997			Y position for death.
3998-3999	Starting number of lives. (word)
4000-4001   Limit to lives. (word)
4002-4003	Starting amount of health. (word)
4004-4005	Limit to health. (word)
4006			1 if enemies can hurt each other, 0 if not.
4007			1 if game over sfx are on, 0 if not.
4008			00.
4009			Number of boards. (1 to 127)
4010-????	Per board- 25 char title, including null terminator. Padded
				with junk.
????-????	Per board- Length of board in bytes (dword) and position of
				board within file. (byte number, dword)

At location of board- The board itself. (see .MZB files, exactly the same)

Format for a .MZB board file
----------------------------

This file format is only accurate up through version 1.03.

First- Level ids, RLE encoded.
Then-  Level colors, RLE encoded.
Then-  Level params, RLE encoded.
Then-  Ids under stuff, RLE encoded.
Then-  Colors of ids under stuff, RLE encoded.
Last-  Params of ids under stuff, RLE encoded.

Level id/color/param is a number representing an object, a number for it's
color, (bk and fg) and a number representing it's stats. (IE robot id, or
enemy stats, or custom chars, or passage destination, etc) These are all
bytes. The "under stuff" is for things beneath other things, like floors and
carpets. All six sets are RLE encoded, a simple compression method. The
method works as follows- The first byte is the x size (of the board) and the
second byte is the y size. After that, read two bytes. The first is the runs
byte, the second is the data byte. The runs byte tells how many times to use
the data byte. This repeats for the entire x/y size. Runs can wrap across
multiple lines.

After board design-

00-12    	Name of default MOD file, w/extension and null terminator.
				Padded with junk.
13				X position of upper left corner of the viewport.
14				Y position of upper left corner of the viewport.
15				X size of the viewport.
16				Y size of the viewport.
17				1 if you can shoot here, 0 otherwise.
18				1 if you can bomb here, 0 otherwise.
19				1 if fire burns through brown things, 0 otherwise.
20				1 if fire burns through spaces, 0 otherwise.
21				1 if fire burns through fakes, 0 otherwise.
22				1 if fire burns through trees, 0 otherwise.
23          Code for what an explosion leaves- 0 for spaces, 1 for ash,
				2 for fire.
24				1 if you can't save here, 2 if you can only save on a sensor,
				0 for normal saving.
25				0 if forest becomes empty, 1 if forest becomes floor.
26				1 if you collect bombs normally, 0 if they automatically light.
27          1 if fire burns forever, 0 otherwise.
28-31			Board numbers for boards to the N S E and W. 255 for no board.
32				1 if you restart the screen when zapped, 0 otherwise.
33-34			Time limit. (word)
35				The last alphabetic key that was pressed. (A-Z)
36-37			Numeric form of the last input. (word)
38				Size in characters of the last input.
39				Volume for MOD files.
40				1 if the player is locked in the ns direction.
41				1 if the player is locked in the ew direction.
42				1 if the player is locked from attacking.
43-123		81 char string (including null terminator and junk padding) of
				the last string inputted.
124			Number of cycles remaining of blindness.
125			Number of cycles remaining of firewalking.
126			00.
127			Number of cycles remaining of frozen time.
128			Number of cycles remaining of slowed time.
129-131		00.
132			Number of cycles remaining of wind.
133			Last direction the player moved. (0=N, 1=S, 2=E, 3=W)
134-214		81 char string (including null terminator and junk padding) of
				current message at the bottom of the screen.
215			Number of cycles until the message at the bottom of the screen
				disappears.
216			Lazer wall timer, from 0 to 7. (increases once per cycle and
				loops from 7 to 0)
217			Row for the message row.
218			Column for the message row, 0 for centered.
219			X scroll of the screen, signed byte. (From SCROLL VIEW)
220			Y scroll of the screen, signed byte. (From SCROLL VIEW)
221			Number of robots.

Per robot- (these robots start counting at id #1. There is no id #0.)

0-3         (signed dword) Length of robot program
4-7			Junk
8-22			15 character robot name, including null terminator. Padded with
				junk.
23				Robot character.
24-27			(signed dword) Location within program of current line
28				(unsigned byte) Location within current line, IE countdown
				for WAIT and GO commands.
29				(unsigned byte) Robot cycle number.
30				(unsigned byte) Robot cycle count. Reset to 0 after robot runs
				a program section, then each cycle counts up 1. When it reaches
				the Robot cycle number, program continues and this is again
				reset to 0.
31				Bullet type code- 0 player, 1 neutral, 2 enemy.
32				Set to one if robot is locked from receiving messages.
33				Set to one for a lava walking robot.
34				Current direction of walk. (1 North 2 South 3 East 4 West)
35				Last direction the robot was touched. (1-4)
36				Last direction the robot was shot. (1-4)

This is now followed by the robot's program according to it's length.

Next-
0				Number of scrolls (counting from id #1)

Per scroll-
0-1			(unsigned word) Number of lines in the scroll
2-5			Junk.
6-9			(unsigned dword) Length in chars of the scroll.

This is now followed by the scroll's text. Signs count as scrolls.

Next-
0				Number of sensors (counting from id #1)

Per sensor-
0-14			15 char name of sensor, including null terminator. Padded with
				junk.
15				Sensor char.
16-30			15 char name of robot to send messages to, including null
				terminator. Padded with junk.

Finally, the board name (25 chars including null and junk padding) is at the
end of the board ONLY IN A .MZB FILE. Within a .MZX or .SAV file, this is not
present.

Format for a .SAV saved game file (Megazeux)
---------------------------------

This file format is only accurate up through version 1.03.

00-05			The letters "MZSAV" and a null terminator.
06				Current board number.
07-3590		The character set (14 bytes per character, 256 characters)
				Each character is 14 bytes, from the top row to the bottom
				row, one byte per pixel row.
3591-3896	IdChars array (306 bytes) This is the info in Global Chars,
				as well as anything that can be edited with CHANGE CHAR ID.
3897-3912   Current keys held. Each byte is either 0-15 for a key or 127
				for no key.
3913-3962	The four status counters, IE those counters shown on the
				status screen. Each is 15 chars long, including a terminating
				null. Padded with junk.
3963-3966	Bullet characters- N S E W.
3967			Player character.
3968			X position of saved player position. (SAVE PLAYER POSITION cmd)
3969			Y position of saved player position.
3970			Board number (0-127) of saved player position.
3971			Color of edge border during play.
3972			Color of player.
3973			Color of bullets.
3974			Color of missiles.
3975			Base color for scrolls.
3976			Border color for scrolls.
3977			Pointer color for scrolls.
3978			Title color for scrolls.
3979			Arrow color for scrolls.
3980-3983	(dword) Current score.
3984			Starting board number.
3985			Board for end game.
3986			Board for death.
3987			X position for end game.
3988			Y position for end game.
3989			X position for death.
3990			Y position for death.
3991-3992	Starting number of lives. (word)
3993-3994   Limit to lives. (word)
3995-3996	Starting amount of health. (word)
3997-3998	Limit to health. (word)
3999			1 if enemies can hurt each other, 0 if not.
4000			Junk byte.
4001			00.
4002			Number of counters
Per counter-
00-14			15 char name of counter, including null terminator. Padded with
				junk.
15-16			(unsigned word) Value of counter.
Then-
00				Number of boards. (1 to 127)
01-????		Per board- 25 char title, including null terminator. Padded
				with junk.
????-????	Per board- Length of board in bytes (dword) and position of
				board within file. (byte number, dword)

At location of board- The board itself. (see .MZB files, exactly the same)

repo_name: pgimeno/megazeux

license: mit


code:
MegaZeux ver 2.51 source -

		  Copyright (C) 1996 by Greg Janson
		  Copyright (C) 1998 by Matthew D. Williams

  REQUIREMENTS:
		  IBM PC (286 or higher) compatible computer
		  640K RAM
		  EGA or higher display adapter
		  SoundBlaster/PAS-16/GUS sound card optional
		  Mouse optional
		  Dos 2.1 or greater
		  Hard drive w/at least 5 megabytes free

              Internet: dbwilli@scsn.net
		  WWW: http://www.scsn.net/users/dbwilli/

  This game package may be copied or distributed according to the
  terms and conditions stated in GNUGPL.DOC.

MegaZeux --- Table of Contents

  Section

	  I.  License Agreement and Support
	 II.  Installing and Starting the Program
	III.  Overview of MegaZeux
       IV.  Controls
	  V.  Advanced Play Info, Tips
	 VI.  The World Editor
	VII.  General Editing Tips
     VIII.  Robots- What They Are and How to Use Them
	 IX.  FREQUENTLY ASKED QUESTIONS
	  X.  Command Line Options
	 XI.  EMS Memory/Boot Disk Tips
	XII.  Known Bugs and Quirks
     XIII.  Thanks, Acknowledgements, and Miscellaneous

I. LICENSE AGREEMENT AND SUPPORT

  --- LICENSE ---

  This program is free software; you can redistribute it and/or
  modify it under the terms of the GNU General Public License as
  published by the Free Software Foundation; either version 2 of
  the License, or (at your option) any later version.

  This program is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  General Public License for more details.

  You should have received a copy of the GNU General Public License
  (GNUGPL.DOC) along with this program; if not, write to the Free Software
  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.

  --- SUPPORT ---

  This source code is supplied as is.  The current copyright holder is not
  required in any way to assist anyone who chooses to modify this code.

  However, the current copyright holder can be reached via email:
  Matt Williams
  dbwilli@scsn.net
  And via the World Wide Web:
  http://www.scsn.net/users/dbwilli/

II. INSTALLING AND STARTING THE PROGRAM

  It is recommended that you install MegaZeux in its own sub-directory
  on your hard disk. Do NOT run the program directly from a distribution
  disk, as disks sometimes fail.  Always make a copy and run the program
  from it!

  To install the registered version of MegaZeux, simply change to the proper
  drive (usually A: or B:) after inserting the installation disk. Type
  INSTALL and select the program to install. A recommended directory is
  MEGAZEUX. Then you must wait as the program is unarchived and copied to
  the given directory.

  You should always use INSTALL to install registered products from Software
  Visions, as they are in archived form.

  Once the program is installed, you can change to that sub-directory at
  any time and run the program.

  MegaZeux is started by typing

		  MEGAZEUX

  You will then be prompted for an output device to use for all digitized
  music and sound. If you do not pick PC Speaker, you will then be prompted
  for whether you wish PC Speaker sound IN ADDITION to digitized music and
  sound. Then, if you did not pick No Sound for digitized output, you will
  be prompted to pick a mixing rate for digitized music. Lower numbers are
  more staticy and may distort percussion sounds, but higher numbers require
  more processor power. The high end numbers will slow down the game (OK on
  a 386 or 486) or even stop it on a 286 or very slow 386. Experiment for
  the best compromise.

  You will then be whisked to the title screen for the first included game,
  Caverns of Zeux. Press P to play, or L to load another world. Press F1
  for comprehensive help AT ANY TIME. Help is context sensitive, and much
  more comprehensive than this document.

III.  Overview of MegaZeux

  Welcome to MegaZeux!

  As you may already know, MegaZeux is a game system which
  allows you to play almost limitless worlds in EGA graphics
  and with beautiful digitized music and sound. MegaZeux comes
  with worlds, and new worlds are being uploaded every day to
  major on-line services such as America Online. But the most
  fabulous feature of MegaZeux is the World Editor.

  Using the World Editor, ANYONE can create the world of their
  dreams. Make it as simple or complex, as easy or difficult,
  as long or short as you please. And we aren't just talking
  about worlds made up of petty, pre-programmed enemies and
  objects. MegaZeux has it's own, easy to use PROGRAMMING
  LANGUAGE called Robotic that allows you to create enemies,
  objects, and worlds that do almost anything you desire.

  For the new user, I recommend you play Caverns, the first
  included game, to get the feel of MegaZeux. You may wish
  to read the section entitled "Controls" to learn how
  to play MegaZeux.

  Once you have the feel for the game, however, feel free
  to dive into the World Editor and get messy! You should
  probably read the section entitled "The World Editor"
  first.

IV.  Controls

  MegaZeux is very easy to play, once you understand the
  simple control system. After that, experimentation will
  prove to be the best teacher, although you can discover
  everything within Help as well.

  To start a game, press 'P' during the title screen. To
  select another world, press 'L' during the title screen.
  Use ESC during the title screen to exit to DOS, or during
  the game to return to the title screen. You know it is
  the title screen if a message on the bottom says "Press
  F1 for help, Enter for menu". Enter will bring up a menu
  of options on the title screen, also.

  Your character is represented by a little smiley face
  in the included game(s). In other games, he may be
  a stick person, animal, spaceship, or other entity.
  Usually it is obvious where you are, since you are usually
  colored to stand out.

  To move your character, press one of the arrow keys on
  the keyboard or numeric keypad. If you hold it down, you
  will continue to move in that direction.

  To interact with objects and other characters, you usually
  must stand next to them and touch them. This basically
  means push against them using the arrow keys. Watch out
  for enemies and evil creatures, who will often hurt you
  when you touch them.

  To stop enemies, you will usually have some type of weapon,
  often with limited ammunition. The actual weapon depends
  upon the game, and may even differ from game to game, but
  by default you have a small pistol. To fire your weapon,
  hold Space and press an arrow key. You can also hold the
  arrow key and press Space. You must press both keys TOGETHER.

  To see your current status, such as Health points, Coins,
  Gems, Ammunition, and Keys, press Enter. This will bring up
  a box containing all your stats, as well as a menu detailing
  other options you have available.

  In some games, you may encounter bombs. (as usual, push
  against them to pick them up.) To use a bomb, press the
  Delete key. Then run! The bomb will not actually burn its
  fuse until you step away from it. There are two styles of
  bomb- Low strength and High strength. You can tell which
  kind you pick up by the pitch of the sound it makes. To
  change which TYPE of bomb you are using, press Insert. A
  message at the bottom of the screen will inform you of
  your new selection.

  Other games may have other controls, such as 'S' to cast
  a spell, or 'J' to jump, but they will be detailed within
  the game. Some basic play tips:

  * Make sure you visit every screen. To get to other screens,
	 enter passageways, stairs, caves, or doors. (by pushing
	 against them.) You can also often reach another screen
	 by pushing against the edge of the screen, leading to an
	 adjacent screen.

  * Touch everything! Even things of seemingly little value may
	 prove worthy of your attention. If it kills you, then...
	 well... hope you saved.

  * Save your game! It is rather simple- Press F3 to save your
	 game to disk at the EXACT point you are at. Press F4 to
	 reload a game off of disk. You can use F9 and F10 to
	 quick-save and quick-load, which work on the last game
	 you saved. Remember to save often- If something kills you,
	 you'll want a game to go back to.

  * Collect supplies! Make sure you grab every coin, gem,
	 ammo dump, bomb, chest, and pouch you see! You will often
	 be in want of supplies, so don't push things.

  * Remember how things work. Most things in MegaZeux have
	 patterns, and the same object will usually do the same
	 thing all the time. (although two objects may look alike
	 and not really be the same thing)

V.  Advanced Play Info, Tips

  You've tried some MegaZeux worlds, and they are fun, but you
  have the feeling you are missing something. This is it- the
  remaining knowledge you might need to survive in a given world.

  First, let me warn you that many worlds you get from public
  services or BBSes may not be of a very good quality. They may
  be unfair, boring, have bugs, and/or not give proper
  instructions. My advice is to E-Mail the author and tell him
  what you think of poor quality MegaZeux games. There is no
  problem in MAKING them, but PLEASE don't upload them. Don't
  let a few losers ruin the fun.

  Now to cover the game keys, in detail-

  F1- Help
  Use this at any time to bring up help relating to the current
  situation. Within the game, you will go to the Controls
  section.

  Enter- Menu/status
  Use this to bring up a menu of options and a list of your
  current stats, such as Score, Gems, etc.

  ESC- Exit to title
  This will quit the current game and return to it's title
  screen.

  F2- Settings
  This will bring up a dialog box where you can change the
  current game settings, such as Game Speed, Music, and
  Sound. To speed up the game, lower the speed and/or turn
  music off. A speed of 1 will cause flicker in most machines,
  so it is not recommended unless it is your only option.

  F3- Save game
  This will prompt you for a filename, then save the exact
  state of your current game. Some games may not allow saving
  on some or all of its screens. This lets you quit your game
  in the middle or take precautions against unknown dangers.

  F4- Restore game
  This will let you select a saved game from a list of filenames.
  The game will then be reloaded from the same point you left off
  at.

  F5 or Insert- Toggle bomb type
  This will switch your current bomb type between High Strength
  and Low Strength.

  F6- Debug mode
  This will bring up a small box in the lower left corner of the
  screen, detailing your position and the current memory
  situation. It is generally only necessary when testing and
  fixing your own games. Press F6 again to turn the box off. The
  debug menu, when active, will also increase the sensitivity to
  module and SAM problems. Normally during the game, no errors
  relating to modules and SAMs will be shown. With the debug menu on,
  errors loading modules and SAMs and out of memory conditions will
  be shown.

  F9- Quicksave
  This will save the game, like F3, but to the last filename you
  used, without prompting you for a filename. The old file will
  be overwritten. If no game has been saved since MegaZeux was
  started, a filename of SAVED.SAV will be used.

  F10- Quickload
  This will reload the last game saved using F3 or F9. If no
  game has been saved since MegaZeux was started, a filename of
  SAVED.SAV will be used.

  Arrows- Move
  The arrow keys will move your character and allow him to
  interact with most objects.

  Space- Shoot
  Use this key in conjunction with an arrow key to fire your
  weapon in the selected direction. Weapons vary from world to
  world.

  Delete- Bomb
  This will drop a bomb of the current type BENEATH the player.
  Move out of the way to see it, then run before it explodes!

  The following keys are active at the title screen-

  F1- Help (see above)

  Enter- Menu
  This is similar to Enter within the game. However, there is
  no status screen.

  ESC- Exit to DOS
  Pressing ESC will exit MegaZeux, returning to the DOS prompt
  or other operating system.

  F2 or S- Settings (see above)

  F3 or L- Load world
  This will allow you to load up the title screen of any MegaZeux
  world. A list of choices will be presented to you to select
  from. After the world is loaded, you may watch the title
  screen, then press 'P' to play.

  F4 or R- Restore game (see above)

  F5 or P- Play game
  This will stop the title screen and actually begin game play.

  F6- Debug menu (see above)

  F8 or E- World editor
  This will quit the gaming portion of MegaZeux and enter the
  integrated World Editor. For detailed info on using the World
  Editor, view the appropriate help sections.

  F10- Quickload (see above)

  We'll close this section with some more playing tips, some
  general hints and others specific to certain sections of
  Caverns of Zeux, the first included game.

  * Don't take anything for granted. If it looks like a spike,
	 it PROBABLY is. PROBABLY. Although it is rare that these
	 types of puzzles must be solved to complete a game, there
	 are often bonuses, hidden rooms, etc. behind illusions.

  * Don't trust anyone. All characters in a game, (including
	 yourself) have the potential to lie, cheat, and backstab.

  * Try things twice. Sometimes objects respond differently a
	 second time. If you get a new treasure, go talk to all
	 the citizens- maybe one of them will say something new!

  * Caverns hint- (DON'T READ UNLESS YOU ARE STUCK!) Many people
	 often get stuck early in the game, after a couple of bosses.
	 If you have the three amulets, did you talk to the dwarf in
	 town who wants them? Make sure you change back to a dwarf
	 by talking to the spirit. Later make sure to lavawalk across
	 the lava on the left of the room where you got the three
	 amulets.

VI.  The World Editor

  Ready to start creating your own worlds? Then let's get
  started! This section is a short editor tutorial, it will teach
  you the basics of creating your own worlds.

  To get into the editor, press E from the title screen. You will
  be presented with a blank board with a small menu at the bottom.
  You can use PgUp and PgDn to change the currently shown menu,
  and you will be presented with various keys and options. The
  mouse also works here. Feel free to fool around with these
  various options. Press Alt+R to restart and clear everything.

  For your first world, you should start simple. The screen you
  begin on is your title screen, so pick a simple name for your
  game, such as "Mike's World". Move the flashing cursor down a
  few lines and over a few spaces, using the arrow keys. Press C
  and use the arrow keys to select an appropriate color. Press
  Enter to select this color. Now press F2 to write Text. Type
  in the name of your world, and then press F2 to stop writing
  text. This screen will be your title screen.

  Now you need to create the first board, or location, of your
  game. Press A to add a board, then type in a short description
  of the board, such as "Starting Board". Press Enter to go to
  this new board.

  Now you are free to doodle around. Use C to change the active
  color. Use F3 through F9 to bring up menus of items, terrains,
  and creatures. Selecting one with the arrows and Enter will
  allow you to place it using arrow keys and space.

  For example, press F3 for terrains, and select Line. (This is
  a form of wall.) Now move around, placing walls. To ease this,
  you can press Tab to toggle draw mode. When draw mode is active,
  every move of the cursor will place the current item/color. The
  current item and color is shown on the top line of the menu.

  Try to create a pleasing-looking screen, with walls, items, and
  creatures. Some items will require that you set settings to
  determine their behavior. To place the player's starting
  position, move the cursor to the destination, press F10, and
  select Player.

  When you are done, press G to go to the Global Info screen. TAB
  to the Next button and press Enter. You will now be highlighting
  the option "Starting Board". Press Enter, and select the
  starting board (NOT the title screen) from the list and press
  Enter. Then TAB to OK and press Enter. This tells MegaZeux which
  board you want the game to start on.

  You could now press Alt+N to select a module (music) file for the
  board, if you wished. Then press S to save the world, and type in a
  filename of eight or less characters. (The extension of .MZX
  will automatically be added.) Press Enter twice to save. Press
  ESC to exit the editor, and now you can play your game! You can
  use L to reload your world in the editor to make changes, if
  necessary. See General Editing Tips for more advanced editing
  info.

VII.  General Editing Tips

  The following is a list of important editing tips. They assume
  you are familiar with MegaZeux's dialog box system, and that
  you can navigate the editor's menus.

	  Linking Boards

  One-board games get boring REAL fast. There are two ways to
  connect multiple boards. The first way is to add stairs, doors,
  and whirlpools using the Transport (F7) menu. Then you select a
  destination board. The destination board should contain a
  similar transport, leading back. The two entrances will now lead
  to each other.

  The other method of connecting boards is with X, the Board Exits
  dialog. Here, you can select boards that you will reach if you
  walk off of the screen in a given direction. The destination
  board shouldn't have anything in the way, and will not
  automatically lead back- You must set the exit on that board
  too.

  To add boards, press A, or select (new board) from a board list.
  To switch to other boards, use B.

	  Board Sizes

  You can change the maximum size, and the view position, of a
  board, with Alt+P. Here you can move and re-size the view, or
  center it on-screen.

  You can also change the actual size of the board, as well as
  the maximum, overall size. The lowermost radio control
  determines the MAXIMUM size possible for the board, one of
  60x166, 80x125, 100x100, 200x50, or 400x25. The Virtual size
  is the ACTUAL size of the board, which is always equal to or
  less than the MAXIMUM size. Example- If you wanted a board
  that was 180 wide and 40 high, you would select a MAXIMUM
  size of 200x50, then set the Virtual size to 180x40.

  Note that reducing the size of a board will permanently
  destroy anything outside the new limits.

	  Other Important Editing Keys

  You can use Insert to "grab" the object beneath the cursor, or
  Enter to edit it and then grab it as well. Use P to modify the
  current object's settings. Use Alt+N to select music for the
  current board, or turn the music off if it is already selected.
  Use Alt+Z to clear the current board entirely. You can edit
  important Board Options with I, and important Global (world)
  Options with G.

VIII.  Robots- What They Are and How to Use Them

  Robots are the heart and soul of MegaZeux. Anything you could
  want to do in MegaZeux, anything you see done in a MegaZeux
  game, many things you didn't know were possible, can be done
  with MegaZeux's Robots.

  Robots are programmed in their own programming language, called
  Robotic. Robotic is a fairly simple language to learn, somewhere
  along the lines of BASIC, although a bit more complex. If you've
  ever used Epic Megagame's ZZT, Robotic is a bit more complex
  than ZZT-OOP, although it is similar and more logical in style
  and syntax.

  To place a Robot in the editor, press F10 and select Robot, or
  Pushable Robot if you want things to be able to push the Robot.
  Then name the Robot, and select a character to represent it. Now
  you are brought to the Robot editor, where you can program the
  Robot in Robotic.

  Complete info and a tutorial on Robotic is included in the online
  Help.

IX.  FREQUENTLY ASKED QUESTIONS

  The following is a list of questions that I have received
  through mail or E-mail about MegaZeux repetitively.

  Q: My robot can't change it's/the player's characters! I
	  use CHAR "A" but it turns invisible!

  A: Use CHAR 'A' instead. You MUST use single quotes
	  (apostrophes) or it will use the value of the COUNTER
	  A which is probably 0.

  Q: Can I distribute a world I made with MegaZeux? Is it
	  legal? Must I/Can I include MegaZeux with it? Can they
	  be shareware worlds?

  A: Of course you can distribute your worlds! That is what
	  MegaZeux is for! Please refrain from uploading worlds
	  that you made as a novice user, if they contain only
	  built-in enemies, items, and no plot/etc. People will
	  only yell at you. Get creative and use Robots! Please
	  include any SAM, MOD, and CHR files with the games,
	  as well as a short TXT description file if necessary.
	  Don't include MegaZeux, but make sure MegaZeux itself
	  is available on any BBS or online system that you
	  upload worlds to. (MegaZeux is available on AOL) Your
	  worlds can be freeware, public domain, or shareware,
	  whichever you prefer.

  Q: Can I use the music from Caverns in my games? How about
	  the music from the registered games? How about the SAM
	  files?

  A: I would prefer it if you did not use Caverns music in
	  any games you distribute, because most people have
	  heard it and it is getting old. The music from the
	  registered games is illegal to distribute. The SAM
	  files are public domain and may be used as you please.

  Q: Where can I get module files?

  A: If you can't make them, search public BBSes and online
	  services for public domain ones. AOL has a large MOD/S3M
	  library, as do many CD-ROM collections. Or employ a
	  friend to do it for you. I myself (Greg Janson) am
	  not available to create module files unless I am being
	  paid well for my time.

  Q: What is some good software to create module files?

  A: For modules, Fast Tracker II by Triton is fairly good, but
	  you have to avoid using the XM features. ScreamTracker 3.0
	  is good for making S3M files.

  Q: How do I make SAM files?

  A: There are three easy ways to create SAM files. First,
	  you get recording software, a sound card, and a mike.
	  Hook 'em all up (read the instructions) and go for it.
	  Second, you can download them or get them from module
	  files or other games. Third, you can take existing files
	  and change them with effects like echo. Blaster Master
	  is a good piece of software to handle numbers one and
	  three.

  Q: But I can only find software to make WAVs! (or VOCs)

  A: There is a nice small program called CVT2SAM which can
	  convert most WAVs and VOCs to SAMs. I believe it is in
	  the public domain. It is available on AOL.

  Q: The TELEPORT PLAYER command doesn't work!

  A: It does now. That was a small (er... big) bug in version
	  1.02, which was corrected in version 1.03 and 2.51.

  Q: Is the world design contest still going?

  A: Until you see a Best of MegaZeux series OR the calendar
	  reaches 1-22-97 without sufficient entries, the contest
	  will continue. So far I've received only one board,
	  which wasn't even acceptable. However, I've received
	  E-mail from several interested parties, so the contest
	  continues. See CONTEST.TXT for details.

  Q: I need more than 256 characters!

  A: Then you'll need to carefully utilize the Robot command
	  LOAD CHAR SET and ration your characters carefully. The
	  limit of 256 is a hardware limit and cannot easily be
	  worked around.

X.  Command Line Options

  The following command line options are available for use when
  starting MegaZeux. To use them, type them in after MEGAZEUX
  at the DOS prompt. Separate all options with spaces.

  -?

  Bring up command line option help screen.

  -lxxxxxxxx.MZX

  Loads up xxxxxxxx.MZX at start up. (the .MZX is optional)

  -nomouse

  Don't activate the mouse, even if one is present. Use if the
  mouse gets in the way or MegaZeux seems to think you have a
  mouse when you don't.

  -noems

  Don't use any EMS memory. Use if MegaZeux's use of EMS memory
  is causing a problem. Note that with this option, you will
  probably not have enough memory for module and SAM files.

  -ega

  Use EGA mode even on VGA or higher. This only affects the
  granularity of palette fades and color changes.

  -keyb2

  Use another style of keyboard handler. Use if your keyboard is
  locking up or otherwise causing problems.

  ** Sound Card Options

  -port###
  -irq#
  -dma#

  Allows you to specify the settings for your sound card. -port
  sets the base port and must be followed by a hexadecimal number
  such as 220. -irq sets the IRQ line number, and should be
  followed by a single digit such as 7. -dma sets the DMA number
  and should be followed by a single digit such as 1. See your
  sound card manual for details. These options are only neccesary
  if autodetection fails. An example of a command line for the
  default SoundBlaster settings-

  MEGAZEUX -port220 -irq7 -dma1

XI.  EMS Memory/Boot Disk Tips

  MegaZeux makes extensive use of EMS and conventional (first
  640k) memory. The more you have available, the better it will
  run.

  To have EMS memory available, you must have an EMS driver
  installed. Most EMS drivers also require an XMS/HIMEM driver
  loaded first. You will need lines similar to the following in
  your CONFIG.SYS to load HIMEM and an EMS driver, respectively-

  DEVICE=C:\DOS\HIMEM.SYS
  DEVICEHIGH=C:\DOS\EMM386.EXE 3072 H=160

  The 3072 tells DOS to reserve up to 3072K of memory (3
  megabytes) for EMS. Feel free to lower or raise this value,
  but a minimum of 2048K (2 megabytes) is recommended.

  It is also recommended that you load SmartDrive to run MegaZeux.
  SmartDrive is a disk-cache utility that is usually loaded,
  because it greatly speeds up repeat disk accesses. You probably
  already have a line such as SMARTDRV.EXE /X in your AUTOEXEC.BAT;
  if not, you should consider adding it somewhere after the PATH
  statement.

  To help free up conventional memory, you may need to create a
  boot disk. This is a common procedure for games that use less
  conventional setups (such as MegaZeux), and if a certain boot disk
  works for one game, it may work just fine for MegaZeux. However,
  you must remember to include HIMEM and an EMS driver, and include
  a mouse driver if you want your mouse to be available.

  To create a boot disk, stick a blank disk into your A: drive and
  type the following:

  FORMAT A: /S <enter>

  Answer Yes to all questions. Give the disk a label if you wish.
  Answer No to "Format another?" and then type:

  COPY CON A:CONFIG.SYS <enter>
  DEVICE=C:\DOS\HIMEM.SYS <enter>
  DEVICEHIGH=C:\DOS\EMM386.EXE 4096 H=160 <enter>
  DOS=HIGH <enter>
  <ctrl+z>

  COPY CON A:AUTOEXEC.BAT <enter>
  PATH C:\DOS;C:\WINDOWS <enter>
  SMARTDRV /X <enter>
  C:\MOUSE\MOUSE <enter>
  C: <enter>
  CD \MEGAZEUX <enter>
  MEGAZEUX <enter>
  <ctrl+z>

  The line to load the mouse driver is optional, and may vary on
  different computers. The drive and directory you have MegaZeux
  in may differ as well. Your windows and dos paths may differ.

  Once you've followed these instructions, you can insert the
  disk and reboot the computer to run MegaZeux. It is best if you
  get a computer-wise friend to help you, if you can't get the
  above to work.

  One note- most newer sound cards require drivers or other
  programs to be run before they can be used. Check your existing
  configuration files and/or manuals to find out what these
  commands are if you intend to use MegaZeux with a boot disk.

XII.  Known Bugs and Quirks

  Note that the graphics quirks are more likely to appear on laptops
  as their graphics cards are usually proprietary and may contain
  non-standard quirks.

  A. A couple of computers/graphics cards display MegaZeux in the
	  "9-pixel-character" mode. This basically means that thin black
	  lines appear between each column of most characters. This doesn't
	  affect gameplay but can be annoying. Known offenders- Zenith
	  Z-Note MX laptop.

  B. A couple computers/graphics cards may display characters with the
	  bottom of every character stretched down a little (2 additional
	  rows of pixels added). This does not affect gameplay but can be
	  annoying. Known offenders- Sharp 8700 Laptop

  C. Certain SVGA cards display black as deep red. Again, this doesn't
	  affect gameplay but can be annoying.

  D. The Global Robot's code has been reported to be trashed while
	  music is on. (in the editor.) It happened very rarely and I cannot
	  seem to reproduce or pinpoint the bug. It may be an isolated
	  cause.

  E. Certain modules may play slightly off-tune.

  F. MegaZeux does not always run under certain Windows or Win95
	  configurations, or if it does, sound does not work.

  If you have something to add here or might be able to help solve one
  of these quirks, drop me a line.

XIII.  THANKS, ACKNOWLEDGEMENTS, AND MISCELLANEOUS

  ** Credits and Acknowledgments **

  Programming and Overall Design by Gregory Janson
  Music/Sound code by Edward Schlunder

  Included Game Modules by Gregory Janson
  Included Music by Gregory Janson

  Beta Testing and Special thanks:

  Jason Albanese
  Alek Benedict
  Chris Bromley
  Christopher Christensen *
  Chris Cooper
  Carlos DaSilva
  Jacob Farmer
  Geoff Friesen *
  Tim Gallagher
  Themie Gouthas *
  Jamie Holub
  Jason Kim
  Dave Kirsch *
  Elbert Lim
  Joe McManis
  Vic Putz *
  Robin Rudge *
  Brian Schweitzer
  Allen Shirvanian
  Tim Sweeny (author of ZZT)
  Tony Vanvranken

  * = Thanks for the public domain code!

  AOL Beta Testers

  Compukid
  Shammydog
  DMcgee1008
  SpectreB1
  NL Aric
  JustJoshua
  SkreenNme
  MegaKev
  Herbie III
  Spider124

				- Originally by Greg Janson
				  ZZT'er at heart

				- Modified by Matt Williams
				  also a ZZT'er at heart
				  on March 1, 1998


code:
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
                      "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<title>MegaZeux Platform Support Matrix</title>

MegaZeux Platform Support Matrix

Best viewed with >=1280 pixel monitor.

Legend:
Ideal
Normal
Not applicable
Suboptimal, Trivially fixable
Faulty, Not trivially fixable

$PLATFORM
amiga
android
darwin
gp2x
mingw
msvc
nds
psp
unix
wii
pandora

Description
AmigaOS 4.x
Android
MacOS 10.x
GP2X
Windows
(GNU toolchain)
Windows
(Visual Studio)
Nintendo DS
Playstation Portable
Linux, BSD, Solaris
HaikuOS, etc.
Nintendo Wii
Pandora

Architecture(s)
(Tested Only)
PPC (ELF)
ARMv7-a (ELF)
i686 (ELF)
PPC (Mach-O)
i686 (Mach-O)
ARM9 (ELF)
x86 (PE COFF)
x86 (PE COFF)
x64 (PE+ COFF)
ARM9 (ELF)
MIPS (ELF)
x86 (ELF)
AMD64 (ELF)
PPC64 (ELF)
PPC (ELF)
ARMv7-a (ELF)

Endian
Big
Little
Varies
Little
Little
Little
Little
Little
Varies
Big
Little

Toolchain
gcc 4.2.2
binutils 2.14
clib2
gcc 4.2.1
binutils 2.17
bionic
gcc 4.0.1
cctools 667.3
10.3 (min ver)
gcc 4.1.1
binutils 2.16.1
glibc 2.3.6
(open2x)
gcc 4.4.0
binutils 2.19.1
Visual Studio 2008
gcc 4.4.0
binutils 2.19.1
(dk r26)
gcc 4.3.3
binutils 2.16.1
(dk r13)
Various
gcc 4.4.1
binutils 2.19.1
(dk r18)
gcc 4.4.1
binutils 2.19.51
(CS 2009q3)

Packaged
LHA
TBD
DMG
ZIP
ZIP
NO[1]
ZIP
ZIP
Various
ZIP
ZIP (PND?)

Optimized
Visibility[2]
YES
YES
YES
N/A
YES
YES
N/A
N/A
YES
N/A
YES

Stack Protector
YES
NO
YES
NO
NO[3]
NO
NO
NO
YES
NO
YES

Module Engine
ModPlug
ModPlug
ModPlug
MikMod
ModPlug
ModPlug
N/A
ModPlug
ModPlug
ModPlug
ModPlug

Ogg Vorbis
libvorbis
tremor
libvorbis
tremor
libvorbis
libvorbis
N/A
tremor
libvorbis
libvorbis
tremor

Optimization
Speed
Size
Speed
Size
Speed
Speed
Size
Size
Speed
Size
Speed

SDL
YES
NO
YES
YES
YES
YES
NO
YES
YES
NO
YES

EDITOR
YES
YES
YES
NO[4]
YES
YES
NO[4]
NO[4]
YES
YES
YES

HELPSYS
YES
YES
YES
NO[4]
YES
YES
NO[4]
NO[4]
YES
YES
YES

AUDIO
YES
TBD
YES
YES
YES
YES
NO
YES
YES
YES
YES

SOFTWARE
YES
NO
YES
render_gp2x
YES
YES
render_nds
YES
YES
render_gx
YES

GL
YES
YES
YES
N/A
YES
YES
NO
NO
YES
NO
NO

OVERLAY
YES
NO
YES
NO
YES
YES
NO
NO
YES
NO
NO

GLSL
YES
YES
YES
N/A
YES
YES
N/A
N/A
YES
N/A
NO

UPDATER
YES
YES
YES
YES
YES
YES
NO
NO
NO[5]
NO
YES

MODULAR
YES
YES
YES
N/A
YES
YES
N/A
N/A
YES
N/A
N/A

PNG
YES
YES
YES
YES
YES
YES
NO[6]
NO[6]
YES
NO[6]
YES

X11
N/A
N/A
N/A
N/A
N/A
N/A
N/A
N/A
YES
N/A
NO

LOADSAVE_METER
NO
NO
NO
YES
NO
NO
YES
YES
NO
YES
NO

Platform Notes

Could use existing `package.sh' however this does
not handle PDB files.

MSVC binaries are replicate of MinGW binaries and require a non-free, non
cross-capable compiler.

"Optimized Visibility" refers to the
hiding of library symbols which are not required or referenced
outside of that library. An "optimized" library is smaller
and loads faster.

Required on Win32. Only applicable with CONFIG_MODULAR=y builds.

Disabled due to miscompilation of stack protector
in conjunction with C++ exceptions with some MinGW compilers.

The editor and help system features are disabled
to conserve cache on embedded platforms. The features build and work
on these platforms, but they are basically unusable due to the lack of any
on-screen keyboard.

The updater is typically disabled in the Linux
binaries that are shipped (for distributions like Debian or Fedora), even
though the feature can easily be enabled.
The issue is that MegaZeux is
installed system-wide on these platforms and overwrites cannot be
guaranteed.
Additionally, it is felt that the advanced package management
on these platforms supercedes any usefulness of the built-in updater.

Not had the opportunity to cross compile the
required libraries (zlib and libpng).
Future developments may depend on
these libraries, such as networking and the archive browser. Currently, the
bloat cannot be justified, and these platforms do not yet have functioning
network APIs.

Copyright

This document may be copied and redistributed without limitation
or reservation.


code:
MegaZeux 2.80 public BETA

-- Introduction --

MegaZeux 2.80 is a hybrid port/rewrite of MegaZeux 2.70 for DOS (actually,
development for 2.80 began a bit prior to 2.70's release, but it's 100%
feature compatible). It is not a complete rewrite, in that the existing
MZX source was used as a base for its development. Nonetheless, quite a lot
of the code has been rewritten, and what hasn't been has been reformatted
and carefully examined. As much as 75% or more of the current source is new
code or code that has been heavily modified from the original. For this
reason, it is not adequete to simply refer to it as a port, because a
typical port will only have the bare minimum changes necessary to make the
program run seamlessly on other platforms (or sometimes, just one other
platform, such as MZX32). This does not fully realize this project's short
and long-term goals, which include:

- First and foremost, as stated, allowing MZX in its current state to run
  seamlessly on other platforms with no handicaps (for instance, missing
  robot editor)
- Removing unnatural limitations within MZX itself.
- Providing a relatively sane and efficient implementation of MZX's
  functionality.
- Providing source code which is decently readable, maintainable, and
  can easily be modified and expanded upon.
- As much portability as possible, placing portability over other ideals.

In case anyone is actually interested, here is a more technical overview
of what has actually been done so far on this project:

- All ASM files have been rewritten to ANSI C compliant C++; this mainly
  involves the mammoth game2.asm.
- Everything graphics related has been replaced with an SDL driven engine,
  including text mode rendering (also capable of rendering SMZX modes)
- All keyboard and mouse events are now also handled by an SDL driven
  engine. All internal keyboard/mouse routines use SDL keycodes; no
  attempt was made to convert to MZX's old format at this level.
- All world/board/robot loading and saving code has been entirely
  rewritten and is more modular now.
- All robot handling code has been rewritten from scratch, and is more
  sane/efficient now (allocation, message sending, sensors, etc.)
- All counter handling code has also been rewritten from scratch. This
  includes the functionality of builtin and "function" counters. It also
  includes a new string framework.
- The robot interpreter has been almost entirely rewritten.
- The main game playing code (game.cpp) has been almost entirely rewritten.
- All module/sample playing code has been rewritten to use modplug and
  SDL. PC speaker effects are emulated.
- The main part of the editor (edit.cpp) has been almost entirely rewritten.
- The robot editor has been entirely rewritten, utilizing a modifed (fixed)
  version of RASM (released by me over a year ago)
- All other source files (for instance, window handling code, scroll
  displaying, char editor, etc.) have been largely overhauled, some to more
  of a degree than others. At the very least, everything has been
  reformatted and made to work with the new systems.

Now, for a disclaimer. This release is very much in beta status. What that
means is that it will almost definitely have several bugs. I have every
intention of fixing such bugs as soon as I can, and if I don't, someone
else definitely will. The port has been tested internally by private beta
testers for some time now, and I suspect that there is at least a 90%
compatability rate. Nonetheless, MZX has such a diverse number of
applications and worlds have so many variables that it's impossible to
test exhaustively, especially with the features added after version 2.51s3.
See more about bugs/reporting procedure further down.

-- Platforms --

See platforms_matrix.html for a list of supported platforms and the options
available to each respective platform.

-- Minimum Requirements --

I really can't give any exact numbers here, because for one thing it depends
entirely on the game being ran. Chances are the requirements will only be
slightly higher than it would be for a machine that can run the DOS version
correctly, and sometimes may even be slightly lower. As compared to the
original, the port has to manually draw the screen pixel by pixel without
acceleration. However, the renderer is optimized and quite fast.

For the record, I believe the lowest specs machine that has ran the port so
far is a 266MHz mobile Pentium 2 with 32-64MB of RAM. Chances are it can
run fine on something even slower than this. Right now, I don't know, but
in the future this section will likely have more information. If you have
any specific success or failure stories on older hardware, let me know.

-- Gameplay --

Gameplay should be more or less the same as it always was. Some keys
are changed though:

- Use ctrl + alt + enter to toggle between fullscreen and windowed mode
  (read the disclaimer on this further down!)
- Use F12 to dump the screen to a BMP; this can be done at ANY time.

The default values (speed, volumes, etc) are the same as they were before,
but if you change them in MZX they won't stay that way the next time you
load. To change them permanently, you have to change the config file
(see below).

Password protected worlds are not supported natively. However, if you try
to load one, you will be presented with an option to permanently decrypt
the world and then load it. With that said, password protection is now
100% removed from MZX, and no trace of encryption code exists outside of
the decryption module.

There are a couple discrepencies that break compatability that should be
noted:

- key_pressed and key_code now return unsigned chars instead of signed,
  so if the game checks for negative values, it won't work.
- The same goes for reading back characters for strings.
- Some things that worked in the DOS version only worked due to chance,
  such as there being default (but valid) values for sprite widths or
  heights and thus sprites could be displayed before new values were
  set.

These shouldn't apply to very many games (I know of one.. in the recent
DoZ. The game was already really broken anyway :p)

-- Limitations --

The MZX port removes many limitations of the original. However, some
still remain due to the world format which has not been changed. These
are the changes:

- Boards may now be as large as 32767x32767. Please do not make boards
  this large. :)
- You may now have up to 250 boards.
- Boards may have up to 255 robots, 255 scrolls, and 255 sensors.
- There is no robot memory per board limit. However, individual robots
  may only be up to 64k large. If you include the global robot, this
  means that you effectively can have up to 16MB of robot memory per
  board.
- The same applies to scrolls, which have separate memory spaces and
  may only be up to 64k in length each (so you could have almost
  16MB of scroll text per board, but who would want that??)
- The robot stack need not be initialized, and will be dynamically
  resized as necessary (useful for recursion). This refers to lines
  such as
  . "#*-1-2-3-4-5-6-7-8"
  at the beginning of robots. They're no longer necessary or useful
  (they will be ignored, like any other comment).
- You may have a virtually unlimited number of counters active. The
  theoretical limit is some 4 billion. The effective limit depends on
  memory available.
- The same goes for strings, which may now have any name, so long as
  it begins with a dollar sign ($). The same conventions regarding
  strings in 2.68+ still apply (see 268_info.txt for more information)
- Local2 and local3 no longer have dangerous side-effects. Local4
  through local32 are also available per-robot now.

A warning: I have tried my best to make it impossible to exceed these
limits, however, you may be able to somehow. If you do, don't save the
game. You will probably corrupt it. Just exit.

-- Video --

The port by default runs in a window that is 640x350. It can run fullscreen,
but chances are you won't get 640x350. It's very likely that you'll get
640x400, which only has minor black bars at the top and bottom (I find it to
be entirely satisfactory). If you're not so lucky, you might be limited to
640x480. You can manually specify a resolution in the config file. In fact,
before going into fullscreen, I recommend forcing 640x480 then 640x400. So
far we've experienced temporary monitor problems when trying to go into
640x350 fullscreen for one user - it may be a good idea to force 640x400's
refresh rate using a tool like hztool (win9x) or NVRefresh (win2k+). You
can also set these with PowerStrip, as well as experiment with custom
refresh rates. It is worth trying to add 640x350 and 640x700 in this
utility.

If you don't get 640x400, there might be a remedy to this.. but as of now
I don't know any. I believe that most video cards can handle it, though.
In the cases where you can't, it's probably a driver/OS/configuration issue.

It is also possible to set a multiplier for the height, for the image to be
stretched. Be sure that the multiplication of 350 is within the resolution
chosen or MZX will crash! On my machine, I can run MZX at 640x700 with a 2x
height multiplier and it looks great.

-- Audio --

With this version, many more module formats are playable than compared to
the previous version. The following are natively supported:

XM, S3M, MOD, MED, MTM, STM, IT, 669, ULT, WAV, DSm, FAR, AMS, MDL, OKT,
DMF, PTM, DBM, AMF, MT2, PSM, J2B, and UMX.

Yes, WAVs can be loaded as mods, and although this is not generally
recommended it could be useful sometimes (such as for short musical clips).

GDM is not supported natively. However, if a GDM file is attempted to be
loaded, an attempt will be made to load an alternate .S3M version, and if
it does not exist, one will be created by converting the GDM file.

The same goes for SAM; they will be converted to WAV. Therefore, you can
now use WAV files natively as samples.

It is strongly recommended that you do not include any GDM or SAM files in
distributions of new MZX games; instead include only their conversions.
You cannot load GDM files with alt + N in the editor at all anymore.
However, you can convert SAM files by testing them with alt + L, and you
can convert GDM files by loading them with a robot. Or, you can use an
external convertor.

Audio is always sampled to 16bit, 44KHz. If your computer cannot support
this, then I believe SDL will emulate it, although I'm not 100% certain
(this remains to be seen). If this is the case, you're in dire need of a
new soundcard anyway.

The size of the audio buffer can be changed in the config file. See the
comments therein to determine the affect of this.

-- Editor --

Although quite a lot of the editor has been rewritten from scratch, a
sincere attempt has been made to make it as compatible and similar to the
original as possible. These are the differences:

- You cannot click on help options to make it happen (for instance, you
  can't click on L:Load and expect it to bring up the load window).
- You cannot import or export ANS files. Use MZM instead.
- You can now perform repeated copies by selecting "Copy (repeated)"
  from the block command window. This will cause you to repeat the copy
  indefinitely until you press escape. Also, after the first paste is
  made, you may press ctrl + direction to move in steps that are the
  size of the copy (you really have to try it to get a good idea of what
  I mean)
- Press alt + H to hide/unhide the menu/information occupying the bottom
  6 lines of the screen.
- Right click is similar to pressing insert (grabs whatever's under the
  cursor)
- Exporting char sets now gives direct options to set the size/offset
  for partial charsets. The old format (prefixing the name) will not
  work.
- For saving files, you may make filenames larger and use mixed case
  (as opposed to all caps).
- Now when you import worlds their exits will actually work.
- Loading worlds results in all empty boards and empty
  robots/scrolls/sensors within the boards being removed. When you delete
  a board, you won't be presented with a gap in the board list anymore.
- You may once again select ASCII as a default charset and revert to it
  in the char editor. You may also select a default SMZX charset.
- Anywhere you can enter a line of text you can now press ctrl + left
  and ctrl + right to go to the previous/next word.
- This isn't totally limited to the editor, but now everywhere a
  selection box shows up (such as for files, boards, items) you can
  press multiple keys to seek to a specific entry. Furthermore, in
  file selection boxes you can press backspace to go up a directory.

- The SMZX char editor has been changed quite a bit. First, to use, you
  must be in SMZX modes 1-3 (toggle using F11).
  Within the editor, press keys 1 through 4 to change the "current color."
  You can place this color with space, and you can toggle repeated
  placement on/off using tab (sorry, no clear/toggle in this mode, they
  got in the way far more than they helped).
  You now move in increments of 1 char naturally instead of "half chars."
  Right click grabs the current "color" underneath the cursor.

- The robotic editor has been rewritten from scratch and is therefore
  quite different. Some options do not appear in the help at the bottom
  (not enough room), so refer here for information:

  You are now able to type invalid code within a robotic line. You will
  see that it's invalid due to the way the line is color coded. If you
  try to escape while any lines are invalid or if you press alt + V, a
  window will be brought up describing the nature of all erroneous lines.
  It will also let you mark each line to be deleted or commented out on
  exit. If all invalid lines are marked with anything besides ignore,
  you can exit safely. You may also mark invalid lines using ctrl + I, D,
  and C (to mark as ignore, delete, and comment respectively).

  ctrl + C may also be used to comment out a normal line, and then
  uncomment.

  alt + O is still available, but you may only change macros here (see
  the config file for the other rarely used options). This does give
  you more room to modify macros, though. They may be up to 64 characters
  in length, and you may set up to around 45 or so in this window. (To
  get larger, you'll have to use the config file.)

  There are some slight discrepencies in robot size; if you highlight the
  last line then leave it it will register as a compilation of that line.
  Yet, when you exit, the line will be discarded, so this addition is not
  permanent. This shouldn't be problematic.

  alt + enter and alt + escape no longer work; use the alternatives
  (alt + b and alt + u)

-- Config File --

The config file is named config.txt and is a plain-text file that is
intended to be edited in a text editor. All information about it and
options are described in the file itself. It's a good idea to keep a
backup of it in case you want to be made aware of the defaults again,
but if you simply delete the file these defaults will be used.

You may also set config file options at commandline. Note that you
may not use whitespace at all here (if you do, different words will
be counted as separate options). For instance, you may run from
command line:

mzx280 startup_file=test.mzx mzx_speed=7

To start MZX with test.mzx at speed 7.

It's probably worth the time of any new user to check out the config
file options.

-- Misc --

The default char sets for MZX, SMZX, ASCII, and even blank are stored
as actual charsets in the same directory as MZX (mzx_default.chr,
mzx_smzx.chr, mzx_ascii.chr, and mzx_blank.chr respectively). They
are not read-only by default, but you may want to make them so. Don't
change them unless you know what you're doing.

See build.txt for information about building from source.

-- Known Bugs --

As of this release I don't KNOW of any bugs, and in general I don't
make a habit of releasing something when I know of specific bugs. Since
I wrote much of the code and have a good understanding of virtually all
of it, and because it's much easier to debug outside of DOS, chances are
I should be able to fix any bugs that crop up.

-- Bug Reporting Procedure --

If you find a bug, report it on DigitalMZX (there will be a special
pinned thread for this) or e-mail me at exophase@adelphia.net. Here are
some guidelines to consider:

- Describe exactly what is happening to you. Do not attempt to diagnose
  the nature of the bug, because you may be wrong, and this could throw
  me off significantly.
- I may ask for you to then send the world file where this is happening,
  or even better, a save file.
- Include directions of how to reproduce the bug. If the bug doesn't
  happen every time, try to find out what is causing it some of the time
  and reproduce it regularly.
- If possible, it would be very helpful if you were to create a new world
  which synthesizes the bug in as little code as possible. This may
  require some debugging of your own on the game in question to find out
  exactly what's not working.

Please do NOT make reports such as:

"HELP ME MZX IS CRASHING HELP THIS SUCKS"

Because they won't help anything.

-- Credits --

Main author: Exophase (Gilead Kutnick, exophase@adelphia.net)

Original MZX base code: Gregory Janson

Additional MZX contributions: Spider124, MenTaLguY, CapnKev, JZig,
  madbrain, Akwende, Koji

(I'd also like to thank MenTaLguY for idput.cpp, the first converted
 piece of MZX's code base, which has been included in the DOS build
 since version 2.51s3)

Original SAM2WAV code: madbrain

GDM2S3M library code: ajs

Default SMZX charset: LogiCow

Beta Testers:
  Wervyn
  Quasar84
  Terryn
  asgromo

I'd really like to give a special thanks to my beta testers,
especially Terryn. They really worked very hard in not only finding
bugs but helping crush them. If not for them, the port would have
never progressed at all. They were very patient and hardworking
throughout this whole ordeal.


code:
Chests       : Never
Locks        : Never
Other Items  : Pushed
Slime Blobs  : Never
Sharks       : Never
Dragons      : Never
Runners      : Pushed/Willing
All Guns     : Never
Other Foes   : Pushed
Robots       : Willing (Pushed if pushable)
Mines        : Never
Sensors      : Pushed/Willing
Missiles     : Never
Seekers      : Pushed
Bullets      : Never
Spitfires    : Never
Scrolls      : Pushed
MovingWalls  : Willing
Boulders     : Pushed
Boxes        : Pushed
Crates       : Pushed
CustomBoxes  : Pushed
CustomPushes : Pushed
Pushers      : Never

NOTES:

-Whatever can be pushed can be pushed through a transporter as well.
~"Willing" means they went through the transporter through natural behavior (most things) or were directed through Robotic to go through (only applies to Robots and sensors).
~Nonhostile fish and invincible ghosts can only be pushed indirectly, not directly by the player. Current cannot force fish through transporters.
~Sliders cannot traverse lava or goop.


code:
Name:		megazeux
Version:	2.84
Release:	1%{?dist}

Summary:	A simple game creation system (GCS)

Group:		Amusements/Games
License:	GPLv2+
URL:		http://digitalmzx.net/
Source:		megazeux-2.84.tar.bz2
BuildRoot:	%{_tmppath}/%{name}-%{version}-%{release}-root

BuildRequires:	SDL-devel
BuildRequires:	libvorbis-devel
BuildRequires:	libpng-devel
BuildRequires:	zlib-devel

%description

MegaZeux is a Game Creation System (GCS), inspired by Epic MegaGames' ZZT,
first released by Gregory Janson in 1994. It was recently ported from 16bit
MSDOS C/ASM to portable SDL C/C++, improving its platform support and
hardware compatibility.

Many features have been added since the original DOS version, and with the
help of an intuitive editor and a simple but powerful object-oriented
programming language, MegaZeux allows you to create your own ANSI-esque games
regardless of genre. It is actively maintained by a thriving community.

See http://digitalmzx.net/ for more information.

%prep
%setup -q

%build
./config.sh --platform unix --as-needed-hack \
            --enable-release
%{__make}

%install
rm -rf "$RPM_BUILD_ROOT"
make install DESTDIR=${RPM_BUILD_ROOT}

%clean
rm -rf "$RPM_BUILD_ROOT"

%files
%defattr(-,root,root,-)
%doc docs/changelog.txt docs/port.txt docs/macro.txt
%{_bindir}/
%{_prefix}/games
%{_libdir}/megazeux
%{_datadir}/megazeux
%{_datadir}/icons/megazeux.png
%{_sysconfdir}/megazeux-config

%changelog
* Sat Jun 02 2012 Alistair John Strachan <alistair@devzero.co.uk> 2.84-1
- new upstream version

* Sat Nov 26 2009 Alistair John Strachan <alistair@devzero.co.uk> 2.83-1
- new upstream version

* Thu Nov 27 2008 Alistair John Strachan <alistair@devzero.co.uk> 2.82b-1
- initial RPM release


code:
These scripts probably only work for me, but you might find them useful
to adapt. They basically allow me to use a variety of cross compilers to build
MZX for multiple non-Linux platforms, on Linux. This greatly speeds up the
building of new release binaries.

The deps/ folder contains some binaries for darwin, windows, nds and wii which
aren't included in the MegaZeux tree for various licensing reasons. They're
necessary to build binaries for these platforms.

--ajs.

path: scripts/README


code:
platform_enter_hook() {
	export PATH=$HOME/bin/amiga/bin:/usr/local/amiga/SDK/local/clib2/bin:$PATH

	BUILD_FLAGS="debuglink"
	CONFIG_FLAGS="$CONFIG_FLAGS --platform amiga \
	              --prefix /usr/local/amiga --disable-libpng \
	              --disable-utils"
}

platform_exit_hook() {
	DUMMY=1
}

platform_build_test_hook() {
	if [ ! -f mzxrun.exe -o ! -f megazeux.exe ]; then
		ERRNO=1
		return
	fi

	file mzxrun.exe | egrep -q "ELF 32-bit.*MSB.*PowerPC.*dynamically"
	if [ "$?" != "0" ]; then
		ERRNO=1
		return
	fi

	file megazeux.exe | egrep -q "ELF 32-bit.*MSB.*PowerPC.*dynamically"
	if [ "$?" != "0" ]; then
		ERRNO=1
		return
	fi
}

platform_archive_test_hook() {
	[ ! -f build/dist/amiga/*amiga.lha ] && ERRNO=2
}


code:
#!/bin/sh

if [ "$1" = "" -o "$2" = "" ]; then
	echo "usage: $0 <datestr> <revision> <outdir> [branch]"
	exit 0
fi

DATE=$1
shift

REVISION=$1
shift

GITBASE=$HOME/megazeux

if [ "$2" = "" ]; then
	OUTDIR=$1/trunk-$DATE-$REVISION
else
	OUTDIR=$1/$2-$DATE-$REVISION
fi

if [ ! -d $GITBASE ]; then
	echo "Could not find specified Git basedir, aborting."
	exit 1
fi

[ -d "$OUTDIR" ] && rm -rf $OUTDIR
mkdir -p $OUTDIR/source

pushd $GITBASE >/dev/null

git reset --hard $REVISION >/dev/null 2>&1
if [ "$?" != "0" ]; then
	echo "git reset --hard failed; aborting."
	exit 1
fi

rm -rf build
make source >/dev/null 2>&1

SRCPKG=$GITBASE/build/dist/source/*.tar.xz
if [ -f "$SRCPKG" ]; then
	echo "Failed to compile source package; aborting."
	exit 2
fi

[ -d /tmp/megazeux ] && rm -rf /tmp/megazeux
mkdir /tmp/megazeux

for PLATFORM in amiga gp2x nds psp wii windows-x86 windows-x64; do
	tar -C/tmp/megazeux -xf $SRCPKG

	pushd /tmp/megazeux/mzx* >/dev/null
	$GITBASE/scripts/build.sh $PLATFORM $PWD >/dev/null 2>&1

	if [ -d build/dist/$PLATFORM ]; then
		mv build/dist/$PLATFORM /tmp/megazeux
	else
		mkdir /tmp/megazeux/$PLATFORM
	fi

	mv build/logs/$PLATFORM/* /tmp/megazeux/$PLATFORM

	popd >/dev/null

	rm -rf /tmp/megazeux/mzx*
done

pushd /tmp/megazeux >/dev/null

export CONCURRENCY_LEVEL=3

mkdir ubuntu

for CHROOT in ubuntu-i386 ubuntu-amd64; do
	tar -xf $SRCPKG
	MZX=`echo mzx* | sed 's,^mzx,megazeux-,' | sed 's,-2,-2.,'`
	mv mzx* $MZX

	pushd $MZX >/dev/null
	dchroot -d -c $CHROOT -- \
		debuild --preserve-envvar=CONFIG_FLAGS -us -uc >/dev/null 2>&1
	popd >/dev/null

	rm -rf $MZX
	mv megazeux* ubuntu
done

popd >/dev/null

mv $SRCPKG $OUTDIR/source
rm -rf build

mv /tmp/megazeux/* $OUTDIR
rm -rf /tmp/megazeux

popd >/dev/null


code:
#!/bin/sh

if [ "$1" = "" ]; then
	echo "usage: $0 <platform> [<sourcedir>]"
	exit 0
else
	PLATFORM="$1"
	shift
fi

BASEDIR=`dirname $0`

if [ ! -f "$BASEDIR/$PLATFORM.sh" ]; then
	echo "Unknown port: $PLATFORM"
	exit 0
fi

. "$BASEDIR/global.sh"
. "$BASEDIR/$PLATFORM.sh"

if [ "$1" = "" ]; then
	pushd $HOME/megazeux >/dev/null
else
	pushd $1 >/dev/null
	shift
fi

LOGDIR=build/logs/$PLATFORM
rm -rf build/$PLATFORM build/dist/$PLATFORM $LOGDIR
mkdir -p $LOGDIR

export ERRNO=0

platform_enter_hook

./config.sh $CONFIG_FLAGS 2>&1 | tee $LOGDIR/config.log

make -j3 $BUILD_FLAGS 2>&1 | tee $LOGDIR/build.log
platform_build_test_hook

if [ "$ERRNO" = "0" ]; then
	make archive 2>&1 | tee $LOGDIR/archive.log
	platform_archive_test_hook

	if [ "$ERRNO" != "0" ]; then
		echo "Archive test failed, aborting.."
	fi
else
	echo "Build test failed, aborting.."
fi

make distclean >/dev/null 2>&1
platform_exit_hook

popd >/dev/null

exit $ERRNO


code:
platform_enter_hook() {
	BUILD_FLAGS="dist"
	CONFIG_FLAGS="$CONFIG_FLAGS --platform darwin \
	              --prefix blah --disable-utils --disable-x11"
}

platform_exit_hook() {
        DUMMY=1
}

platform_build_test_hook() {
        if [ ! -f megazeux -o ! -f mzxrun ]; then
                ERRNO=1
                return
        fi

        file megazeux | egrep -q "Mach-O universal binary"
        if [ "$?" != "0" ]; then
                ERRNO=1
                return
        fi

        file mzxrun | egrep -q "Mach-O universal binary"
        if [ "$?" != "0" ]; then
                ERRNO=1
                return
        fi
}

platform_archive_test_hook() {
        [ ! -f build/dist/darwin/*.dmg ] && ERRNO=2
}


code:
#
# All platform builds inherit these flags
#
CONFIG_FLAGS="--enable-release $CONFIG_FLAGS"


code:
platform_enter_hook() {
	export PATH=$HOME/bin/open2x/gcc-4.1.1-glibc-2.3.6/arm-open2x-linux/bin:$PATH

	BUILD_FLAGS="debuglink"
	CONFIG_FLAGS="$CONFIG_FLAGS --platform gp2x \
	              --prefix $HOME/bin/open2x/gcc-4.1.1-glibc-2.3.6/arm-open2x-linux \
	              --optimize-size --disable-editor --disable-helpsys
	              --disable-utils --enable-mikmod --enable-meter"
}

platform_exit_hook() {
	DUMMY=1
}

platform_build_test_hook() {
	if [ ! -f mzxrun.gpe ]; then
		ERRNO=1
		return
	fi

	file mzxrun.gpe | egrep -q "ELF 32-bit.*LSB.*ARM.*statically"
	if [ "$?" != "0" ]; then
		ERRNO=1
		return
	fi
}

platform_archive_test_hook() {
	[ ! -f build/dist/gp2x/*gp2x.zip ] && ERRNO=2
}


code:
platform_enter_hook() {
	pushd arch/nds >/dev/null
		unzip -qq $HOME/megazeux/scripts/deps/nds.zip
	popd >/dev/null

	export DEVKITPRO=$HOME/bin/devkitpro
	export DEVKITARM=$HOME/bin/devkitpro/devkitARM
	export PATH=$DEVKITARM/bin:$PATH

	BUILD_FLAGS="debuglink"
	CONFIG_FLAGS="$CONFIG_FLAGS --platform nds --prefix $DEVKITARM \
	              --optimize-size --disable-editor --disable-helpsys \
	              --disable-utils --disable-libpng --enable-meter"
}

platform_exit_hook() {
	rm -rf arch/nds/ndsLibfat arch/nds/ndsDebug
	rm -rf arch/nds/ndsScreens/build arch/nds/ndsScreens/lib
}

platform_build_test_hook() {
	if [ ! -f mzxrun ]; then
		ERRNO=1
		return
	fi

	file mzxrun | egrep -q "ELF 32-bit.*LSB.*ARM.*statically"
	if [ "$?" != "0" ]; then
		ERRNO=1
		return
	fi
}

platform_archive_test_hook() {
	[ ! -f build/dist/nds/*nds.zip ] && ERRNO=2
}


code:
platform_enter_hook() {
	export DEVKITPRO=$HOME/bin/devkitpro
	export DEVKITPSP=$HOME/bin/devkitpro/devkitPSP
	export PATH=$DEVKITPSP/bin:$DEVKITPSP/psp/bin:$PATH

	BUILD_FLAGS="debuglink"
	CONFIG_FLAGS="$CONFIG_FLAGS --platform psp --prefix $DEVKITPSP/psp \
	              --optimize-size --disable-editor --disable-helpsys \
	              --disable-utils --disable-libpng --enable-meter"
}

platform_exit_hook() {
	DUMMY=1
}

platform_build_test_hook() {
	if [ ! -f mzxrun ]; then
		ERRNO=1
		return
	fi

	file mzxrun | egrep -q "ELF 32-bit.*LSB.*MIPS.*statically"
	if [ "$?" != "0" ]; then
		ERRNO=1
		return
	fi
}

platform_archive_test_hook() {
	[ ! -f build/dist/psp/*psp.zip ] && ERRNO=2
}


code:
platform_enter_hook() {
	pushd arch/wii >/dev/null
		unzip -qq $HOME/megazeux/scripts/deps/wii.zip
	popd >/dev/null

	export DEVKITPRO=$HOME/bin/devkitpro
	export DEVKITPPC=$HOME/bin/devkitpro/devkitPPC
	export PATH=$DEVKITPPC/bin:$PATH

	BUILD_FLAGS="debuglink"
	CONFIG_FLAGS="$CONFIG_FLAGS --platform wii --prefix $DEVKITPPC \
	              --optimize-size --disable-utils --disable-libpng \
	              --enable-meter"
}

platform_exit_hook() {
	rm -rf arch/wii/{libfat,libogg,libvorbis}
}

platform_build_test_hook() {
	if [ ! -f mzxrun -o ! -f megazeux ]; then
		ERRNO=1
		return
	fi

	file mzxrun | egrep -q "ELF 32-bit.*MSB.*PowerPC.*statically"
	if [ "$?" != "0" ]; then
		ERRNO=1
		return
	fi

	file megazeux | egrep -q "ELF 32-bit.*MSB.*PowerPC.*statically"
	if [ "$?" != "0" ]; then
		ERRNO=1
		return
	fi
}

platform_archive_test_hook() {
	[ ! -f build/dist/wii/*wii.zip ] && ERRNO=2
}


code:
platform_enter_hook() {
	export PATH=$HOME/bin/mingw64/bin:$HOME/bin/mingw64/local/bin:$PATH

	BUILD_FLAGS="debuglink"
	CONFIG_FLAGS="$CONFIG_FLAGS --platform mingw64 \
	              --prefix $HOME/bin/mingw64"
}

platform_exit_hook() {
	DUMMY=1
}

platform_build_test_hook() {
	if [ ! -f mzxrun.exe -o ! -f megazeux.exe ]; then
		ERRNO=1
		return
	fi

	file mzxrun.exe | egrep -q "PE32\+.*MS.Windows"
	if [ "$?" != "0" ]; then
		ERRNO=1
		return
	fi

	file megazeux.exe | egrep -q "PE32\+.*MS.Windows"
	if [ "$?" != "0" ]; then
		ERRNO=1
		return
	fi
}

platform_archive_test_hook() {
	[ ! -f build/dist/windows-x64/*-x64.zip ] && ERRNO=2
}


code:
platform_enter_hook() {
	export PATH=$HOME/bin/mingw32/bin:$PATH

	BUILD_FLAGS="debuglink"
	CONFIG_FLAGS="$CONFIG_FLAGS --platform mingw32 \
	              --prefix $HOME/bin/mingw32"
}

platform_exit_hook() {
	DUMMY=1
}

platform_build_test_hook() {
	if [ ! -f mzxrun.exe -o ! -f megazeux.exe ]; then
		ERRNO=1
		return
	fi

	file mzxrun.exe | egrep -q "PE32.*Intel.80386.*MS.Windows"
	if [ "$?" != "0" ]; then
		ERRNO=1
		return
	fi

	file megazeux.exe | egrep -q "PE32.*Intel.80386.*MS.Windows"
	if [ "$?" != "0" ]; then
		ERRNO=1
		return
	fi
}

platform_archive_test_hook() {
	[ ! -f build/dist/windows-x86/*-x86.zip ] && ERRNO=2
}


code:
#!/bin/sh

if [ "$1" == "" ]; then
	echo "usage: $0 zipfile"
	exit 0
fi

SRCZIP=$PWD/$1
shift

[ -d /tmp/split ] && rm -rf /tmp/split
mkdir -p /tmp/split/debug
mkdir -p /tmp/split/release

cd /tmp/split/debug
unzip $SRCZIP *.debug manifest.txt
7za -tzip a $SRCZIP.debug *

cd /tmp/split/release
rm -rf /tmp/split/debug

unzip $SRCZIP
egrep -v ".debug$" manifest.txt >manifest.txt.new
mv manifest.txt.new manifest.txt
find -name "*.debug" -exec rm '{}' ';'
7za -tzip a $SRCZIP.release *

rm -rf /tmp/split


code:
##
# MegaZeux Makefile fragment
##

include contrib/gdm2s3m/src/Makefile.in
include contrib/icons/Makefile.in
include contrib/libmodplug/src/Makefile.in

.PHONY: mzx_clean core_target_clean

LINK_CC := ${CC}

core_src = src
core_obj = src/.build

network_src = src/network
network_obj = src/network/.build

core_flags   += -ffast-math -funsigned-char
core_flags   += -Wmissing-format-attribute -Wpointer-arith
core_flags   += -Wwrite-strings
core_cflags  += ${CFLAGS} -Wmissing-prototypes
core_cxxflags = ${CXXFLAGS} -DHAVE_INTTYPES_H

core_flags   += -I${core_src} -I${PREFIX}/include
core_ldflags := -lm ${core_ldflags}

ifeq (${PLATFORM},mingw)
core_spec := -DCORE_LIBSPEC="__declspec(dllexport)"
endif

${core_obj}/main.o: ${core_src}/main.c
	$(if ${V},,@echo "  CC      " $<)
	${CC} -MD ${core_cflags} ${core_flags} -c $< -o $@

${core_obj}/run_stubs.o: ${core_src}/run_stubs.c
	$(if ${V},,@echo "  CC      " $<)
	${CC} -MD ${core_cflags} ${core_flags} -c $< -o $@

${core_obj}/updater.o: ${core_src}/updater.c
	$(if ${V},,@echo "  CC      " $<)
	${CC} -MD ${core_cflags} ${core_flags} -c $< -o $@

${network_obj}/%.o: ${network_src}/%.c
	$(if ${V},,@echo "  CC      " $<)
	${CC} -MD ${core_cflags} ${core_flags} ${core_spec} -c $< -o $@

${core_obj}/%.o: ${core_src}/%.c
	$(if ${V},,@echo "  CC      " $<)
	${CC} -MD ${core_cflags} ${core_flags} ${core_spec} -c $< -o $@

${core_obj}/%.o: ${core_src}/%.cpp
	$(if ${V},,@echo "  CXX     " $<)
	${CXX} -MD ${core_cxxflags} ${core_flags} ${core_spec} -c $< -o $@

#
# Lists mandatory C language sources (mangled to object names) required
# to build the main binary. Please keep this sorted alphabetically.
#
core_cobjs := \
  ${core_obj}/board.o ${core_obj}/configure.o ${core_obj}/counter.o  \
  ${core_obj}/data.o ${core_obj}/error.o ${core_obj}/event.o         \
  ${core_obj}/expr.o ${core_obj}/fsafeopen.o ${core_obj}/game2.o     \
  ${core_obj}/game.o ${core_obj}/graphics.o ${core_obj}/idarray.o    \
  ${core_obj}/idput.o ${core_obj}/intake.o ${core_obj}/legacy_rasm.o \
  ${core_obj}/mzm.o ${core_obj}/render.o ${core_obj}/robot.o         \
  ${core_obj}/run_robot.o ${core_obj}/scrdisp.o ${core_obj}/sfx.o    \
  ${core_obj}/sprite.o ${core_obj}/util.o ${core_obj}/validation.o   \
  ${core_obj}/window.o ${core_obj}/world.o

#
# Lists mandatory C++ language sources (mangled to object names) required
# to build the main binary. Currently there are only optional sources.
#
core_cxxobjs :=

#
# Hack to avoid silly warnings from devkitPro headers
#
ifeq ($(or ${BUILD_WII},${BUILD_NDS},${BUILD_PSP}),)
core_cflags += -Wstrict-prototypes
endif

#
# Hack to avoid silly warnings from Android headers
#
ifeq (${PLATFORM},android)
core_cflags += -Wno-strict-prototypes
endif

#
# These are really just hacks and should be moved elsewhere
#
ifeq (${BUILD_NDS},1)
core_cobjs += arch/nds/ram.o arch/nds/exception.o
core_cobjs += arch/nds/dlmalloc.o
core_cobjs += arch/nds/platform.o arch/nds/event.o
core_cobjs += arch/nds/render.o arch/nds/evq.o
ifneq (${BUILD_DEBYTECODE},1)
core_cobjs += arch/nds/extmem.o
endif
endif

ifeq (${PLATFORM},android)
core_cxxobjs += arch/android/sfwrapper.o
LINK_CC := ${CXX}
endif

ifeq (${BUILD_WII},1)
core_cobjs += arch/wii/event.o arch/wii/platform.o
ifeq (${BUILD_AUDIO},1)
core_cobjs += arch/wii/audio.o
endif
endif

#
# Other modular stuff
#

ifeq (${BUILD_HELPSYS},1)
core_cobjs += ${core_obj}/helpsys.o
endif

ifeq (${BUILD_RENDER_SOFT},1)
core_cobjs += ${core_obj}/render_soft.o
endif

# GL shared
ifneq ($(or ${BUILD_RENDER_GL_FIXED},${BUILD_RENDER_GL_PROGRAM}),)
core_cobjs += ${core_obj}/render_gl.o
endif

# Fixed function renderers (OGL=1, OGLES=1)
ifeq (${BUILD_RENDER_GL_FIXED},1)
core_cobjs += ${core_obj}/render_gl1.o ${core_obj}/render_gl2.o
endif

# Shader renderers (OGL>=2, OGLES=2)
ifeq (${BUILD_RENDER_GL_PROGRAM},1)
core_cobjs += ${core_obj}/render_glsl.o
endif

#
# Currently only usable with GL, but could theoretically be used
# with OpenVG in the future.
#
ifeq (${BUILD_EGL},1)
core_cobjs += ${core_obj}/render_egl.o
core_ldflags := -lEGL ${core_ldflags}
ifneq (${X11DIR},)
core_flags += -I${X11DIR}/../include
core_ldflags := -L${X11DIR}/../${RAWLIBDIR} -lX11 ${core_ldflags}
endif
endif

ifeq (${BUILD_RENDER_YUV},1)
core_cobjs += ${core_obj}/render_yuv.o
core_cobjs += ${core_obj}/render_yuv1.o ${core_obj}/render_yuv2.o
endif

ifeq (${BUILD_RENDER_GP2X},1)
core_cobjs += ${core_obj}/render_gp2x.o
endif

ifeq (${BUILD_RENDER_GX},1)
core_cobjs += ${core_obj}/render_gx.o
endif

ifeq (${BUILD_MODPLUG},1)
core_cflags += -I${gdm2s3m_src}
core_cobjs += ${gdm2s3m_objs}
core_flags += -I${libmodplug_src} -I${libmodplug_src}/libmodplug
core_cxxobjs += ${core_obj}/audio_modplug.o ${libmodplug_objs}
LINK_CC := ${CXX}
endif

ifeq (${BUILD_MIKMOD},1)
core_ldflags := ${MIKMOD_LDFLAGS} ${core_ldflags}
core_cobjs += ${core_obj}/audio_mikmod.o
endif

ifeq (${LIBPNG},1)
core_flags += ${LIBPNG_CFLAGS} -DNEED_PNG_WRITE_SCREEN
core_ldflags := ${LIBPNG_LDFLAGS} ${core_ldflags}
core_cobjs += ${core_obj}/pngops.o
endif

ifeq (${BUILD_AUDIO},1)
core_cobjs += ${core_obj}/audio.o
core_flags += ${VORBIS_CFLAGS}
core_ldflags := ${VORBIS_LDFLAGS} ${core_ldflags}
endif

ifeq (${BUILD_SDL},1)

core_cobjs += ${core_obj}/event_sdl.o ${core_obj}/platform_sdl.o
core_cobjs += ${core_obj}/render_sdl.o

ifeq (${BUILD_AUDIO},1)
core_cobjs += ${core_obj}/audio_sdl.o
endif

core_flags   += ${SDL_CFLAGS}
core_ldflags += ${SDL_LDFLAGS}

ifeq (${BUILD_MODULAR},1)
mzx_ldflags    += ${SDL_LDFLAGS}
mzxrun_ldflags += ${SDL_LDFLAGS}
endif

else

ifeq ($(or ${BUILD_WII},${BUILD_NDS}),)

core_cobjs += ${core_obj}/platform_dummy.o

#
# Normally SDL would provide us with pthread, but in the case
# we're not using SDL or any other platform mutex implementation,
# we must link pthread ourselves.
#
ifeq (${PTHREAD},1)
core_ldflags := ${PTHREAD_LDFLAGS} ${core_ldflags}
endif

endif

endif

ifeq (${BUILD_NETWORK},1)

core_cflags += ${ZLIB_CFLAGS}
core_ldflags := ${ZLIB_LDFLAGS} ${core_ldflags}

core_cobjs += ${network_obj}/host.o ${network_obj}/manifest.o
core_cobjs += ${network_obj}/network.o ${network_obj}/sha256.o

ifeq (${BUILD_UPDATER},1)
mzx_objs += ${core_obj}/updater.o
endif

ifeq (${PLATFORM},amiga)
core_ldflags := ${core_ldflags} -lnet
endif

endif

ifeq (${BUILD_DEBYTECODE},1)
core_cobjs += ${core_obj}/rasm.o
endif

core_objs := ${core_cobjs} ${core_cxxobjs}

-include ${core_objs:.o=.d}

${core_objs}: $(filter-out $(wildcard ${core_obj}), ${core_obj})
${core_objs}: $(filter-out $(wildcard ${network_obj}), ${network_obj})

ifeq (${BUILD_MODULAR},1)

core_target := ${DSOPRE}core${DSOPOST}

${core_target}: ${core_objs}
	$(if ${V},,@echo "  LINK    " $@)
	${LINK_CC} ${DSOLDFLAGS} -o $@ ${core_objs} ${LDFLAGS} \
	  ${DSOSONAME}$@ ${core_ldflags}

core_target_clean:
	$(if ${V},,@echo "  RM      " ${core_target} ${core_target}.debug)
	${RM} ${core_target} ${core_target}.debug

else

core_target := ${core_objs}

core_target_clean:

endif

ifeq (${BUILD_EDITOR},1)

include src/editor/Makefile.in

mzx_objs := ${mzx_objs} ${core_obj}/main.o

ifeq (${PLATFORM},darwin)
mzx_objs += arch/darwin/SDLMain.o
mzx_ldflags += -framework Cocoa
endif

-include ${mzx_objs:.o=.d}

ifeq (${EMBED_ICONS},1)
mzx_objs += ${icons}
endif

ifeq (${BUILD_MODULAR},1)
${mzx}.debug: ${core_target}.debug ${editor_target}.debug
endif

${mzx}: ${core_target} ${editor_target} ${mzx_objs}
	$(if ${V},,@echo "  LINK    " ${mzx})
ifeq (${BUILD_MODULAR},1)
	${CC} ${mzx_objs} -o ${mzx} ${ARCH_EXE_LDFLAGS} ${LDFLAGS} \
	  ${DSORPATH} -L. -lcore -leditor \
	  ${mzx_ldflags}
else
	${LINK_CC} ${mzx_objs} ${core_target} ${editor_target} \
	  -o ${mzx} ${ARCH_EXE_LDFLAGS} ${LDFLAGS} \
	  ${core_ldflags} ${editor_ldflags}
endif

mzx_clean: editor_clean

else

.PHONY: ${mzx}.debug
${mzx}:
${mzx}.debug:

endif

ifeq (${BUILD_MZXRUN},1)

mzxrun_objs := ${core_obj}/main.o ${core_obj}/run_stubs.o

ifeq (${PLATFORM},darwin)
mzxrun_objs += arch/darwin/SDLMain.o
mzxrun_ldflags += -framework Cocoa
endif

-include ${mzxrun_objs:.o=.d}

ifeq (${EMBED_ICONS},1)
mzxrun_objs += ${icons}
endif

ifeq (${BUILD_MODULAR},1)
${mzxrun}.debug: ${core_target}.debug
endif

${mzxrun}: ${core_target} ${mzxrun_objs}
	$(if ${V},,@echo "  LINK    " ${mzxrun})
ifeq (${BUILD_MODULAR},1)
	${CC} ${mzxrun_objs} -o ${mzxrun} ${ARCH_EXE_LDFLAGS} ${LDFLAGS} \
	  ${DSORPATH} -L. -lcore ${mzxrun_ldflags}
else
	${LINK_CC} ${mzxrun_objs} ${core_target} \
	  -o ${mzxrun} ${ARCH_EXE_LDFLAGS} ${LDFLAGS} ${core_ldflags}
endif

else

.PHONY: ${mzxrun}.debug
${mzxrun}:
${mzxrun}.debug:

endif

mzx_clean: core_target_clean gdm2s3m_clean icons_clean libmodplug_clean
	$(if ${V},,@echo "  RM      " ${core_obj} ${network_obj})
	${RM} -r ${core_obj} ${network_obj}
	$(if ${V},,@echo "  RM      " ${mzxrun} ${mzxrun}.debug)
	${RM} ${mzxrun} ${mzxrun}.debug
	$(if ${V},,@echo "  RM      " ${mzx} ${mzx}.debug)
	${RM} ${mzx} ${mzx}.debug