PZX

From MZXWiki
Revision as of 00:31, 15 June 2009 by Wervyn (talk | contribs) (Merged from old page.)
Jump to navigation Jump to search

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.