The OR Color

# Introduction

With the introduction of the V9938 in the MSX2 came a major improvement in the sprite area. Not only was the maximum amount of sprites on a row doubled, but sprites could have a color per sprite line and the OR-color was introduced. OR-colors are bonus colors which can be had when two or more sprites are put on top of each other and when the colors of such sprites have the right colors.

The OR refers to the OR as used in binary math: 0011 OR 1010 = 1011, 0001 OR 1000 = 1001, 1100 OR 1100 = 1100, and 1000 OR 1111 = 1111.

# Setting up a game palette

In context of games, the most commonly used amount of sprites to form game characters is two. With two sprites, there can be a maximum of three colors per sprite line and there can be four such composite sprites on a row and sixteen on screen in normal circumstances. While setting up such sprites and palettes may be complex, it didn't stop for instance Konami to create sprites using this technique, for games like Usas, Vampire Killer, Metal Gear, Metal Gear 2, King Kong 2 and many others.

Setting up a palette with enough OR-color flexibility is best done prior to designing any other relevant graphics, because the position of OR-colors is mathematical while people usually tend to group colors by shade.

## OR 1

An easy to understand scheme is the OR 1 scheme: 2 OR 1 gives 3 as bonus, 4 OR 1 gives 5 as bonus, 6 OR 1 gives 7 as bonus, and so on. If color 1 would be black then color 2 and 3 could form the main sprite color. Often these are two shades of a particular color, such as light red and dark red. Using this OR 1 scheme there could be seven color schemes like that - per sprite line! A variation on this concept is to not use black as darkest color 1 but a color like dark blue. With colors 2 and 3 being lighter shades of blue there are three shades of blue in total. This darkest blue can only be used properly in an OR 1 scheme with other blue shades however, which is a disadvantage.

A more general disadvantage of the OR 1 scheme is that, while assuming a black outline color and two main color shades, the only available colors for a sprite line are the two main color shades. This is perfect for skeletons, knights, polar bears, clouds and such (black outline, white and grey shade), walking/moving plants (black outline and two green shades) and walking oranges (black outline, two orange shades). It's less useful for objects like humans and (complex) monsters, because OR 1 schemes aren't handy for sharing a skin tone among different shade groups.

## OR 3

With the OR 3 scheme we get three global color groups in our palette: 3 OR 4, 5 or 6 always gives 7 as OR-color. 3 OR 8, 9 or 10 always gives 11 as OR-color. 3 OR 12, 13, or 14 always gives 15 as OR-color. In this scheme there is some variation possible within a sprite line. If a sprite is designed to have color 3 and color 7, then one of the colors 4, 5 and 6 can be used on that line too.

## OR 7

Using color 7 together with colors 8-14 always gives 15 as OR-color. Assuming we want a black outline would mean 7 or 15 would have to be black. With color 7 being black, color 15 could be white (as a general phong/highlight color), with colors 8-14 being single shade main colors. This gives seven main colors with black and white. These could for instance be seven balls or seven shiny pieces of fruit. Alternatively, with color 7 being black, color 15 could be a skin tone. Colors 8-14 could be single shade main colors again, meaning you could have seven differently colored humans.

# Brief technical information

"OR" color is set on each sprite color line on the VRAM, on the bit 6. The sprite on the lower layer should always have all lines with "OR" color bit disabled. More information can be find at https://www.msx.org/wiki/COLOR_SPRITE\$%28%29#Parameters

# Analysis

Let's have a look at how Konami applied OR colors to their games.

## Usas

### Wit and Spider

ColorRGBColorColorRGBColor
0 000 8 650
1 052 9 733
2 025 10 700
3 003 11 037
4 777 12 321
5 367 13 777
6 753 14 444
7 531 15 000
 * The Wit sprite is based on colors 6 (skin) and 9 (red), which gives 15 (black) as bonus color. * The dog-like statues use the colors 13 (white), 14 (grey) and 15 (black), there are more sprites in Usas that use this combination, such as the coins, the flying skeletons, the crawlers early in the first temple of the game, the transporting stone heads, the pushable rock and the ghosts wearing blankets. * The spider uses the colors 7 (brown) and 8 (light brown) with again color 15 (black) as bonus.

