In the emulator

With openMSX and the Philips_VG_8020 machine:

echo 3 > work/fase.txt
openmsx -machine Philips_VG_8020 -cart magicaltree.rom -script tools/omsx_fases.tcl

tools/omsx_fases.tcl:

The whole game happens in the hook at 0x402C: a breakpoint there stops once per frame.

A warning: if a breakpoint's command fails, openMSX freezes the emulation. The script wraps its commands in catch and logs the error in work/fases/log.txt.