예제 #1
0
        public void PeekPoke()
        {
            var mem = new MemoryModule();

            mem.InitRam();

            byte writeVal = (byte)Random.Range(1, 255);

            mem.Poke(MemoryModule.ADDR_GENERAL, writeVal);
            byte readVal = mem.Peek(MemoryModule.ADDR_GENERAL);

            Assert.AreEqual(writeVal, readVal);
        }
예제 #2
0
        public void MemSet()
        {
            var mem = new MemoryModule();

            mem.InitRam();

            mem.MemSet(MemoryModule.ADDR_GENERAL, 128, 64);

            for (int i = 0; i < 64; i++)
            {
                byte val = mem.Peek(MemoryModule.ADDR_GENERAL + i);

                Assert.AreEqual(128, val);
            }
        }
예제 #3
0
        private void PullFrame()
        {
            int framePointer = MemoryModule.ADDR_MUSIC + frame_n * 4;

            int ch_0 = mem.Peek(framePointer);
            int ch_1 = mem.Peek(framePointer + 1);
            int ch_2 = mem.Peek(framePointer + 2);
            int ch_3 = mem.Peek(framePointer + 3);

            bool ch_0_en = (ch_0 & 0x40) == 0; //bit 6
            bool ch_1_en = (ch_1 & 0x40) == 0; //bit 6
            bool ch_2_en = (ch_2 & 0x40) == 0; //bit 6
            bool ch_3_en = (ch_3 & 0x40) == 0; //bit 6

            int ch_0_sfx = ch_0 & 0x3F;        //bits 0 - 5
            int ch_1_sfx = ch_1 & 0x3F;        //bits 0 - 5
            int ch_2_sfx = ch_2 & 0x3F;        //bits 0 - 5
            int ch_3_sfx = ch_3 & 0x3F;        //bits 0 - 5

            if (ch_0_en)
            {
                channelManager.GetChannel(0).Sfx(ch_0_sfx);
            }
            if (ch_1_en)
            {
                channelManager.GetChannel(1).Sfx(ch_1_sfx);
            }
            if (ch_2_en)
            {
                channelManager.GetChannel(2).Sfx(ch_2_sfx);
            }
            if (ch_3_en)
            {
                channelManager.GetChannel(3).Sfx(ch_3_sfx);
            }

            playingOnChanels[0] = ch_0_en;
            playingOnChanels[1] = ch_1_en;
            playingOnChanels[2] = ch_2_en;
            playingOnChanels[3] = ch_3_en;
        }