As good as these sprites look, each individual sprite is based on just a single OR scheme, 6 OR 9, 7 OR 8 and 13 OR 14. Now let's have a look at another screen of the same level.

### Zombie

ColorRGBColorColorRGBColor
0 000 8 342
1 052 9 733
2 025 10 700
3 003 11 037
4 777 12 321
5 367 13 777
6 753 14 444
7 564 15 000
 In this scene, the green zombies take over the colors of the spider: 7 (light green) and 8 (dark green). The trick here is to set a specific enemy type per screen, and while you can't have all the possible combinations (e.g. zombie and spider in one screen), at least throughout a whole level you can have plenty variations of sprites and colors. It does suggest that you reserve such colors for sprites, unless you agree to have unique background tiles for such screens too.

### Bird and Cyan Creature

ColorRGBColorColorRGBColor
0 000 8 144
1 052 9 733
2 025 10 700
3 003 11 037
4 777 12 321
5 367 13 777
6 753 14 444
7 467 15 000
 * In this screen, the colors 7 and 8 have been replaced by shades of cyan for those odd little creatures that are pestering you. Again, it suggests that there won't be zombies, spiders and cyan creatures in one screen. * The bird is made out of the colors 10 (red) and 13 (white) with 15 (black) as bonus.

### Boss 1

ColorRGBColorColorRGBColor
0 000 8 542
1 052 9 733
2 025 10 700
3 003 11 037
4 777 12 321
5 367 13 777
6 753 14 444
7 663 15 000
 The boss of this level again takes the colors 7 (light brown) and 8 (dark brown) with color 15 (black) as bonus.

### Cles

ColorRGBColorColorRGBColor
0 000 8 342
1 052 9 234
2 025 10 700
3 003 11 037
4 777 12 321
5 367 13 777
6 753 14 444
7 564 15 000
 Now let's play with Cles, the blue guy. As you can see, the color that used to be Wit's light red (color 9) has been replaced with Cles' blueish color. This suggests that Wit and Cles won't be joining forces together in a level, which is of course true, a necessity even. The water of the waterfall is made out of sprites too, but as there are only two colors in this waterfall, it could be any blue and any white.

## King Kong 2

### Mitchel and Pigworm

ColorRGBColorColorRGBColor
0 000 8 602
1 000 9 661
2 431 10 245
3 754 11 421
4 713 12 555
5 746 13 543
6 522 14 777
7 765 15 025
 * In King Kong 2, the Mitchel character uses the OR 1 scheme; color 1 (black), color 2 (brown) and color 3 as bonus (skin). * The pigworm creature uses the next OR 1 combination: color 1 (black), color 4 (dark pink) and color 5 as bonus (light pink). * The explosion takes two sprites but doesn't (and can't) use a third color, so it can be any color. It uses color 8 and 14 though. (note: isn’t color 6 being used as well?)

### Wildboar and Poisonfrog

ColorRGBColorColorRGBColor
0 000 8 602
1 000 9 661
2 431 10 245
3 754 11 421
4 631 12 555
5 751 13 543
6 035 14 777
7 065 15 025
 * The Wildboar takes the two pink shades from the Pigworm. Just like in Usas, Konami uses dedicated enemies with dedicated colors for specific screens. * The Wildboar explosion uses color 6 (blue), color 8 (very dark pink) with color 14 (white) as bonus.

Colors 6 (medium cyan) and 7 (cyan) are new in this screen palette, but unused..

 ..because these cyan colors belong to the Poisonfrog, one screen above. Why? Who knows. Perhaps Konami planned to use these Poisonfrogs earlier, scrapped the idea but didn't restore the palette. So far, the main characters, Mitchel, Pigworm, Wildboar and Poisonfrog use the OR 1 scheme, and just like Usas, they use just three colors for the whole sprite.

