SMBX64



SMBX64 (Super Mario Bros. X Standard version 64) is the name of the technical standard used by Super Mario Bros. X version 1.3. This standard contains the file formats, references, item lists, and game-wide default values. The specifics of this standard were researched by Wohlstand in early 2014. This standard is very strictly defined. Each item and behavior algorithm is linked directly to a specific ID value.

The SMBX 1.3 Compatible configuration package for PGE is a full implementation of SMBX64 Itemset: blocks, BGO's, NPC's, Music list map, Sound list map, Tiles, Paths, Level entrances, effects. This configuration package completely provides compatibility layer with SMBX-made levels, world maps and episodes.

Name
The Standard name it is a name of game SMBX and last internal version number which you can read in first line of any .lvl file with notepad (it is 64).

Standard history
This is a partial history researched from available builds of SMBX. This history doesn't contains any unpublished alpha-builds (numbers of those versions you will find in the SMBX64-LVL file format specification).

SMBX1 - The first version of standard which came with Super Mario Bros. X 1.0, written by Andrew 'Redigit' Spinks. Blocks can hold 1-99 coins or one of the following NPCs: goomba, flower, leaf, shoe, or mushroom.

SMBX2 - Added support for custom music

SMBX8 - Added support for inter-level warps, added "stars-needed" lock for warps, added "Door" warp type

SMBX10 - Added support for layers and events in levels. Para-Koopas, Para-Goombas, and Cheep-Cheeps were given multiple behavior algorithms. Added NPC Generators. Added talk messages, "friendly" flag, and "not movable" flag for NPCs. Boss NPCs no longer all use the same algorithm, so the flag "Legacy Boss" was added to re-enable those algorithms. Added intro levels of episodes. Added "restart level on death" support. Added "hub-style" worlds system. Added credits fields for world map. Added support for entering to the specified warp ID of a level from world map.

SMBX17 - Added star count field into level file.

SMBX18 - Blocks can contain any available NPC by its ID. Added play-sound event.

SMBX20 - Added "Number of stars" field for world maps.

SMBX28 - Added "Locked", "No Yoshi" and "Allow NPC" flags for warps. Added support for event triggers. Added support for forcing the player's control key events. Added "Always visible" flag for levels on world map. Added support of background image under level icon. Added "Game start" flag for level: allows for using any level location as the episode start point. Added support for warping between two locations on the world map.

SMBX32 - Added support for "Water" physical environment zones. Added auto-start ability of events, added layer motion events.

SMBX49 - Added auto-scrolling support.

SMBX55 - Added support to disable specified characters in the episodes.

SMBX62 - Added "level title" field. Added slippery block support.

SMBX63 - Allowed layers to be attached to an NPC, which will move layers with NPC's motion. Added "Quicksand" physical environment zone type.

SMBX64 - The latest and final version of the SMBX standard which was created in 2011 with "Super Mario Bros. X 1.3". After this version, "Super Mario bros. X" development was permanently ended.

SMBX65-38A - The unoficial continuation of SMBX64 Standard used in Chinese SMBX. New standard has much more features, and introduces new LVL/WLD file formats which going with not similar file syntax

File formats
SMBX64 standard uses a text format with unmarked values.

SMBX1...64 Standard specifications:

.LVL - level file format. Download specification: ODT, PDF

.WLD - world file format. Download specification: ODT, PDF

.SAV - game save file format. Download specification: ODT, PDF

SMBX65-38A Standard specifications:

Comming soon, currently there are not documented yet

Limits
SMBX64 Standard has some limits about placing elements on the level map and world map:

