Copypasta from what I posted on SDA:
Below is the RNG sequence in SPO. It calls this most frames while the game is active, regardless of whether you're in a fight or not.
00b15a jsr $ccb7 [00ccb7] A:0002 X:0000 //Start RNG sequence
00ccb7 lda #$00 A:0002 X:0000 //Clear the accumulator
00ccb9 xba A:0000 X:0000 //Clear X
00ccba lda $0090 [000090] A:0000 X:0000 //Load the Button Masks
00ccbd clc A:0000 X:0000
00ccbe adc $0091 [000091] A:0000 X:0000 //Add to the Direction Masks
00ccc1 adc $004e [00004e] A:0040 X:0000 //Add to current Button Sum
00ccc4 sta $004e [00004e] A:0089 X:0000 //Store back into Button Sum
00ccc7 lda $0043 [000043] A:0089 X:0000 //Load decrementing frame counter
00ccca sbc $004e [00004e] A:00c7 X:0000 //Subtract the Button Sum
00cccd tax A:003d X:0000 //Transfer Accumulator to X
00ccce lda $bc2f,x [00bc6c] A:003d X:003d //Load from RNG Table
00ccd1 sta $004d [00004d] A:0085 X:003d //Store into RNG address
00ccd4 rts A:0085 X:003d //End subroutine
Different buttons correspond to different bits in the Button/Direction Masks. Pressing multiple buttons/directions at the same time will have both bits be set for as many frames as they are held. It also means that not pressing any buttons will make the Button Sum not change. The RNG Table is at 0x00003C2F in the ROM.