示例#1
0
        internal void HandleMemoryChange(MMR mappedRegister, byte value)
        {
            switch (mappedRegister)
            {
            case MMR.LCDC:
                // We set all the LCDC bits
                for (int i = 0; i < 8; ++i)
                {
                    _state.LCDCBits[i] = (value & (1 << i)) != 0;
                }
                break;

            case MMR.STAT:
                _state.STAT = value;
                break;

            case MMR.SCY:
                _state.SCY = value;
                break;

            case MMR.SCX:
                _state.SCX = value;
                break;

            case MMR.LY:
                _state.CurrentLine = 0;
                break;

            case MMR.LYC:
                _state.LYC = value;
                break;

            case MMR.DMA:
                LoadSprites();
                break;

            case MMR.BGP:
                DisFuncs.SetupTilePallete(_disDef, _memory);
                break;

            case MMR.OBP0:
                DisFuncs.SetupSpritePalletes(_disDef, _memory, MMR.OBP0);
                break;

            case MMR.OBP1:
                DisFuncs.SetupSpritePalletes(_disDef, _memory, MMR.OBP1);
                break;

            case MMR.WY:
                _state.WY = value;
                break;

            case MMR.WX:
                _state.WX = value;
                break;

            default:
                throw new InvalidProgramException("All cases should be handled...");
            }
        }