コード例 #1
0
        private void ShockMemCallback(uint address, OctoshockDll.eShockMemCb type, uint size, uint value)
        {
            MemoryCallbackFlags flags = 0;

            switch (type)
            {
            case OctoshockDll.eShockMemCb.Read:
                flags |= MemoryCallbackFlags.AccessRead;
                break;

            case OctoshockDll.eShockMemCb.Write:
                flags |= MemoryCallbackFlags.AccessWrite;
                break;

            case OctoshockDll.eShockMemCb.Execute:
                flags |= MemoryCallbackFlags.AccessExecute;
                break;
            }

            MemoryCallbacks.CallMemoryCallbacks(address, value, (uint)flags, "System Bus");
        }
コード例 #2
0
        public void frame_advance()
        {
            if (!emulator_running)
            {
                return;
            }

            event_frameend = false;
            m64pCoreDoCommandPtr(m64p_command.M64CMD_ADVANCE_FRAME, 0, IntPtr.Zero);

            //the way we should be able to do it:
            //m64pFrameComplete.WaitOne();

            //however. since this is probably an STAThread, this call results in message pumps running.
            //those message pumps are only supposed to respond to critical COM stuff, but in fact they interfere with other things.
            //so here are two workaround methods.

            //method 1.
            //BizHawk.Common.Win32ThreadHacks.HackyPinvokeWaitOne(m64pFrameComplete);

            //method 2.
            //BizHawk.Common.Win32ThreadHacks.HackyComWaitOne(m64pFrameComplete);

            for (;;)
            {
                BizHawk.Common.Win32ThreadHacks.HackyPinvokeWaitOne(m64pEvent, 200);
                if (event_frameend)
                {
                    break;
                }
                if (event_breakpoint)
                {
                    MemoryCallbackFlags flags = 0;
                    switch (_breakparams._type)
                    {
                    case BreakType.Read:
                        flags |= MemoryCallbackFlags.AccessRead;
                        break;

                    case BreakType.Write:
                        flags |= MemoryCallbackFlags.AccessWrite;
                        break;

                    case BreakType.Execute:
                        flags |= MemoryCallbackFlags.AccessExecute;
                        break;
                    }

                    _breakparams._mcs.CallMemoryCallbacks(_breakparams._addr, 0, (uint)flags, "System Bus");

                    event_breakpoint = false;
                    Resume();
                    continue;
                }
                //no event.. must be a timeout
                //check if the core crashed and bail if it did
                //otherwise wait longer (could be inside slow emulation or lua logic)
                if (!emulator_running)
                {
                    break;
                }
            }
        }
コード例 #3
0
        private LibGambatte.MemoryCallback CreateCallback(MemoryCallbackFlags flags, Func <bool> getHasCBOfType, string which = "")
        {
            var rawFlags = (uint)flags;

            return((address, cycleOffset) =>
            {
                callbackCycleCount = _cycleCount + cycleOffset;
                if (getHasCBOfType())
                {
                    MemoryCallbacks.CallMemoryCallbacks(address, 0, rawFlags, which + "System Bus");
                    var bank = LibGambatte.gambatte_getaddrbank(GambatteState, (ushort)address);
                    if (address < 0x4000u)                     // usually rom bank 0 for most mbcs, some mbcs might have this at a different rom bank
                    {
                        address += (uint)(bank * 0x4000);
                        MemoryCallbacks.CallMemoryCallbacks(address, 0, rawFlags, which + "ROM");
                    }
                    else if (address < 0x8000u)                     // rom bank x
                    {
                        address += (uint)(bank * 0x4000);
                        address -= 0x4000u;
                        MemoryCallbacks.CallMemoryCallbacks(address, 0, rawFlags, which + "ROM");
                    }
                    else if (address < 0xA000u)                     // vram (may be banked on CGB in CGB enhanced mode)
                    {
                        if (IsCGBMode() && !IsCGBDMGMode())
                        {
                            address += (uint)(bank * 0x2000);
                        }
                        address -= 0x8000u;
                        MemoryCallbacks.CallMemoryCallbacks(address, 0, rawFlags, which + "VRAM");
                    }
                    else if (address < 0xC000u)                     // sram (may be banked)
                    {
                        address += (uint)(bank * 0x2000);
                        address -= 0xA000u;
                        MemoryCallbacks.CallMemoryCallbacks(address, 0, rawFlags, which + "SRAM");
                    }
                    else if (address < 0xD000u)                     // wram bank 0
                    {
                        address -= 0xC000u;
                        MemoryCallbacks.CallMemoryCallbacks(address, 0, rawFlags, which + "WRAM");
                    }
                    else if (address < 0xE000u)                     // wram bank x (always one for dmg/cgb in dmg mode)
                    {
                        if (IsCGBMode() && !IsCGBDMGMode())
                        {
                            address += (uint)(bank * 0x1000);
                        }
                        address -= 0xD000u;
                        MemoryCallbacks.CallMemoryCallbacks(address, 0, rawFlags, which + "WRAM");
                    }
                    else if (address < 0xFE00u)                     // echo ram
                    {
                        // do we do something here?
                    }
                    else if (address < 0xFEA0u)                     // oam
                    {
                        address -= 0xFE00u;
                        MemoryCallbacks.CallMemoryCallbacks(address, 0, rawFlags, which + "OAM");
                    }
                    else if (address < 0xFF00u)                     // "extra" oam
                    {
                        // do we do something here?
                    }
                    else if (address < 0xFF80u)                     // mmio
                    {
                        // do we do something here?
                    }
                    else if (address < 0xFFFF)                     // hram
                    {
                        address -= 0xFF80u;
                        MemoryCallbacks.CallMemoryCallbacks(address, 0, rawFlags, which + "HRAM");
                    }
                    else if (address == 0xFFFF)                     // ie reg
                    {
                        // do we do something here?
                    }
                    else
                    {
                        throw new InvalidOperationException("Core accessed invalid address???");
                    }
                }
            });
        }
