Player physics/movement algorithm

• Signed vertical velocity in whole pixels at 0x009F
• Unsigned(?) vertical velocity in fractions of a pixel at 0x0433
• Gravity varies, see RAM map for 0x0709/070A
• Basic integration of vertical velocity (when player not grounded)
• If the carry flag is set (addition into 0x0433 overflowed), a whole pixel (0x01) is added to 0x009F.
• Note: 0x009F is clamped to a maximum positive value of 0x05, but 0x0433 is NOT cleared. This could lead to various round-off errors leading into the next jump (unconfirmed).
• Jumps
• An instant velocity impulse is set, e.g. 0xFB, propelling the sprite upward.
• Gravity is also modified, e.g. set to 0x30 (weaker) when going up and then to 0xA8 (stronger) when falling down.
• These values VARY based on jump power/horizontal velocity. See RAM map for some possible values. Exact algorithm yet unknown.

Hacking the End-of-Level Castles

1) Get some graphing paper, and start cordoning 2x2 squares. Make a 5x5 block of such squares (10x10 overall).

2) Reading right-to-left, from the top row down, you've got the metatile defined by \$17DF, \$17E0, \$17E1, etc......, \$17F7.

3) This linear string of 25 bytes can be represented on your graph paper like this:

``` 5  4  3  2  1
10  9  8  7  6
15 14 13 12 11
20 19 18 17 16
25 24 23 22 21
```

The first byte in this string codes for the upper-rightmost metatile, the second byte codes for the metatile directly to #'s left, etc.

4) The large castles at the end of every X-3 level (and the beginning of most X-1 levels) are simply the small castle stacked on top of another, slightly taller one. This taller castle is 6 metatiles high and five metatiles wide, and is coded in a similar right-to-left, top-down fashion. Its linear byte sequence begins at \$17F8.

5) The little side-sections on the X-3 castle type are actually the same background image that occurs throughout World 8-3. This image is 1 metatile wide and eleven metatiles high (although it only appears to be six metatiles high since the first five bytes are assigned transparent "00" values). Its coding begins at \$13CE and ends at \$13D8.

Mario Palette Information

Main Palettes

There are four main palettes each with a unique set of 8 colors defined (background, pipe, cloud, brick, mario, green enemy, red enemy, brown enemy)

• Water
• Ground
• Underground
• Castle

4 alternate palettes

• Night (sets background)
• Snow (sets background, pipe color)
• Night/Snow 1 (sets background, pipe colors)
• Night/Snow 2 (uses castle palette for everything but background)

Other

• Mushroom type sets pipe color (over rides all other pipe color settings)
• Bowser has special palette

Metatile list

```00 - Blank
01 - Black Metatile
02 - Bush Left
03 - Bush Middle
04 - Bush Right
05 - Mountain Left
06 - Mountain Left Bottom/Middle Center
07 - Mountain Middle Top
08 - Mountain Right
09 - Mountain Right Bottom
0A - Mountain Middle Bottom
0B - Bridge Guardrail
0C - Chain
0D - Tall Tree Top, Top Half
0E - Short Tree Top
0F - Tall Tree Top, Bottom Half
10 - Warp Pipe End Left, Points Up
11 - Warp Pipe End Right, Points Up
12 - Decoration Pipe End Left, Points Up
13 - Decoration Pipe End Right, Points Up
14 - Pipe Shaft Left
15 - Pipe Shaft Right
16 - Tree Ledge Left Edge
17 - Tree Ledge Middle
18 - Tree Ledge Right Edge
19 - Mushroom Left Edge
1A - Mushroom Middle
1B - Mushroom Right Edge
1C - Sideways Pipe End Top
1D - Sideways Pipe Shaft Top
1E - Sideways Pipe Joint Top
1F - Sideways Pipe End Bottom
20 - Sideways Pipe Shaft Bottom
21 - Sideways Pipe Joint Bottom
22 - Seaplant
23 - Blank, Used On Bricks Or Blocks That Are Hit
24 - Flagpole Ball
25 - Flagpole Shaft
26 - Blank, Used In Conjunction With Vines

40 - Vertical Rope
41 - Horizontal Rope
42 - Left Pulley
43 - Right Pulley
44 - Blank Used For Balance Rope
45 - Castle Top
46 - Castle Window Left
47 - Castle Brick Wall
48 - Castle Window Right
49 - Castle Top W/ Brick
4A - Entrance Top
4B - Entrance Bottom
4C - Green Ledge Stump
4D - Fence
4E - Tree Trunk
4F - Mushroom Stump Top
50 - Mushroom Stump Bottom
51 - Breakable Brick W/ Line
52 - Breakable Brick
53 - Breakable Brick (Not Used)
54 - Cracked Rock Terrain
55 - Brick With Line (Power-Up)
56 - Brick With Line (Vine)
57 - Brick With Line (Star)
58 - Brick With Line (Coins)
59 - Brick With Line (1-Up)
5A - Brick (Power-Up)
5B - Brick (Vine)
5C - Brick (Star)
5D - Brick (Coins)
5E - Brick (1-Up)
5F - Hidden Block (1 Coin)
60 - Hidden Block (1-Up)
61 - Solid Block (3-D Block)
62 - Solid Block (White Wall)
63 - Bridge
64 - Bullet Bill Cannon Barrel
65 - Bullet Bill Cannon Top
66 - Bullet Bill Cannon Bottom
67 - Blank Used For Jumpspring
68 - Half Brick Used For Jumpspring
69 - Solid Block (Water Level, Green Rock)
6A - Half Brick (???)
6B - Water Pipe Top
6C - Water Pipe Bottom
6D - Flag Ball (Residual Object)

80 - Cloud Left
81 - Cloud Middle
82 - Cloud Right
83 - Cloud Bottom Left
84 - Cloud Bottom Middle
85 - Cloud Bottom Right
86 - Water/Lava Top
87 - Water/Lava
88 - Cloud Level Terrain
89 - Bowser's Bridge

C0 - Question Block (Coin)
C1 - Question Block (Power-Up)
C2 - Coin
C3 - Underwater Coin
C4 - Empty Block
C5 - Axe
```

Stripe Image

This data format represents title screens and other static background layouts in a lot of games published by Nintendo. SMB uses it in ROM for the title screen and other strings (see ROM map) and in RAM for the transfer buffer.

An image consists of several packets, where each packet is as follows, followed by a 00 byte

```0    VRAM destination address high byte (20-3F)
1    VRAM destination address low byte
2    Flags and length
irnn nnnn
||++-++++- Length minus 1 (00: 1 byte; 3F: 64 bytes)
|+-------- Run (0: 1-64 literal bytes follow; 1: 1 byte follows repeated 1-64 times)