Change 4th D to mapmode, not color, fix if statements

No need to store which color mode we are using, since the pixels get
assigned a new color anyway. Instead the fourth dimension can store
which mapmode we are in so that all three map types can be stored.