diff options
| author | Jan Tuomi <jans.tuomi@gmail.com> | 2024-02-22 08:52:20 +0200 |
|---|---|---|
| committer | Jan Tuomi <jans.tuomi@gmail.com> | 2024-02-22 08:52:20 +0200 |
| commit | 416e896956d3b05793337da6609fe1544797c0a9 (patch) | |
| tree | 9fa0cf3b622d4c9c086e4c08c5011ab12fdd4a77 /atk16_emu/test | |
| parent | aefe0cf3874c542669051b2b3cc21c9590aa970b (diff) | |
Add stuff, refactor
Diffstat (limited to 'atk16_emu/test')
| -rw-r--r-- | atk16_emu/test/test_opcode_alr.py | 4 | ||||
| -rw-r--r-- | atk16_emu/test/test_opcode_hlt.py | 4 | ||||
| -rw-r--r-- | atk16_emu/test/utils.py | 25 |
3 files changed, 4 insertions, 29 deletions
diff --git a/atk16_emu/test/test_opcode_alr.py b/atk16_emu/test/test_opcode_alr.py index e7fe1a7..9a34845 100644 --- a/atk16_emu/test/test_opcode_alr.py +++ b/atk16_emu/test/test_opcode_alr.py @@ -1,5 +1,5 @@ -from ..emu import Machine -from .utils import make_rom +from atk16_emu import Machine +from test.utils import make_rom def test_alr_add_small_unsigned(): machine = Machine() diff --git a/atk16_emu/test/test_opcode_hlt.py b/atk16_emu/test/test_opcode_hlt.py index 6991042..4d3d5c8 100644 --- a/atk16_emu/test/test_opcode_hlt.py +++ b/atk16_emu/test/test_opcode_hlt.py @@ -1,5 +1,5 @@ -from ..emu import Machine -from .utils import make_rom +from atk16_emu import Machine +from test.utils import make_rom def test_hlt(): machine = Machine() diff --git a/atk16_emu/test/utils.py b/atk16_emu/test/utils.py deleted file mode 100644 index 0d40d54..0000000 --- a/atk16_emu/test/utils.py +++ /dev/null @@ -1,25 +0,0 @@ -def pad_bytearray(to_length: int, ba: bytearray) -> bytearray: - """ - Pads a bytearray with zeros until it reaches a specified length. - - :param to_length: Target length in bytes. - :param ba: The bytearray to be padded. - :return: The padded bytearray. - """ - padding_size = to_length - len(ba) - if padding_size > 0: - ba.extend(b'\x00' * padding_size) - return ba - -def make_rom(words: list[int]) -> bytearray: - """ - Constructs a ROM image from a list of 16-bit words. - - :param words: The list of 16-bit words. - :return: The ROM image as a bytearray. - """ - bytes = [] - for word in words: - bytes.append((word >> 8) & 0xFF) - bytes.append(word & 0xFF) - return pad_bytearray(64 * 1024, bytearray(bytes))
\ No newline at end of file |
