Extended map number

From SRB2 Wiki
Jump to navigation Jump to search
"Extended map numbers" redirects here. For a list of extended map numbers, see List of extended map numbers.

Extended map numbers are map numbers which make use of letters in addition to digits. MAPA1 is an example of an extended map number.

In SRB2, the names of map lumps take the form MAPxx, where xx specifies the particular map. The first ninety-nine, then, are named MAP01 to MAP99, but the game allows a greater number of maps to be loaded by means of the extended map numbers, which include letters as well as digits. SRB1 Remake maps make use of these: for example, Knothole Base Zone Act 1 from the SRB1 Remake is MAPA1. All letters are permitted, but note that, if the first character is a number, the second character must also be so. MAP1A is not a valid map name, for instance.

The map numbers are ordered first from MAP01MAP99, then MAPA0MAPA9, MAPAAMAPAZ, then MAPB0MAPB9, MAPBAMAPBZ, and so on, all the way up to MAPZZ.

Conversion of extended map numbers

All extended map numbers have a corresponding numerical representation. This is used, for example, with the tunes command. When editing the game, it is often necessary to convert between the two. The following algorithms can be used to do so:

Extended map number to integer

For the conversion, we need to establish four variables:

  • x: The first character of the extended map number.
  • y: The second character of the extended map number.
  • p: The position of x within the alphabet. The numbering begins at zero, so C would be 2.
  • q: The position of y within the alphabet. The numbering begins at ten, so C would be 12. If y is a number, q should be that number.

The integer representation is calculated as ((36*p + q) + 100).

Example: We have the extended map number E4.
x = E, y = 4
p = 4, q = 4
((36*4 + 4) + 100)
((144 + 4) + 100)
(148) + 100)
E4 = 248
Example 2: We have the extended map number GH.
x = G, y = H
p = 6, q = 17
((36*6 + 17) + 100)
((216 + 17) + 100)
(233) + 100)
GH = 333

Integer to extended map number

For the conversion, we need to establish five variables:

  • x: The integer minus 100.
  • p: x divided by 36. If you get a decimal, round down.
  • q: The remainder when x is divided by 36. You can determine this by (x - (36*p)).
  • a: The letter of the alphabet at the position p. The numbering begins at zero, so 2 would be C.
  • b: The letter of the alphabet at the position q. The numbering begins at ten, so 12 would be C. If q is less than ten, b should be the same as q.

The extended map number is now ab in succession.

Example: We have the integer 248.
x = 148
p = 148/36 = 4.[...]
q = 148 - 36*4 = 148 - 144 = 4
a = E, b = 4
248 = E4
Example 2: We have the integer 333.
x = 233
p = 233/36 = 6.[...]
q = 233 - 36*6 = 233 - 216 = 17
a = G, b = H
333 = GH