Пример #1
0
        public void CanSetSpriteAtByteBorderBit()
        {
            var sprite = new byte[5];
            sprite[0] = 0xff;

            var display = new TestDisplay();

            var cpu = new CPU(new Memory(), display, null);
            cpu.SetSprite(8, 0, sprite, 1);

            // 0      1       2       3
            // 0000000011111110000000000000000
            // 0x0    0xff   0x0     0x0
            Assert.AreEqual(0xff, display.Screen[1]);
        }
Пример #2
0
        public void CanSetSprite1()
        {
            var sprite = new byte[5];
            sprite[0] = 0x20;
            sprite[1] = 0x60;
            sprite[2] = 0x20;
            sprite[3] = 0x20;
            sprite[4] = 0x70;

            var display = new TestDisplay();

            var cpu = new CPU(new Memory(), display, null);
            cpu.SetSprite(4, 4, sprite, 5);

            display.Print();
        }
Пример #3
0
        public void CanSetSpriteAtOddBit()
        {
            var sprite = new byte[5];
            sprite[0] = 0xff;

            var display = new TestDisplay();

            var cpu = new CPU(new Memory(), display, null);
            cpu.SetSprite(10, 0, sprite, 1);
            display.Print();
            // 0      1       2       3
            // 0000000000111111100000000000000
            // 0000000011111110000000011000000 msb -> lsb
            // 0x0    0x3f   0xc0     0x0

            Assert.AreEqual(0xfc, display.Screen[1]);
            Assert.AreEqual(0x03, display.Screen[2]);
        }
Пример #4
0
        public void CanWrapSpriteAtY()
        {
            var sprite = new byte[5];
            sprite[0] = 0xff;
            sprite[1] = 0xff;

            var display = new TestDisplay();

            var cpu = new CPU(new Memory(), display, null);
            cpu.SetSprite(0, 31, sprite, 2);

            Assert.AreEqual(0xff, display.Screen[31*8]);
            Assert.AreEqual(0xff, display.Screen[0]);
        }
Пример #5
0
        public void CanWrapSpriteAtX()
        {
            var sprite = new byte[5];
            sprite[0] = 0xff;

            var display = new TestDisplay();

            var cpu = new CPU(new Memory(), display, null);
            cpu.SetSprite(62, 0, sprite, 1);

            // 62        63      |64       65
            // 11111100 00000000 |00000000 00000011
            // 00111111 00000000 |00000000 11000000 lsb
            // 0xfc   0x0     0x0      0x3
            display.Print();
            Assert.AreEqual(0xc0, display.Screen[7]);
            Assert.AreEqual(0x3f, display.Screen[0]);
        }