Off the top of my head:
If the high byte is 0, you get a random number as normal for an 8-bit value.
If the high bytes is not 0, get a random number as normal where the high byte is used by itself as an 8-but value. Use this as the "random high byte".
Then get a second random number that is always from 0 to FF.
Use this as the "random low byte".
Hmm... Not sure I understand step #2. >.< I might be able to grasp it better if you put it in ASM?
While trying to picture it, I remembered bit shifting. So for example, Effectivity is:
$01, $12 | #274
Shift that right...
$89 | #137
Then get a random number between $0 and $89
$61 | #97
Then shift it back left?
$C2 | #197
Then its $C2 + $12 for the low byte, $01 + #0 (to get the carry) for the high byte = $01, $D4 | #468
That seems to make sense, but I'm not sure if that's overpowered or Just Right or what!
Since I did bug fixes last, it was time to treat myself! Behold, randomized backdrop patterns!
Due to the nature of RNG, I capped it at 3 possible repeats in row. First attempt was uncapped and resulted in 5:
I imagine without a cap it would be possible to get a screen of only short or only tall trees, depending on how the RNG works (still using the 256 byte table.) So take picture #3 and the RNG basically popped out: 3, 1, 1, 1, [1 or 3], 3, 1, 1, 1, [1 or 3], 3, 1, 1, 1, [1 or 3], 3. Very silly.
Another Update: Did some fancy sprite work. Using a Soft, the character will now flash grey (in their normal pose) before turning the right colour. I could get them to flash in the Cheer pose, but its easier not to, and gives the little hint that they're softening up. This only happens with Soft items so far, not the spell; will update that next time.
Alarm Clock now calls a little routine that flashes the whole party. I will make Smokebombs use it too!! Easier than doing enemy explosion sprites over everyone. Segue!
I moved all character sprites in OAM to the bottom and took out the spaces between them again. I just don't see animated poison bubbles and stuff working well with the palette situation as it is now. Not to mention having 9 cursors pointing at enemies for variable magic will not leave enough room for that. There will be 4 tiles of sprites left! I moved all this so that the multiple cursor sprite can be loaded up contiguously. Groundwork is laid out for them to point to all -- HECK* -- enemy formations except fiends and Chaos. Should also work on the party. Just needs to be loaded up by the magic targeting routine, then called in a loop to keep them doing the ghost-y effect.
* I forgot to add something in so that cursors aren't pointing at empty enemy slots. Gonna do that before I go to bed.