PZX: Difference between revisions

From MZXWiki
Jump to navigation Jump to search
(Made a page for you to work on, zzo.)
 
(Merged from old page.)
Line 1: Line 1:
'''PZX''' (which stands for something-zeux) is a fork of MZX written by [[zzo38]] that focuses primarily on adding support for [http://en.wikipedia.org/wiki/Forth_(programming_language) FORTH], a low-level, stack-driven programming language.
'''PZX''', or ProngZeux, is a fork of [[MegaZeux]] written by [[zzo38]] that focuses primarily on support for [http://en.wikipedia.org/wiki/Forth_(programming_language) FORTH], a low-level, stack-driven programming language.


==Features==
==Features==
PZX includes the following changes and additions to the mainline code base.
The biggest contribution of this particular fork is FORTH support.  Other changes include the ability to use the old ALT+D function in the editor (only zzo38 seems to remember what this is or use the function to begin with), deferred expressions, extended kinds, new overlay modes and SMZX modes of dubious utility (including the one that draws overlay on the outside of the viewport instead of inside, one that draws only the overlay and not the board, an SMZX mode that uses 16 colors per character (reducing the resolution per character to 4x7), and a blinking text mode), meanings for the other bits in lava_walk, and displacement overlay modes which allow adjustment of the overlay by individual pixels.


===FORTH Programs===
zzo38 also corrected a long standing, esoteric bug in the handling of built-in spider webs, which has been merged (with changes) into the existing codebase.
This would be an excellent place to explain how to use Forth with MZX in as much detail as possible.


===Extra Overlay and SMZX Modes===
To make backward compatibility, the way it works, is if the first line of the global robot is a comment with a greater than sign at beginning (optionally followed by a filename), it will activate PZX mode. If there is a filename, that is the file containing the Forth codes.
There's one that causes text to blink, at first;
 
A mode with 16-color characters;
===Deferred Expressions===
A mode that only shows the overlay,
A deferred expression is sort of like having function calls for calling another expression. The operator <tt>,</tt> sets the current parameter value to the left side and then evaluates the right side, the operator <tt>p</tt> gets the current parameter, and the operator <tt>`</tt> allows you to use a deferred expression.
And one that draws outside the field of play.
 
And finally, in the vein of [[Logicow]],
Because parentheses are used to evaluate expression, it uses square brackets to mean a deferred expression. It will convert <tt>[]</tt> to <tt>()</tt> when accessing a deferred expression.
There's pixel displaced drawing, ZOMG wow!
 
The <tt>`</tt> operator is two of <tt>`</tt> with the name of string in between (including the dollar sign), and it call the deferred expression. You can also use <tt>`</tt> operator with <tt>*</tt> followed by a Forth word instead of a string, in which case it will instead call that Forth word to determine the value of the expression.


===Extended Kinds===
===Extended Kinds===
Inquiring minds want to know if this means support for floating point arithmetic (a good idea but non-trivial to implement correctly) or just differently sized integers (a bad idea in general).
You can create extended kinds 0x80 to 0xFE (128 to 254) using Forth codes.


===Deferred Expressions===
In order to create a extended kind you must indicate:
What is this?  The ability to store an expression in a string and evaluate it later?
* The number assigned to it
* The character used to represent it (255 means use the parameter, like a CustomBlock does, and negative number mean various other things)
* The A_ flags associated with it
* How the parameter is decided (the parameter type can come from any built-in)
* The name
And then you can optionally define events for it, such as what happens when it is shot, updated, touched by the player, underneath the player, and so on. Which events are used depends on the A_ flags, although it is possible to have A_ flags without the corresponding events (for example, the simplest way to prevent the player from pushing something that is normally pushable is to give the object the A_ITEM flag without a corresponding event).
 
Some new A_ flags have been implemented:
* A_BREAKABLE
* A_USERFLAG
* A_CRUSH
* A_INVISIBLE
* A_ELEMENT (3 bits, and in Forth codes you use AE_WATER and so on instead of typing A_ELEMENT)
 
===Overlay Modes===
Mode 4 makes it draw the overlay outside of the viewport instead of on the inside of the viewport.
 
Mode 65 and 66 makes it to not draw the board, and only draw the overlay. (This feature actually already existed in MegaZeux, but there was previously no access to it during the game.)
 
Mode 0x7? prevents it from drawing anything at all, allowing Forth codes direct access to the text_video.


===Other Minor Things===
There are also displacement overlay modes 0xA?, 0xB?, 0xE?, which allows pixel-accuracy for drawing characters, and also can make individual pixels transparent (so you can see the character drawn underneath).
Hey hey hey! zzo reverted the behavior of ALT+D in the editor back to its pre-port version.  Now, instead of resetting the palette to default colors, it...what exactly did it do before, again?


{{stub}}
===Graphics Modes===
Modes 0 to 3 are same as normal MegaZeux. Mode 64 to 67 are the mode for 16 colors per character. Mode 141 makes blinking text.

Revision as of 00:31, 15 June 2009

PZX, or ProngZeux, is a fork of MegaZeux written by zzo38 that focuses primarily on support for FORTH, a low-level, stack-driven programming language.

Features

The biggest contribution of this particular fork is FORTH support. Other changes include the ability to use the old ALT+D function in the editor (only zzo38 seems to remember what this is or use the function to begin with), deferred expressions, extended kinds, new overlay modes and SMZX modes of dubious utility (including the one that draws overlay on the outside of the viewport instead of inside, one that draws only the overlay and not the board, an SMZX mode that uses 16 colors per character (reducing the resolution per character to 4x7), and a blinking text mode), meanings for the other bits in lava_walk, and displacement overlay modes which allow adjustment of the overlay by individual pixels.

zzo38 also corrected a long standing, esoteric bug in the handling of built-in spider webs, which has been merged (with changes) into the existing codebase.

To make backward compatibility, the way it works, is if the first line of the global robot is a comment with a greater than sign at beginning (optionally followed by a filename), it will activate PZX mode. If there is a filename, that is the file containing the Forth codes.

Deferred Expressions

A deferred expression is sort of like having function calls for calling another expression. The operator , sets the current parameter value to the left side and then evaluates the right side, the operator p gets the current parameter, and the operator ` allows you to use a deferred expression.

Because parentheses are used to evaluate expression, it uses square brackets to mean a deferred expression. It will convert [] to () when accessing a deferred expression.

The ` operator is two of ` with the name of string in between (including the dollar sign), and it call the deferred expression. You can also use ` operator with * followed by a Forth word instead of a string, in which case it will instead call that Forth word to determine the value of the expression.

Extended Kinds

You can create extended kinds 0x80 to 0xFE (128 to 254) using Forth codes.

In order to create a extended kind you must indicate:

  • The number assigned to it
  • The character used to represent it (255 means use the parameter, like a CustomBlock does, and negative number mean various other things)
  • The A_ flags associated with it
  • How the parameter is decided (the parameter type can come from any built-in)
  • The name

And then you can optionally define events for it, such as what happens when it is shot, updated, touched by the player, underneath the player, and so on. Which events are used depends on the A_ flags, although it is possible to have A_ flags without the corresponding events (for example, the simplest way to prevent the player from pushing something that is normally pushable is to give the object the A_ITEM flag without a corresponding event).

Some new A_ flags have been implemented:

  • A_BREAKABLE
  • A_USERFLAG
  • A_CRUSH
  • A_INVISIBLE
  • A_ELEMENT (3 bits, and in Forth codes you use AE_WATER and so on instead of typing A_ELEMENT)

Overlay Modes

Mode 4 makes it draw the overlay outside of the viewport instead of on the inside of the viewport.

Mode 65 and 66 makes it to not draw the board, and only draw the overlay. (This feature actually already existed in MegaZeux, but there was previously no access to it during the game.)

Mode 0x7? prevents it from drawing anything at all, allowing Forth codes direct access to the text_video.

There are also displacement overlay modes 0xA?, 0xB?, 0xE?, which allows pixel-accuracy for drawing characters, and also can make individual pixels transparent (so you can see the character drawn underneath).

Graphics Modes

Modes 0 to 3 are same as normal MegaZeux. Mode 64 to 67 are the mode for 16 colors per character. Mode 141 makes blinking text.