Hard to be sure, but I doubt that's something specifically coded into the game. Each sword's palette is the same as its level-1, and its power is 8<<level. The only difference between them that requires different handling in the code is the icon tiles. It does show a non-magical sword icon, but there's no telling whether that means anything.
It's using the palette that corresponds to CSet 9 in ZC. They probably wouldn't have used it deliberately for the same reason you wouldn't do that in ZC.
Later update: I tried playing with it myself. He was wrong about something: setting it to 5 does not wrap back around to the wooden sword. It uses the same palette (which makes sense, because it definitely only uses two bits for those), but the behavior is different. It does no damage. That fits with what I suggested above; 8<<5 overflows and becomes 0. It does still cause enemies to flash and be knocked back. Oddly, the beams still do damage, but only as much as the wooden sword's.
Setting the sword to level 7, the one that would wrap back around to the magical sword, produces a sword that uses the magical sword's palette with the other swords' sprite. That suggests the code that draws the sword is specifically checking if level==3.
It seems to be that the sword's level (minus 1) is given directly to the PPU as the sprites' attribute bytes, which means higher values are more interesting, because the upper nibble sets the sprite flags. Sword 21 is drawn behind the background. Sword 81 is drawn upside-down.
Damage gets a bit more complicated for the higher level swords. Level 5 does no damage, level 6 does twice the magic sword's damage, level 7 does 1/16 the wooden sword's damage. Sword FF takes three hits to kill a red octorock, which isn't possible with powers of two. I would guess it has something to do with the carry bit being set, which isn't normally possible, but I'm not certain a simple ROL and counter would explain it.
Other leveled items exhibit similar behavior.
That's a potion with 255 uses. Arrows fired from that bow are drawn behind the background.
The candle doesn't do anything interesting; it's just the plain old red candle. I suspect that's because the fire sprite is separate from the candle sprite, so it doesn't have the flags applied.
The boomerang's especially interesting. The regular and magic boomerangs are separate items. The regular one is always the same, no matter its value. The magic boomerang's icon never changes, but its thrown sprite does change palettes and flags. So apparently the magic boomerang is considered a leveled item and the regular one isn't.
Edited by Saffith, 05 April 2017 - 12:02 PM.