mirror of
https://github.com/autinerd/game_and_watch_emulator.git
synced 2025-12-16 07:16:26 +01:00
20 lines
581 B
Python
20 lines
581 B
Python
from abc import ABC, abstractmethod
|
|
|
|
class Periph(ABC):
|
|
@abstractmethod
|
|
def read_mem(self, address: int, size: int) -> int:
|
|
"""
|
|
Returns data to be read by the firmware.
|
|
"""
|
|
pass
|
|
|
|
@abstractmethod
|
|
def write_mem(self, address: int, size: int, data: int):
|
|
"""
|
|
Returns data to be read by the firmware.
|
|
"""
|
|
pass
|
|
|
|
def set_reg(self, reg_name: str, mask: int, value: int):
|
|
if reg_name in vars(self):
|
|
vars(self)[reg_name] = (value & mask) | (vars(self)[reg_name] & (~mask & 0xFFFF_FFFF)) |