As the map is 16bits encoded and uses only 512 tiles,
bits 9 up to 15 are free.

When we are editing the map in the MAP console,
use the <M> key to input a hex number that uses those bits.

We can imput there, numbers like from 0000 up to FE00,
the editor won't let us to control the bits 0 up to 8 this way,
as them are used for the "graphical tile number".

Of those bits the bits 13 up to 15 has the meaning for storing the "Major" attribute.
the bits 12 up to 9 has the meaning for storing the "Minor" attribute.

--------- --------- --------- ---------   16 bits encoding.
-M-M-M-m- -m-m-m-t- -t-t-t-t- -t-t-t-t-
--------- --------- --------- ---------

t = tile number from 0 - 511.
m = Minor attribute
M = Major attribute

In each square location of the map,
we can specify in bits 13 up to 15 seven differents major features or 0 = nothing.

$0xxx = nothing.
$2xxx = EnemyRespawn.
$4xxx = RoomDoor
$6xxx = AnimatedTile
$8xxx = AutoBreakable
$Axxx = Special
$Cxxx = BreakableToBlack
$Exxx = BreakableToBlue

Note that the bit 12 is part of the "Minor attribute".
So $2000 and $3000 both means "Enemy Respawn", and so, too for the others.

Each feature uses the minor field (bits 9 up to 12, that is just 4 bits / one nibble),
as defined by the feature,
but note that this nibble is not aligned with the hexadecimal textual writing, it is << 1 (moved 1 bit to the left).

The most used feature is Enemy respawn which its minor attribute can select one of 16 characters to respawn.

By default all tiles in the map has the MAJOR attribute $0xxx which means just do NOTHING, there is no feature encoded in these tiles,
BUT its MINOR attribute can hold arguments for a feature located in other tile,
it is because some features requires extra arguments encoded in the next tile/s on the map (is to say, tiles located at its right).

-----------------------------------------------------------------------------------------------

Lets do the list:

Code

2000 respawn a lift that go up/down,  the location in the map defines which graphical pattern it will use to show, this way.

                                      map location X = even, Y = even = shows as machine lift. (sprite pattern 194).
                                      map location X = odd, Y = even = shows as brick block. (sprite pattern 195).
                                      map location X = even, Y = odd = shows as a cloud. (sprite pattern 196).
                                      map location X = odd, Y = odd = shows as wooden table. (sprite pattern 197).

When editing the map we can see the X/Y location where the cursor is.

2200 respawn a lift that go left/right,  the location in the map defines which graphical pattern it will use to show, this way.

                                      map location X = even, Y = even = shows as machine lift. (sprite pattern 198).
                                      map location X = odd, Y = even = shows as brick block. (sprite pattern 199).
                                      map location X = even, Y = odd = shows as a cloud. (sprite pattern 200).
                                      map location X = odd, Y = odd = shows as wooden table. (sprite pattern 201).

2400 respawn a movable block or box, it is movable by the player or lifts, or can fall.
                                      the location in the map defines which graphical pattern it will use to show, this way.

                                      map location X = even, Y = even = shows as machine lift. (sprite pattern 202).
                                      map location X = odd, Y = even = shows as brick block. (sprite pattern 203).
                                      map location X = even, Y = odd = shows as a cloud. (sprite pattern 204).
                                      map location X = odd, Y = odd = shows as wooden table. (sprite pattern 205).

2600 respawn a turtle.

2800 respawn a bee.

2A00 respawn a spider.

2C00 respawn a frog.

2E00 respawn a guard.

3000 respawn a dog.

3200 respawn a wizard which launch bombs.

3400 respawn a demon which spit fire.

3600 up to 3E00 are reserved for monsters (normally used in monster rooms,
but there is not a limitation to use them elsewhere, but it will has a performance cost,
becuase monster room disable the scrolling, but in the normal map it is scrolling,
and monster classes can be heavier than normal characters).

Normally any character just appears once, when it is killed, and it don't respawn anymore.
But, if in the next tile from the respawn tile (at its right), in the Minor attribute there is a number that isn't zero,
that number will act as a respawn count countdown. As zero means respawn just once (the initial time),
a number 1 will mean respawn 2 times, and so on. After it encoded, is like the following table:

$00 bxx = just once time.
$02 bxx = respawn two times.
$04 bxx = respawn three times.
$06 bxx = respawn four times.
.... and so on ... BUT
$1E bxx = Multiplayer flag (respawn character only if multiplayer).

The CODE "$1E bxx" it doesn't mean to respawn 16 times, it mean respawn ONLY if multiplayer,
and in the next tile (at its right) is moved the countdown number.

It is important to note that the respawn will be produced as soon as the character is killed.

If this next tile has another feature than the "NOTHING" major attribute, the character will respawn just once.

---------------------------------------------------------------------------------------------------------





Roomdoors codes, are those doors that bring the player to the interior of a business, etc.
These business are draw in others locations in the map,
prefferable in the map's top/left edge, that way will be located the room faster, and switch to that room faster.



4400	= door for Cocktails (the bar)
4600	= door for Weapons (the armery)
4800	= door for fruits (the grocery store).
4A00	= door for clothing business.
4C00	= door for special deals businessman.
4E00	= door for hospital.

Each of the avobe business codes, has several speech script to run,
in way the shop keeper don't say always the same for the same kind of business room.
In other words, a bartender will say speech A, and other bartender in other location will say speech B.
The bar room is the same, but the speech is different.
There is up to 8 speech scripts to chose. It is not just the speech, it is the products to sell aswell.

The door location in map X and Y will define which speech he do,
the bits 0 & 1 of X, and the Y odd/even (bit 0), will control which speech is presented.
So, the door location in the map, must be set strategically.

No, I won't list here the speechs, experiment yourself moving the access door one location left/right/up/down.

