示例#1
0
        public void WriteWord(int address, int width, int value)
        {
            Debug.Assert(address > 0x20);

            if ((address >= 0x08000000) && (address < 0x9FFFFFF))
            {
                address -= 0x08000000;
                fixed(byte *basePointer = _mainMemory)
                {
                    byte *ptr = basePointer + address;

                    if (width == 4)
                    {
                        int *p = ( int * )ptr;
                        *    p = value;
                    }
                    else if (width == 1)
                    {
                        *ptr = ( byte )value;
                    }
                    else if (width == 2)
                    {
                        short *p = ( short * )ptr;
                        *      p = ( short )value;
                    }
                    else
                    {
                        Debug.Assert(false, "Unsupported width");
                    }
                }
            }
            else if ((address >= 0x00010000) && (address < 0x00013FFF))
            {
                address -= 0x00010000;
                fixed(byte *basePointer = _scratchPad)
                {
                    byte *ptr = basePointer + address;

                    if (width == 4)
                    {
                        int *p = ( int * )ptr;
                        *    p = value;
                    }
                    else if (width == 1)
                    {
                        *ptr = ( byte )value;
                    }
                    else if (width == 2)
                    {
                        short *p = ( short * )ptr;
                        *      p = ( short )value;
                    }
                    else
                    {
                        Debug.Assert(false, "Unsupported width");
                    }
                }
            }
            else if ((address >= 0x04000000) && (address < 0x041FFFFF))
            {
                if (_frameBuffer != null)
                {
                    _frameBuffer.WriteWord(address, width, value);
                }
                else
                {
                    address -= 0x04000000;
                    fixed(byte *basePointer = _frameBufferBytes)
                    {
                        byte *ptr = basePointer + address;

                        if (width == 4)
                        {
                            int *p = ( int * )ptr;
                            *    p = value;
                        }
                        else if (width == 1)
                        {
                            *ptr = ( byte )value;
                        }
                        else if (width == 2)
                        {
                            short *p = ( short * )ptr;
                            *      p = ( short )value;
                        }
                        else
                        {
                            Debug.Assert(false, "Unsupported width");
                        }
                    }
                }
            }
            else
            {
                Debugger.Break();
            }

            //if( this->MemoryChanged != nullptr )
            //this->MemoryChanged( this, address, width, value );
        }