Y subpixels roll "randomly" every frame, like in Duck Tales and Chip'n'Dale.
$E4-$E7 get RORed every gameplay frame, and sometimes additional small manipulations are done with either
$E6-$E7 whenever random even is about to occur (item drops from dying enemies, bosses actions).
End values can be affected by killing enemies at different frames, by spawning enemies that roll RNG at different frames.
Each boss has his own randomness (if any) and can't be manipulated during the fight. But they roll their RNG routines at fixed time relatively to boss room start, so by entering it at different frames one should be able to manipulate the pattern the boss will take during the whole fight.
He moves around the screen, then whenever he reaches position 0x40, 0x80, or 0xC0, he rolls RNGs 3 and 4, puts to Y register, reads from
$9F6F + Y register what he should do: show up or resume swimming.
Runs around a platform until you step on it, the next frame jumps up or down from it. If he is at the top, he will jump down, if at the bottom, he will jump up, but if he is in the middle, he rolls RNGs 1 and 2, puts to Y register, then reads from
$9969 + Y register for whether he should jump up or down.
Is vulnerable only when the Moon is covered with a cloud, which travels by the rule: when the room fades in, the cloud is covering the Moon, and the timer ticks from 78 to 0 every frame, then the cloud starts moving left around the screen. When it reaches the Moon again, it counts down from 0xB4 to 0 and starts moving again.
Jumps on a middle platform, rolls RNGs 3 and 4, puts result to Y register, reads from
$AA69 + Y register for whether he should jump up or stay on the platform. Then shoots from the platform he's on and walks off to cross the screen and jump on the other middle platform, to roll RNG once again.
Starts fixing whichever machine gets broken. Walks around the platform until you touch it, then he throws a hammer in you and jumps away. His behavior doesn't really matter, since even with default gun he dies in one cycle.
At certain moments, while jumping,
$049F decrements from 7 to 0. If Bushroot is jumping when that address is 6, 4, or 2, he will roll RNGs 1 and 2, write the result to Y register, then read from
$A83F for what he should do next.
His behavior also doesn't matter, since bullets can reach him from the back after going through him.
a = 0x400 + slot
facing = getb(a,0x000)
timer1 = getb(a,0x010)
state = getb(a,0x020)
timer2 = getb(a,0x030)
yScr = getb(a,0x040)
xScr = getb(a,0x050)
ySub = getb(a,0x060)
xSub = getb(a,0x070)
timer3 = getb(a,0x080)
action = getb(a,0x0d0)
xPos = getw(a,0x0f0)
yPos = getw(a,0x110)
xVelSub = getb(a,0x130)
xVel = getb(a,0x140)
yVelSub = getb(a,0x150)/256
yVel = memory.readbytesigned(a+0x160)
id = getb(a,0x170)
if yVel >= 0
then ySpd = yVel + yVelSub
else ySpd = yVel - yVelSub
if action > 0 then
"X: %04d.%d\nY: %04d.%03d\nS: %.3f",
rng1 = memory.readbyte(0xe4)
rng2 = memory.readbyte(0xe5)
rng3 = memory.readbyte(0xe6)
rng4 = memory.readbyte(0xe7)
xCam = memory.readword(0xfc)
yCam = memory.readword(0xfa)
bossInv = memory.readbyte(0xed)
bossHP = memory.readbyte(0xee)
bossSlot = memory.readbyte(0xef)
bossX = memory.readbyte(0x450+bossSlot)
bossY = memory.readbyte(0x440+bossSlot)
if bossHP > 0 then