The business will be open for a certain number of knocks,
after it determine that it must close, the gamecode will change the door tile number,
new tile number = original tile number + 1.

So the next pattern, must show the same door but with a CLOSE or OUT letter, something that indicates that the business is close.

How many door knocks will receive before closing the business?.

This is set in the following tile in the map, 

Example
-------

--4400---0600--
-      -      -
- DOOR -   x  -
-      -      -
---------------

Set in the minor attribute how many knocks before close?.
Note that
---------
0 = 1 knock.
1 = 2 knocks.
2 = 3 knocks.
3 = 4 knocks.
.....

Which coded in the Minor attribute bits is.

0000 = 1 knock.
0200 = 2 knocks.
0400 = 3 knocks.
0600 = 4 knocks.
.....


If in the following tile in the map is another Major feature, the door will only tolerate 1 knock before close.




MORE CODES FOR ROOMDOORs.
-------------------------


5000	= door for monster room 1.
5200	= door for monster room 2.
5400	= door for monster room 3.
5600	= door for monster room 4.
5800	= door for monster room 5.



When the player enters a business or monster room ,
how the game code knows in which part of the map those rooms are drew?.

The Special Major feature define where.

CODES
-----

A400	= door for Cocktails (the bar)
A600	= door for Weapons (the armery)
A800	= door for fruits (the grocery store).
AA00	= door for clothing business.
AC00	= door for special deals businessman.
AE00	= door for hospital.
B000	= door for monster room 1.
B200	= door for monster room 2.
B400	= door for monster room 3.
B600	= door for monster room 4.
B800	= door for monster room 5.

Note that it uses the same Minor attribute than the Roomdoors codes. It is a direct relation.

This codes, must be set in the most LEFT/UP map location of the room.

In a room, the scrolling is not allowed,
so, the room must be 16 tile locations width, and 14 tile locations height, but the last row is partially hidden.

BE00	= where inside that room the players will be respawn.

One thing is what the screen shows, other is where inside the room that shows the players must respawn.

Both codes must be present for monster rooms.

-------------------------------------------------------------------------------------------------

Where in the map the player start the game?

A000  = Map Player Respawn. IT is valid for the first map!.

-------------------------------------------------------------------------------------------------

Where is a checkpoint where the game will be saved in disk?.

A200  = checkpoint for players.

-------------------------------------------------------------------------------------------------

Which tiles are animated? is to say, every X number of frames, it changes its pattern, cycling up to 4 patterns?.

6000  = Animate tile enabled.

How it works?, the game code will read the location Tile Number, and will cycle the bits 1 & 0,
So, it will show in that map location up to 4 patterns, which bits 1 & 0 cycle: 00 01 10 11.

By example:
If tilenumber = 248. It will do, 248, 249, 250, 251, 248, 249 .....
If tilenumber = 249, It will do, 249, 250, 251, 248, 249, 250 .....
If tilenumber = 250, It will do, 250, 251, 248, 249, 250, 251 .....
If tilenumber = 251, It will do, 251, 248, 249, 250, 251, 248 .....

All given sequences examples, have place at the same time. By example, water or lava running,
and others animation that are bigger than just one tile.

--------------------------------------------------------------------------------------------------

Floor that breaks by just walking on it or hit without any force required,
it is called "Autobreakable" feature.

When it breaks, can respawn a hidden item,
the game code must know if the item is presented in a blue sky background,
or black night background. So, that means "break to blue", or "Break to black".

CODE
----

8000 = break to black.(tile number 320).
8200 = break to blue. (tile number 324).
8400 = break to ramdon fruit/food on black. (any tile 0-29) and 2.
8600 = break to ramdon fruit/food on blue. (any tile 0-29) and 2 or 1.
8800 = break to yellow key. Tile 42.
8A00 = break to orange key. Tile 44.
8C00 = break to cyan key. Tile 46.
8E00 = break to violet key. Tile 48.
9000 = break to bombs. Tile 30.
9200 = break to twisters. Tile 32.
9400 = break to fireballs. Tile 34.
9600 = break to thunders. Tile 36.
9800 = break to knifes. Tile 38.
9A00 = break to potions. Tile 40.
9C00 = break to nedles (death) on black. Tile 98.
9E00 = break to nedles (death) on blue. Tile 102.

--------------------------------------------------------------------------------------------------

There is other type of breakable blocks, them can be harder to break,
it will require several hits with a given force (can be break with just the bare hands).

CODES
-----

C000 up to DE00 = Breakable To Black	; Minor = number of hit needed (as countdown). (when broke it set Tile 320 = black night).

E000 up to FE00 = Breakable To Blue	; Minor = number of hit needed (as countdown). (when broke it set Tile 324 = sky blue).

As the minor defines the hardness, them never show hidden items.

So, place Autobreakables strategically in the map combined with these ones.

--------------------------------------------------------------------------------------------------

The last code support is the teletransport feature.

It support to teletransport to other place in the same map.

Or, teletransport to other map.

BC00 = Teletransport.

The following 5 tiles to its right in the map,
must contain enconded in the "MINOR attribute" the following:

"lsnX, msnX, lsnY, msnY, map_numberM" values to where tele-transport all players.

HINTS: lsn = least significant nibble, msn = most significant nibble,
first map = 1, last map = 9. Current map = 0.

The Major attribute must be = nothing.

Remember that "minor attribute" is bits 9 up to 12 (NOT 8 up to 11).
Switching to other map, make the game lose track of all what is done in the current map,
so it is used only for going to the next level, and never come back.

Example:

BC00  -  0200  -  0400  -  0800  -  0200  -  0000

It will teletransport to the same map, in map location X = $21 , Y = $14.


And with this, complete all codes that can be used when editing the map.

