## Goemon

ColorRGBColorColorRGBColor
0 000 8 750
1 754 9 532
2 000 10 420
3 700 11 024
4 754 12 444
5 530 13 041
6 777 14 777
7 310 15 021

Using OR colors requires strategic placement of colors, but no matter how hard you try, there's a chance that the ultimate combination (where multiple characters benefit from color advantages) simply isn't possible.

 * The main player in Konami's Goemon is once again a three-color character, using color 1 (skin) with color 2 (black) and color 3 (red) as bonus. * The black character uses color 2 (black), color 4 (skin) with color 6 (white) as bonus. Here it's evident why there are two identical skin colors in this palette; the main player uses skin color 1 to get color 3 as bonus, and to have the black character uses bonus color 6, it'll have to use color 4 to get there. * The light brown character on the left uses four colors, but never more than two on a row. This means no OR color has been used here, resulting in a total freedom of colors. The fourth color is color 8 in the shoes. * The dark brown character also uses four colors and never more than two on a row; color 1 (black), color white (as there are two whites in the palette, it's unclear which white was used, and technically it doesn't matter), color 7 (dark brown) and a skin color (which is either color 1 or color 4).

Would it be necessary to have two skin colors? After all, using color 3 for black and bonus color 7 for skin would give you any of the colors 4..6 for a third color.

## King's Valley 2 - MSX2

ColorRGBColorColorRGBColor
0 000 8 346
1 420 9 640
2 445 10 770
3 334 11 777
4 223 12 124
5 112 13 177
6 300 14 765
7 600 15 000
 * In King's Valley 2 - MSX2, the main player uses color 13 (cyan), color 14 (light skin) with color 15 as bonus (black). Konami used the 13-14-15 combination in Usas too, where it was white-grey-black. * The mummy uses color 11 (white), color 12 (dark blue) and color 15 (black) as bonus.

## Metal Gear 2 - Solid Snake

ColorRGBColorColorRGBColor
0 000 8 333
1 000 9 026
2 430 10 700
3 320 11 654
4 111 12 530
5 222 13 042
6 333 14 021
7 777 15 000

While in Usas, King Kong 2, Goemon and King's Valley 2 the sprites were relatively simple (usually three colors per sprite), in Solid Snake the sprites are far more colorful.

 Snake is made out of six colors, of course no more than three on a row. The green pants and body are made out of color 13 (medium green), color 14 (dark green) and OR color 15 (black). Boots are color 3 (medium dark brown), color 12 (medium brown) and OR color 15 (black). Other combinations used in Snake: 11 OR 12 = 15, 11 OR 14 = 15, 3 OR 14 = 15. The beige enemy is made out of five colors. The lines with the red beret only have black as outline, no OR color is present. The beige outfit uses color 3 (medium dark brown), color 12 (medium brown) and color 15 (black) as OR color. Where skin is present, the combination 11 OR 12 = 15 is used.

# Table of OR-colors based on two colors

The left table shows whether a combination of two colors results in an OR bonus. If two colors don't feature a bonus color, the relevant cell has been left blank. Note that, due to the design of this table, all the values are double; A OR B equals B OR A. The table on the right shows how popular a specific OR color is, the amount equals half the amount you see in the left table. By far the most popular OR bonus is color 15, which leads to the conclusion that colors you wish to share among multiple sprites are best placed at color 15, such as black.

