diff --git a/docs/index.html b/docs/index.html
index 166887a2a..68daf3e75 100644
--- a/docs/index.html
+++ b/docs/index.html
@@ -68,7 +68,7 @@
class PyBoy
-(gamerom, *, window='SDL2', scale=3, symbols=None, bootrom=None, sound=False, sound_emulated=False, cgb=None, **kwargs)
+(gamerom, *, window='SDL2', scale=3, symbols=None, bootrom=None, sound=False, sound_emulated=False, cgb=None, log_level='ERROR', **kwargs)
-
PyBoy is loadable as an object in Python. This means, it can be initialized from another script, and be
@@ -100,6 +100,7 @@
Kwargs
- sound (bool): Enable sound emulation and output.
- sound_emulated (bool): Enable sound emulation without any output. Used for compatibility.
- cgb (bool): Forcing Game Boy Color mode.
+- log_level (str): "CRITICAL", "ERROR", "WARNING", "INFO" or "DEBUG"
- color_palette (tuple): Specify the color palette to use for rendering.
- cgb_color_palette (list of tuple): Specify the color palette to use for rendering in CGB-mode for non-color games.
@@ -120,6 +121,7 @@ Kwargs
sound=False,
sound_emulated=False,
cgb=None,
+ log_level=defaults["log_level"],
**kwargs
):
"""
@@ -154,6 +156,7 @@ Kwargs
* sound (bool): Enable sound emulation and output.
* sound_emulated (bool): Enable sound emulation without any output. Used for compatibility.
* cgb (bool): Forcing Game Boy Color mode.
+ * log_level (str): "CRITICAL", "ERROR", "WARNING", "INFO" or "DEBUG"
* color_palette (tuple): Specify the color palette to use for rendering.
* cgb_color_palette (list of tuple): Specify the color palette to use for rendering in CGB-mode for non-color games.
@@ -185,7 +188,7 @@ Kwargs
if k not in kwargs:
kwargs[k] = kwargs.get(k, defaults[k])
- log_level(kwargs.pop("log_level"))
+ _log_level(log_level)
if not os.path.isfile(gamerom):
raise FileNotFoundError(f"ROM file {gamerom} was not found!")
@@ -419,9 +422,10 @@ Kwargs
self.mb.breakpoint_reinject()
# NOTE: PC has not been incremented when hitting breakpoint!
- breakpoint_index = self.mb.breakpoint_reached()
- if breakpoint_index != -1:
- self.mb.breakpoint_remove(breakpoint_index)
+ breakpoint_meta = self.mb.breakpoint_reached()
+ if breakpoint_meta != (-1, -1, -1):
+ bank, addr, _ = breakpoint_meta
+ self.mb.breakpoint_remove(bank, addr)
self.mb.breakpoint_singlestep_latch = 0
if not self._handle_hooks():
@@ -1164,6 +1168,7 @@ Kwargs
raise ValueError("Hook already registered for this bank and address.")
self.mb.breakpoint_add(bank, addr)
bank_addr_opcode = (bank & 0xFF) << 24 | (addr & 0xFFFF) << 8 | (opcode & 0xFF)
+ logger.debug("Adding hook for opcode %08x", bank_addr_opcode)
self._hooks[bank_addr_opcode] = (callback, context)
def hook_deregister(self, bank, addr):
@@ -1196,12 +1201,12 @@ Kwargs
if bank is None and isinstance(addr, str):
bank, addr = self._lookup_symbol(addr)
- index = self.mb.breakpoint_find(bank, addr)
- if index == -1:
+ breakpoint_meta = self.mb.breakpoint_find(bank, addr)
+ if not breakpoint_meta:
raise ValueError("Breakpoint not found for bank and addr")
+ _, _, opcode = breakpoint_meta
- _, _, opcode = self.mb.breakpoints_list[index]
- self.mb.breakpoint_remove(index)
+ self.mb.breakpoint_remove(bank, addr)
bank_addr_opcode = (bank & 0xFF) << 24 | (addr & 0xFFFF) << 8 | (opcode & 0xFF)
self._hooks.pop(bank_addr_opcode)
@@ -2466,6 +2471,7 @@ Args
raise ValueError("Hook already registered for this bank and address.")
self.mb.breakpoint_add(bank, addr)
bank_addr_opcode = (bank & 0xFF) << 24 | (addr & 0xFFFF) << 8 | (opcode & 0xFF)
+ logger.debug("Adding hook for opcode %08x", bank_addr_opcode)
self._hooks[bank_addr_opcode] = (callback, context)
@@ -2529,12 +2535,12 @@ Args
if bank is None and isinstance(addr, str):
bank, addr = self._lookup_symbol(addr)
- index = self.mb.breakpoint_find(bank, addr)
- if index == -1:
+ breakpoint_meta = self.mb.breakpoint_find(bank, addr)
+ if not breakpoint_meta:
raise ValueError("Breakpoint not found for bank and addr")
+ _, _, opcode = breakpoint_meta
- _, _, opcode = self.mb.breakpoints_list[index]
- self.mb.breakpoint_remove(index)
+ self.mb.breakpoint_remove(bank, addr)
bank_addr_opcode = (bank & 0xFF) << 24 | (addr & 0xFFFF) << 8 | (opcode & 0xFF)
self._hooks.pop(bank_addr_opcode)
diff --git a/pyboy/__main__.py b/pyboy/__main__.py
index 9fe431e04..dbcc1dfd0 100644
--- a/pyboy/__main__.py
+++ b/pyboy/__main__.py
@@ -47,7 +47,7 @@ def valid_file_path(path):
"--log-level",
default=defaults["log_level"],
type=str,
- choices=["ERROR", "WARNING", "INFO", "DEBUG", "DISABLE"],
+ choices=["CRITICAL", "ERROR", "WARNING", "INFO", "DEBUG"],
help="Set logging level"
)
parser.add_argument(
diff --git a/pyboy/logging/__init__.py b/pyboy/logging/__init__.py
index 6c30a6130..91e09b7a3 100644
--- a/pyboy/logging/__init__.py
+++ b/pyboy/logging/__init__.py
@@ -36,6 +36,8 @@ def log_level(level):
level = ERROR
elif level == "CRITICAL":
level = CRITICAL
+ elif level == "DISABLE":
+ level = CRITICAL
elif isinstance(level, int):
pass
else:
diff --git a/pyboy/pyboy.py b/pyboy/pyboy.py
index d03c84450..2efb103d4 100644
--- a/pyboy/pyboy.py
+++ b/pyboy/pyboy.py
@@ -16,7 +16,8 @@
from pyboy.api.memory_scanner import MemoryScanner
from pyboy.api.screen import Screen
from pyboy.api.tilemap import TileMap
-from pyboy.logging import get_logger, log_level
+from pyboy.logging import get_logger
+from pyboy.logging import log_level as _log_level
from pyboy.plugins.manager import PluginManager, parser_arguments
from pyboy.utils import IntIOWrapper, WindowEvent
@@ -49,6 +50,7 @@ def __init__(
sound=False,
sound_emulated=False,
cgb=None,
+ log_level=defaults["log_level"],
**kwargs
):
"""
@@ -83,6 +85,7 @@ def __init__(
* sound (bool): Enable sound emulation and output.
* sound_emulated (bool): Enable sound emulation without any output. Used for compatibility.
* cgb (bool): Forcing Game Boy Color mode.
+ * log_level (str): "CRITICAL", "ERROR", "WARNING", "INFO" or "DEBUG"
* color_palette (tuple): Specify the color palette to use for rendering.
* cgb_color_palette (list of tuple): Specify the color palette to use for rendering in CGB-mode for non-color games.
@@ -114,7 +117,7 @@ def __init__(
if k not in kwargs:
kwargs[k] = kwargs.get(k, defaults[k])
- log_level(kwargs.pop("log_level"))
+ _log_level(log_level)
if not os.path.isfile(gamerom):
raise FileNotFoundError(f"ROM file {gamerom} was not found!")