diff --git a/README.md b/README.md index cd0b335..ea82bc9 100644 --- a/README.md +++ b/README.md @@ -24,6 +24,7 @@ 3. [Jump Quirks](#jump-quirks) 4. [Clip Quirks](#clip-quirks) 5. [Logic Quirks](#logic-quirks) + 5. [Memory Size](#memory-size) 5. [Customization](#customization) 1. [Keys](#keys) 2. [Debug Keys](#debug-keys) @@ -294,6 +295,15 @@ such as AND, OR, and XOR. By default, F is left undefined following these operat With the flag turned on, F will always be cleared. +### Memory Size + +The original specification of the Chip8 language defined a 4K memory size for the +interpreter. The addition of the XO Chip extensions require a 64K memory size +for the interpreter. By default, the interpreter will start with a 64K memory size, +but this behavior can be controlled with the `--mem_size` flag. Valid options are +`64K` or `4K` for historical purposes. + + ## Customization The file `chip8/config.py` contains several variables that can be changed to diff --git a/chip8/cpu.py b/chip8/cpu.py index 1c4d11b..858bfa3 100644 --- a/chip8/cpu.py +++ b/chip8/cpu.py @@ -6,8 +6,6 @@ """ # I M P O R T S ############################################################### -import pygame - from pygame import key from random import randint @@ -69,7 +67,7 @@ def __init__( jump_quirks=False, clip_quirks=False, logic_quirks=False, - mem_size="4K" + mem_size="64K" ): """ Initialize the Chip8 CPU. The only required parameter is a screen diff --git a/test/test_chip8cpu.py b/test/test_chip8cpu.py index 2127c9d..10782b1 100644 --- a/test/test_chip8cpu.py +++ b/test/test_chip8cpu.py @@ -9,7 +9,6 @@ import mock import pygame import unittest -import collections from mock import patch, call @@ -35,6 +34,9 @@ def setUp(self): self.cpu = Chip8CPU(self.screen) self.cpu_spy = mock.Mock(wraps=self.cpu) + def test_memory_size_default_64k(self): + self.assertEqual(65536, len(self.cpu.memory)) + def test_return_from_subroutine(self): for address in range(0x200, 0xFFFF, 0x10): self.cpu.memory[self.cpu.sp] = address & 0x00FF diff --git a/yac8e.py b/yac8e.py index c19cd8b..8a03e9c 100755 --- a/yac8e.py +++ b/yac8e.py @@ -57,8 +57,8 @@ def parse_arguments(): action="store_true", dest="logic_quirks" ) parser.add_argument( - "--mem_size", help="Maximum memory size (4K default)", - dest="mem_size", choices=["4K", "64K"], default="4K" + "--mem_size", help="Maximum memory size (64K default)", + dest="mem_size", choices=["4K", "64K"], default="64K" ) parser.add_argument( "--trace", help="print registers and instructions to STDOUT",