OR0123456789101112131415
0 - - - - - - - - - - - - - - - -
1 - - 3 - 5 - 7 - 9 - 11 - 13 - 15 -
2 - 3 - - 6 7 - - 10 11 - - 14 15 - -
3 - - - - 7 7 7 - 11 11 11 - 15 15 15 -
4 - 5 6 7 - - - - 12 13 14 15 - - - -
5 - - 7 7 - - 7 - 13 13 15 15 13 - 15 -
6 - 7 - 7 - 7 - - 14 15 14 15 14 15 - -
7 - - - - - - - - 15 15 15 15 15 15 15 -
8 - 9 10 11 12 13 14 15 - - - - - - - -
9 - - 11 11 13 13 15 15 - - 11 - 13 - 15 -
10 - 11 - 11 14 15 14 15 - 11 - - 14 15 - -
11 - - - - 15 15 15 15 - - - - 15 15 15 -
12 - 13 14 15 - 13 14 15 - 13 14 15 - - - -
13 - - 15 15 - - 15 15 - - 15 15 - - 15 -
14 - 15 - 15 - 15 - 15 - 15 - 15 - 15 - -
15 - - - - - - - - - - - - - - - -
OR amount
0 0
1 0
2 0
3 1
4 0
5 1
6 1
7 6
8 0
9 1
10 1
11 6
12 1
13 6
14 6
15 25

## Sprites on screen-8

Screen-8 is a special case. It has a specific fixed palette for the sprites that is very similar to the ZX-Spectrum palette, so the resulting OR colors are fixed too. This is its complete table for this mode:

OR0123456789101112131415
0 - - - - - - - - - - - - - - - -
1 - - 3 - 5 - 7 - 9 - 11 - 13 - 15 -
2 - 3 - - 6 7 - - 10 11 - - 14 15 - -
3 - - - - 7 7 7 - 11 11 11 - 15 15 15 -
4 - 5 6 7 - - - - 12 1314 15 - - - -
5 - - 7 7 - - 7 - 13 13 15 15 13 - 15 -
6 - 7 - 7 - 7 - - 14 15 14 15 14 15 - -
7 - - - - - - - - 1515 15 15 15 15 15 -
8 - 9 10 11 12 13 14 15 - - - - - - - -
9 - - 11 11 13 13 15 15 - - 11 - 13 - 15 -
10 - 11 - 11 14 15 14 15 - 11 - - 14 15 - -
11 - - - - 15 15 15 15 - - - - 15 15 15 -
12 - 13 14 15 - 13 14 15 - 13 14 15 - - - -
13 - - 15 15 - - 15 15 - - 15 15 - - 15 -
14 - 15 - 15 - 15 - 15 - 15 - 15 - 15 - -
15 - - - - - - - - - - - - - - - -

# An MSX-BASIC example