Levels

 * Player start points: 2
 * Blocks: 16384 (because the index is 2*8bits [2 bytes] in VB6)
 * Sizable Blocks (these count as normal blocks too): 1000
 * NPCs: 5000
 * Background Objects: 8000
 * Warps: 200
 * Water/Quicksand areas (doesn't matter how big): 450
 * Events: 100
 * Layers: 100
 * Stars (while in-game): 10000
 * Effects (while in-game): 1000

World maps

 * Tiles: 20000
 * Paths: 2000
 * Music-Boxes: 1000
 * Scenery: 5000
 * Levels: 400

Note: information about SMBX's limits here is NOT taken from the Debugger box of SMBX, because it shows incorrect limits for some of the elements, and it doesn't have a debug box for world maps.

Standard item list
Here are lists of the total item settings which are defined by the SMBX64 standard

Level

 * Playable characters
 * Blocks
 * Background Objects
 * Non-playable Characters
 * Backgrounds

World map

 * Tiles
 * Sceneries
 * Paths
 * Levels

Common

 * Sound effects
 * Music
 * Hardcoded images (Impossible to customize without LunaLUA)

Accessible properties
Full list of data properties which can be defined and changed with SMBX64-compatible editors and used in the SMBX based games.

Level Settings

 * Level title string
 * Max total number of sections: 21
 * Per section properties
 * Left-Top-Right-Bottom positions values
 * Background color (accessible from SMBX1 to SMBX2, later unused)
 * Level warp flag (Connect left and right sides)
 * Off-screen exit flag
 * No turn back(right direction walk only) flag
 * Underwater flag
 * Background-ID number
 * Music-ID number (Music-ID=24 is a reserved value which enables custom music playback)
 * Custom music file string

Level items

 * Blocks (Should be sorted by Y and grouped with sorting by X in array)
 * X-Y position
 * W-H Size of sizable block (Multiple 32 only, minimal size is 64x64 px)
 * Slippery flag
 * Invisible flag
 * Contents (Nothing 0, Coins 1...99, NPC-9 100, NPC-1 101, NPC-14 102, NPC-34 103, NPC-35 104, coins 105...999, NPCID+1000, 1001...1392)
 * Layer name string
 * "Destroyed" event slot string
 * "Hit" event slot string
 * "No more objects in the layer" event slot string
 * Background objects (Should be sorted by special sorting priority table)
 * X-Y position
 * Layer name string
 * NPC
 * X-Y position
 * Direction left-random-right
 * Friendly flag
 * No move flag
 * Legacy boss flag (accessible for three NPC's: Boom-boom, Birdo, Bowser III'rd)
 * Message text string
 * Generator flag
 * Generator direction left-up-right-down
 * Generator period delay
 * Generator type number
 * Layer name string
 * Attached layer name string
 * "Activated" event slot string
 * "Died" event slot string
 * "Talk" event slot string
 * "No more objects in layer" event slot string
 * Player's spawn point
 * X-Y Position
 * Warp points
 * X-Y of entrance point position
 * X-Y of exit point position
 * Layer name string
 * Warp type number
 * Entrance direction left-up-right-down
 * Exit direction right-down-left-up
 * No Yoshi (Deny vehicles) flag
 * Allow carried NPC's flag
 * Locked flag
 * Stars needed number
 * Level Entrance flag
 * Level Exit flag
 * Target Level filename string
 * Target warp Array-ID number
 * Target world map X-Y coordinates (-1 and -1 are reserved with "empty fields")
 * Water/Quicksand zone
 * X-Y Position
 * W-H Size (Multiple 32 only)
 * Is Quicksand flag
 * Layers
 * Layer name
 * "layer is hidden" flag
 * Events
 * Event title string
 * Pop-up Message box text string
 * 21 slots for layers of "hide" task (21'st must be empty!)
 * 21 slots for layers of "show" task (21'st must be empty!)
 * 21 slots for layers of "toggle visibility" task (21'st must be empty!)
 * "Disable smoke effect" flag
 * Task to switch background ID's of each 21 section
 * Task to switch music ID's of each 21 section
 * Task to change boundaries of each 21 section
 * Auto-triggerable flag
 * Trigger&hold player control key flags for UP-DOWN-LEFT-RIGHT-JUMP-ALTJUMP-RUN-ALTRUN-DROP-START
 * Set movement for layer name string
 * Set movement for layer X-Y speeds in pixels per frame
 * Set autoscrolling for section number
 * Set autoscrolling of section X-Y speeds in pixels per frame

World map settings

 * Episode title
 * Intro level file name string
 * 5 fields of "Episode credits"
 * "No world map" flag
 * "Restart on fail" flag
 * Total stars number
 * Episode without Mario flag
 * Episode without Luigi flag
 * Episode without Peach flag
 * Episode without Toad flag
 * Episode without Link flag

World map items

 * Tiles
 * X-Y position
 * Scenery
 * X-Y position
 * Paths
 * X-Y position
 * Music Boxes
 * X-Y position
 * Levels
 * X-Y position
 * "Background path" flag
 * "Big background path" flag
 * "Always visible" flag
 * "Game start point" flag
 * Target level file name string
 * Target WARP-ID number
 * Open path condition by exit type for left side
 * Open path condition by exit type for top side
 * Open path condition by exit type for right side
 * Open path condition by exit type for bottom side
 * Target teleportation X-Y world map coordinates

Graphics
SMBX's Graphics uses GIF format. SMBX Engine imitates transparency by using alpha-channel masks - an additional image which defines the transparency level by grayscale level: 0 (Black) - is visible, solid pixel, and 255 (White) - is a transparent pixel, but SMBX64 does supports only completely solid or completely transparent pixels, so using semi-transparent (gray) colors in the mask is not recommended.

Musics and sounds
SMBX uses MP3 file format. Custom music can use other formats, however, such as: WAV, MID and MP3.

Editor Tech Standard
Declaration of level and world map editors for SMBX64 standard.

Sizes
All item sizes are pre-defined for each item and can't be changed except to sizable blocks, water zones and NPC's with npc.txt files.
 * All blocks and most of background objects has a 32x32 px size or multiple 32 px size.
 * All sizable blocks uses 96x96 sprite which dividing to 9 pieces of sizable block.

Aligning
All items has default grid size in 32 pixels where they are should be aligned. But some exceptions are presented.


 * Blocks
 * Aligning relative to left-top corner with 32 px or 16 px grid size
 * Background objects
 * Aligning relative to left-top corner with 32 px or 16 px grid size
 * NPC's
 * Has a special aligning rule:
 * bottom aligned to 32px or 16px grid size
 * Side aligning by formula: Target position = (Offset from grid cell left side: 32px/2)-((Width of NPC)/2) if NPC aligns to grid cell center or when NPC aligns by center to grid line, horizontal offset formula is '-((Width of NPC)/2)'.
 * Any "Generators" aligning with 16 px grid size.
 * Warps
 * Aligns with 16px grid size
 * Water/Quicksand zone
 * Aligns with 16px grid size
 * Player's spawn points
 * Aligning with 4 px vertical and 2 px horizontal aligning grid sizes.

Collisions
Collisions prevents placement of items over each other by special rules:


 * Blocks
 * Colliding with any other blocks except sizable blocks.
 * Colliding with any NPC's except vines, red herb container, red door.
 * Background objects
 * Colliding with background object of same BGO-ID.
 * NPC's
 * Colliding with any blocks except sizable blocks.
 * Colliding with any NPC's except vides, red herb container, red door.
 * Water/Quicksand zone
 * Doesn't colliding with others.
 * Warps
 * Doesn't colliding with others.
 * Player's spawn point
 * Doesn't colliding with others.
 * Effects
 * Denied to placement in the editor.

Render Z-Order
Definition of drawing order of items by types: Lowerest: Background images -160: Background-2: BGO's -150: Sizable blocks -100: Background-1: BGO's -50: Warp - Derived BGOs (locks on doors and stuff) -10: Background NPC's -5: Held NPC's 1: Normal blocks 15: Furthest Back Effects (doors, pressed p-switches, some other stuff) 30: Normal NPC's 31: Normal NPC's (Ice block) 32: Player Vehicles / Mounts 35: Playable characters 50: Foreground-1: BGO's 100: Foreground NPC's 150: Foreground blocks 160: Foreground-2: BGO's Highest: Foreground effects

Blocks array order
All blocks in the file are must be sorted by way [X-position] -> [Y-position] -> [ArrayID]. That required by SMBX's collision detection algorithm which uses a binary ranges. If blocks are will not be ordered, NPCs are will always miss up collisions with any blocks.

Background objects array order
All BGOs are ordering by special order priority coefficient which groups specific BGO-ID's inside.

How SMBX orders BGOs in a list: There's a mix of using hardcoded conditionals, but also some lookup from a table of Boolean values, where this table of boolean values is only written once and not changed. Used an Insertion sort algorithm. Algorithm is stable itself, but implementation inside SMBX is not stable, therefore every file save of same data, resulted file always has a different order of BGOs.

PGE File Library orders BGOs by this order priorities table and by order of placement which gives a same result on every file save. PGE File Library uses recursion-less Quick sort algorithm.

Sizes
All world map items has 32 px tile size except level points which has different sizes of sprites, but physical size still be 32 px.

Aligning
All items aligns with 32 px grid size except 'sceneries' which aligns with 16 px grid size.
 * Tiles, Paths, Music Boxes
 * Aligns with 32 px grid size
 * Sceneries
 * Aligns with 16 px grid size
 * Level points
 * Has a special aligning rule:
 * bottom aligned to 32px or 16px grid size
 * Side aligning by formula: Target position = (Offset from grid cell left side: 32px/2)-((Width of NPC)/2) if NPC aligns to grid cell center or when NPC aligns by center to grid line, horizontal offset formula is '-((Width of NPC)/2)'.

Collisions
Collisions prevents placement of items over each other by special rules:
 * Tiles
 * Collides with any other tiles
 * Sceneries
 * Doesn't collides. (which a technical mistake of SMBX! To prevent it, they should collide with other sceneries with same SCENERY-ID in 16x16 px cell of the left-top picture side)
 * Paths
 * Collides with any other paths and with level points
 * Level points
 * Collides with any other level points and with paths
 * Music boxes
 * Collides with any other music boxes

Render Z-Order
Definition of drawing order of items by types 0: Tiles 5: Sceneries 10: Paths 15: Level points 20: Music boxes

Customization of contents
SMBX64 Standard supports customization.

Blocks
Blocks do support custom graphics. You need to use an image in GIF format with the same size or the same number of animation frames as the original block had.

''Tip: if your block image size is bigger or smaller, than the original block is, in PGE Editor, you can place them with no problem, unlike in SMBX. That way you can create custom blocks of any size, which will work in SMBX.

Warning: don't select custom blocks in SMBX or they will shrink to their original sizes!!

Background Objects (BGOs)
Background Objects do support custom graphics. You need to use an image in GIF format with the same size or the same number of animation frames as the original BGO had. If the image will be bigger than the original BGO's sizes, it will look cut, but if the image will be smaller than the original BGO, it will work in both SMBX and PGE.

Non-Playable Characters (NPCs)
NPCs are fully customizable, but you need to use special npc.txt configuration file.

Backgrounds
Backgrounds do support custom graphics and they can have any image sizes.

Playable Characters
Each playable character uses a spritesheet with a size 1000x1000 pixels, and totally contains 100 frames in each of them.

Tiles
Tiles do support custom graphics.

Sceneries
Sceneries do support custom graphics, but custom sceneries from 33 to 65 will crash SMBX while trying to save the file. PGE fixes that problem.

Paths
Paths do support custom graphics..

Level points
Level points do support custom graphics.

Musics and sounds
You can use custom music in Level Mode, but you can't use custom music in World Map mode. You can't use custom sounds in both modes.

Trivia

 * Fun fact: Wohlstand had no idea about "Sceneries 33-65 will crash SMBX while saving" bug, until h2643 told him that!
 * In the original SMBX World Map editor, there is a bug, which allows you to place sceneries multiple times on the SAME position with no limits. This causes appearing of junk scenery items while you place them with mouse.