This is a game-wrapper plugin for PyBoy specifically for Pokemon Red/Blue.
It currently requires a slightly modified PyBoy version which handles external python plugins and accepts callbacks on each cycle.
You can find it here: https://github.com/Pokeglitch/PyBoy
Simply import the script and, as long you are using the above modified PyBoy module, it will automatically add itself to the list of PyBoy plugins.
import PyBoyPokered
Create a new pyboy instance and ensure the game_wrapper flag is enabled: (Note, ROM file is not included)
import pyboy
p = pyboy.PyBoy("pokered.gb", game_wrapper=True)
Access the plugin:
pokered = p.plugin_manager.get_plugin("PyBoyPokered")
A breakpoint can be added based on the name of the address (from the .sym file) using the Breakpoints submodule:
pokered.Breakpoints.add("OakSpeech", lambda: print("New Game Detected"))
It will execute the callbacks everytime the CPU reaches that address