A code explaining breifly how OR color works (also available at http://msxpen.com/?gist=e193eda297b0909af3f7c6c7348a0828 ):

```10 COLOR,0,0:SCREEN 5
20 SPRITE\$(0)=STRING\$(8,CHR\$(&B11111111)):SPRITEON
30 PUTSPRITE0,(100,100),4,0 ' blue
40 PUTSPRITE1,(106,100),2+64,0 ' green
50 A\$=INPUT\$(1)
60 END```

This code below is just for explaining how to start to experiment something as shown from the examples above. It is based on the Metal Gear’s Snake sprite as shown above. (this code is available at http://msxpen.com/?gist=45632734b2805011ecc54038b2980ae3 as well ):

```110 '--- Slot 0
130 DATA 00000011
131 DATA 00000111
132 DATA 00000101
133 DATA 00011101
134 DATA 00111100
135 DATA 00111110
136 DATA 01001111
137 DATA 01111110
138 DATA 00111011
139 DATA 01111001
140 DATA 10011111
141 DATA 10011111
142 DATA 10011100
143 DATA 01011111
144 DATA 01001111
145 DATA 00011011
150 DATA 10000000
151 DATA 11000000
152 DATA 11000000
153 DATA 11110000
154 DATA 11111000
155 DATA 11111000
156 DATA 11011100
157 DATA 11111100
158 DATA 10111100
159 DATA 11111100
160 DATA 11110100
161 DATA 11110100
162 DATA 01110100
163 DATA 11100100
164 DATA 11111000
165 DATA 11110000
170 ' attr 0
171 DATA 03,03,03,0E,0C,0E,0E,0E
172 DATA 0E,0E,0E,0E,03,0C,0E,0E
210 ' --- Slot 0
230 DATA 00000011
231 DATA 00000100
232 DATA 00000110
233 DATA 00011110
234 DATA 00100111
235 DATA 00000111
236 DATA 01110011
237 DATA 01000011
238 DATA 01001101
239 DATA 01101111
240 DATA 11111000
241 DATA 11111100
242 DATA 11111011
243 DATA 01101111
244 DATA 01111100
245 DATA 00010100
250 DATA 10000000
251 DATA 01000000
252 DATA 01000000
253 DATA 01110000
254 DATA 11001000
255 DATA 11001000
256 DATA 10100000
257 DATA 10000100
258 DATA 01010100
259 DATA 00011100
260 DATA 00111100
261 DATA 00111100
262 DATA 10111100
263 DATA 11111100
264 DATA 00111000
265 DATA 10010000
270 ' attr 0
271 DATA 4C,4C,4C,4D,4B,4B,4D,4B
272 DATA 4D,4D,43,4B,4C,4B,4B,4D
330 DATA 00011111
331 DATA 00010111
332 DATA 00011011
333 DATA 00010011
334 DATA 00010111
335 DATA 00011111
336 DATA 00011111
337 DATA 00011111
338 DATA 00011111
339 DATA 00011111
340 DATA 00011111
341 DATA 00110111
342 DATA 00111111
343 DATA 00110011
344 DATA 00011111
345 DATA 00000000
350 DATA 10110000
351 DATA 10110000
352 DATA 11110000
353 DATA 10110000
354 DATA 11110000
355 DATA 11100000
356 DATA 11100000
357 DATA 11100000
358 DATA 11100000
359 DATA 11110000
360 DATA 11111000
361 DATA 11111100
362 DATA 11111100
363 DATA 11111100
364 DATA 11111000
365 DATA 00000000
370 ' attr 1
371 DATA 0E,0E,0E,0E,0E,0E,0E,0E
372 DATA 0E,03,03,03,03,03,03,03
430 DATA 00010001
431 DATA 00011001
432 DATA 00000101
433 DATA 00011101
434 DATA 00011011
435 DATA 00010001
436 DATA 00011001
437 DATA 00010011
438 DATA 00010011
439 DATA 00011111
440 DATA 00010111
441 DATA 00111011
442 DATA 00110111
443 DATA 00111111
444 DATA 00011111
445 DATA 00000000
450 DATA 01010000
451 DATA 01010000
452 DATA 00010000
453 DATA 11010000
454 DATA 10010000
455 DATA 10100000
456 DATA 00100000
457 DATA 00100000
458 DATA 01100000
459 DATA 10110000
460 DATA 00111000
461 DATA 10011100
462 DATA 11111100
463 DATA 11111100
464 DATA 11111000
465 DATA 00000000
470 ' attr 1
471 DATA 4D,4D,4D,4D,4D,4D,4D,4D
472 DATA 4D,4C,4C,4C,4C,4C,4C,4C
491 SCREEN 4,3
492 color 7,6,1
493 CLS
500 color=( 0,0,0,0)
501 color=( 1,0,0,0)
502 color=( 2,4,3,0)
503 color=( 3,3,2,0)
504 color=( 4,1,1,1)
505 color=( 5,2,2,2)
506 color=( 6,3,3,3)
507 color=( 7,7,7,7)
508 color=( 8,3,3,3)
509 color=( 9,0,2,6)
510 color=(10,7,0,0)
511 color=(11,6,5,4)
512 color=(12,5,3,0)
513 color=(13,0,4,2)
514 color=(14,0,2,1)
515 color=(15,0,0,0)
1104 RESTORE
1105 FOR sn%=0to3
1200 b\$=""
1201 FOR r%=0to31
1203 nextr%
1204 sprite\$(sn%)=b\$
1300 b\$=""
1301 FOR r%=0to15