コード例 #4
0
ファイル: Gambatte.IDebuggable.cs プロジェクト: gocha/BizHawk
        private LibGambatte.MemoryCallback CreateCallback(MemoryCallbackFlags flags, Func <bool> getHasCBOfType, string which = "")
        {
            var rawFlags = (uint)flags;

            return((address, cycleOffset) =>
            {
                callbackCycleCount = _cycleCount + cycleOffset;
                if (getHasCBOfType())
                {
                    MemoryCallbacks.CallMemoryCallbacks(address, 0, rawFlags, which + "System Bus");
                    if (address < 0x4000u)                     // always rom bank 0 for most mbcs (todo: edge mbcs where this doesn't apply)
                    {
                        MemoryCallbacks.CallMemoryCallbacks(address, 0, rawFlags, which + "ROM");
                    }
                    else if (address < 0x8000u)                                    // rom bank x
                    {
                        var bank = LibGambatte.gambatte_getrombank(GambatteState); // this will return 1 in case there is no mbc (0 is valid for some mbcs too)
                        address += (uint)(bank * 0x4000);
                        address -= 0x4000u;
                        MemoryCallbacks.CallMemoryCallbacks(address, 0, rawFlags, which + "ROM");
                    }
                    else if (address < 0xA000u)                     // vram (may be banked on CGB in CGB enhanced mode)
                    {
                        if (IsCGBMode() && !IsCGBDMGMode())
                        {
                            var bank = LibGambatte.gambatte_cpuread(GambatteState, 0xFF4F) & 1;
                            address += (uint)(bank * 0x2000);
                        }
                        address -= 0x8000u;
                        MemoryCallbacks.CallMemoryCallbacks(address, 0, rawFlags, which + "VRAM");
                    }
                    else if (address < 0xC000u)                                     // sram (may be banked)
                    {
                        var bank = LibGambatte.gambatte_getsrambank(GambatteState); // this will return 0 in case there is only one bank
                        address += (uint)(bank * 0x2000);
                        address -= 0xA000u;
                        MemoryCallbacks.CallMemoryCallbacks(address, 0, rawFlags, which + "SRAM");
                    }
                    else if (address < 0xD000u)                     // wram bank 0
                    {
                        address -= 0xC000u;
                        MemoryCallbacks.CallMemoryCallbacks(address, 0, rawFlags, which + "WRAM");
                    }
                    else if (address < 0xE000u)                     // wram bank x (always one for dmg/cgb in dmg mode)
                    {
                        if (IsCGBMode() && !IsCGBDMGMode())
                        {
                            var bank = Math.Max(LibGambatte.gambatte_cpuread(GambatteState, 0xFF70) & 7, 1);
                            address += (uint)(bank * 0x1000);
                        }
                        address -= 0xD000u;
                        MemoryCallbacks.CallMemoryCallbacks(address, 0, rawFlags, which + "WRAM");
                    }
                    else if (address < 0xFE00u)                     // echo ram
                    {
                        // do we do something here?
                    }
                    else if (address < 0xFEA0u)                     // oam
                    {
                        address -= 0xFE00u;
                        MemoryCallbacks.CallMemoryCallbacks(address, 0, rawFlags, which + "OAM");
                    }
                    else if (address < 0xFF00u)                     // "extra" oam
                    {
                        // do we do something here?
                    }
                    else if (address < 0xFF80u)                     // mmio
                    {
                        // do we do something here?
                    }
                    else if (address < 0xFFFF)                     // hram
                    {
                        address -= 0xFF80u;
                        MemoryCallbacks.CallMemoryCallbacks(address, 0, rawFlags, which + "HRAM");
                    }
                    else if (address == 0xFFFF)                     // ie reg
                    {
                        // do we do something here?
                    }
                    else
                    {
                        throw new InvalidOperationException("Core accessed invalid address???");
                    }
                }
            });
        }