diff --git a/BizHawk.Client.Common/lua/EmuLuaLibrary.MainMemory.cs b/BizHawk.Client.Common/lua/EmuLuaLibrary.MainMemory.cs index b69f4f1a06..85efa93bf5 100644 --- a/BizHawk.Client.Common/lua/EmuLuaLibrary.MainMemory.cs +++ b/BizHawk.Client.Common/lua/EmuLuaLibrary.MainMemory.cs @@ -50,9 +50,9 @@ namespace BizHawk.Client.Common "getcurrentmemorydomainsize", "Returns the number of bytes of the domain defined as main memory" )] - public int GetSize() + public uint GetSize() // int to long TODO: test this and think about it more { - return Domain.Size; + return (uint)Domain.Size; } #endregion diff --git a/BizHawk.Client.Common/lua/EmuLuaLibrary.Memory.cs b/BizHawk.Client.Common/lua/EmuLuaLibrary.Memory.cs index 94bdc671b1..b6e0322a24 100644 --- a/BizHawk.Client.Common/lua/EmuLuaLibrary.Memory.cs +++ b/BizHawk.Client.Common/lua/EmuLuaLibrary.Memory.cs @@ -84,9 +84,9 @@ namespace BizHawk.Client.Common "getcurrentmemorydomainsize", "Returns the number of bytes of the current memory domain selected by Lua. The default is Main memory" )] - public int GetCurrentMemoryDomainSize() + public uint GetCurrentMemoryDomainSize() // int to long TODO: test this and think about it more { - return Domain.Size; + return (uint)Domain.Size; } [LuaMethodAttributes( diff --git a/BizHawk.Client.Common/tools/RamSearchEngine.cs b/BizHawk.Client.Common/tools/RamSearchEngine.cs index cc34b39ca5..8eab9150b7 100644 --- a/BizHawk.Client.Common/tools/RamSearchEngine.cs +++ b/BizHawk.Client.Common/tools/RamSearchEngine.cs @@ -68,7 +68,7 @@ namespace BizHawk.Client.Common listSize /= (int)_settings.Size; } - _watchList = new List(listSize); + _watchList = new List((int)listSize); switch (_settings.Size) { diff --git a/BizHawk.Client.EmuHawk/CustomControls/HexTextBox.cs b/BizHawk.Client.EmuHawk/CustomControls/HexTextBox.cs index 1a9beb4a92..be81b8b9f5 100644 --- a/BizHawk.Client.EmuHawk/CustomControls/HexTextBox.cs +++ b/BizHawk.Client.EmuHawk/CustomControls/HexTextBox.cs @@ -18,7 +18,7 @@ namespace BizHawk.Client.EmuHawk public class HexTextBox : TextBox, INumberBox { private string _addressFormatStr = string.Empty; - private int? _maxSize; + private long? _maxSize; private bool _nullable = true; public HexTextBox() @@ -28,7 +28,7 @@ namespace BizHawk.Client.EmuHawk public bool Nullable { get { return _nullable; } set { _nullable = value; } } - public void SetHexProperties(int domainSize) + public void SetHexProperties(long domainSize) { _maxSize = domainSize - 1; MaxLength = _maxSize.Value.NumHexDigits(); diff --git a/BizHawk.Client.EmuHawk/tools/Debugger/AddBreakpointDialog.cs b/BizHawk.Client.EmuHawk/tools/Debugger/AddBreakpointDialog.cs index 5853253db7..048b8f879c 100644 --- a/BizHawk.Client.EmuHawk/tools/Debugger/AddBreakpointDialog.cs +++ b/BizHawk.Client.EmuHawk/tools/Debugger/AddBreakpointDialog.cs @@ -46,11 +46,11 @@ namespace BizHawk.Client.EmuHawk get { return (uint)AddressBox.ToRawInt().Value; } } - public int MaxAddressSize + public long MaxAddressSize { get { - return AddressBox.MaxLength; + return AddressBox.MaxLength; // int to long TODO: I think this logic was wrong (even before the int to long refactor) } set diff --git a/BizHawk.Client.EmuHawk/tools/Debugger/GenericDebugger.Disassembler.cs b/BizHawk.Client.EmuHawk/tools/Debugger/GenericDebugger.Disassembler.cs index bbd725b946..b18a754aa2 100644 --- a/BizHawk.Client.EmuHawk/tools/Debugger/GenericDebugger.Disassembler.cs +++ b/BizHawk.Client.EmuHawk/tools/Debugger/GenericDebugger.Disassembler.cs @@ -25,7 +25,7 @@ namespace BizHawk.Client.EmuHawk public string Mnemonic { get; private set; } } - private int BusMaxValue + private long BusMaxValue { get { diff --git a/BizHawk.Client.EmuHawk/tools/HexEditor/HexEditor.cs b/BizHawk.Client.EmuHawk/tools/HexEditor/HexEditor.cs index 0d2a1b4e74..ed577b1996 100644 --- a/BizHawk.Client.EmuHawk/tools/HexEditor/HexEditor.cs +++ b/BizHawk.Client.EmuHawk/tools/HexEditor/HexEditor.cs @@ -49,7 +49,7 @@ namespace BizHawk.Client.EmuHawk private long _domainSize; private MemoryDomain _domain = new MemoryDomain( - "NULL", 1024, MemoryDomain.Endian.Little, addr => 0, delegate(int a, byte v) { v = 0; }); + "NULL", 1024, MemoryDomain.Endian.Little, addr => 0, delegate(long a, byte v) { v = 0; }); private int _row; private int _addr; diff --git a/BizHawk.Common/Extensions/NumberExtensions.cs b/BizHawk.Common/Extensions/NumberExtensions.cs index f0d8092a6f..496e34c3e5 100644 --- a/BizHawk.Common/Extensions/NumberExtensions.cs +++ b/BizHawk.Common/Extensions/NumberExtensions.cs @@ -63,7 +63,7 @@ namespace BizHawk.Common.NumberExtensions /// Receives a number and returns the number of hexadecimal digits it is /// Note: currently only returns 2, 4, 6, or 8 /// - public static int NumHexDigits(this int i) + public static int NumHexDigits(this long i) { //now this is a bit of a trick. if it was less than 0, it mustve been >= 0x80000000 and so takes all 8 digits if (i < 0) @@ -86,7 +86,12 @@ namespace BizHawk.Common.NumberExtensions return 6; } - return 8; + if (i < 0x100000000) + { + return 8; + } + + return 16; } } } diff --git a/BizHawk.Emulation.Common/Base Implementations/MemoryDomain.cs b/BizHawk.Emulation.Common/Base Implementations/MemoryDomain.cs index a197217609..8cb6a4a4cb 100644 --- a/BizHawk.Emulation.Common/Base Implementations/MemoryDomain.cs +++ b/BizHawk.Emulation.Common/Base Implementations/MemoryDomain.cs @@ -9,7 +9,7 @@ namespace BizHawk.Emulation.Common { public enum Endian { Big, Little, Unknown } - public MemoryDomain(string name, int size, Endian endian, Func peekByte, Action pokeByte) + public MemoryDomain(string name, long size, Endian endian, Func peekByte, Action pokeByte) { Name = name; Size = size; @@ -24,13 +24,13 @@ namespace BizHawk.Emulation.Common /// Special note: if this is 0, the memorydomain is 0x100000000 (full 32bits) in size. /// This was judged to be less of a mess than using a bunch of longs everywhere. /// - public int Size { get; private set; } + public long Size { get; private set; } public Endian EndianType { get; private set; } - public Func PeekByte { get; private set; } + public Func PeekByte { get; private set; } - public Action PokeByte { get; private set; } + public Action PokeByte { get; private set; } /// /// create a memorydomain that references an unmanaged memory block @@ -50,13 +50,13 @@ namespace BizHawk.Emulation.Common name, size, endian, - delegate(int addr) + delegate(long addr) { if ((uint)addr >= size) throw new ArgumentOutOfRangeException(); return p[addr]; }, - delegate(int addr, byte val) + delegate(long addr, byte val) { if (writable) { @@ -86,13 +86,13 @@ namespace BizHawk.Emulation.Common name, size, endian, - delegate(int addr) + delegate(long addr) { if (addr < 0 || addr >= size) throw new ArgumentOutOfRangeException(); return p[addr ^ 1]; }, - delegate(int addr, byte val) + delegate(long addr, byte val) { if (writable) { @@ -109,7 +109,7 @@ namespace BizHawk.Emulation.Common return Name; } - public ushort PeekWord(int addr, bool bigEndian) + public ushort PeekWord(long addr, bool bigEndian) { Endian endian = bigEndian ? Endian.Big : Endian.Little; switch (endian) @@ -122,7 +122,7 @@ namespace BizHawk.Emulation.Common } } - public uint PeekDWord(int addr, bool bigEndian) + public uint PeekDWord(long addr, bool bigEndian) { Endian endian = bigEndian ? Endian.Big : Endian.Little; switch (endian) @@ -141,7 +141,7 @@ namespace BizHawk.Emulation.Common } } - public void PokeWord(int addr, ushort val, bool bigEndian) + public void PokeWord(long addr, ushort val, bool bigEndian) { Endian endian = bigEndian ? Endian.Big : Endian.Little; switch (endian) @@ -158,7 +158,7 @@ namespace BizHawk.Emulation.Common } } - public void PokeDWord(int addr, uint val, bool bigEndian) + public void PokeDWord(long addr, uint val, bool bigEndian) { Endian endian = bigEndian ? Endian.Big : Endian.Little; switch (endian) diff --git a/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/Chip4864.cs b/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/Chip4864.cs index 4cf6478ae7..55fbd0d865 100644 --- a/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/Chip4864.cs +++ b/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/Chip4864.cs @@ -30,6 +30,16 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64.MOS ram[i] = ((i & 0x40) != 0) ? (byte)0xFF : (byte)0x00; } + public byte Peek(long addr) + { + return ram[addr]; + } + + public void Poke(long addr, byte val) + { + ram[addr] = val; + } + public byte Peek(int addr) { return ram[addr]; diff --git a/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/MOS6510.cs b/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/MOS6510.cs index deb3706d6f..557312b0a9 100644 --- a/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/MOS6510.cs +++ b/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/MOS6510.cs @@ -146,24 +146,24 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64.MOS public bool FlagN { get { return cpu.FlagN; } } public bool FlagT { get { return cpu.FlagT; } } - public byte Peek(int addr) + public byte Peek(long addr) { if (addr == 0x0000) return port.Direction; else if (addr == 0x0001) return PortData; else - return PeekMemory(addr); + return PeekMemory((int)addr); } - public void Poke(int addr, byte val) + public void Poke(long addr, byte val) { if (addr == 0x0000) port.Direction = val; else if (addr == 0x0001) port.Latch = val; else - PokeMemory(addr, val); + PokeMemory((int)addr, val); } public byte PortData diff --git a/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/MOS6526.cs b/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/MOS6526.cs index 5e0adb52c2..97a8ab2185 100644 --- a/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/MOS6526.cs +++ b/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/MOS6526.cs @@ -372,14 +372,24 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64.MOS // ------------------------------------ + public byte Peek(long addr) + { + return ReadRegister((int)addr & 0xF); + } + + public void Poke(long addr, byte val) + { + WriteRegister((int)(addr & 0xF), val); + } + public byte Peek(int addr) { - return ReadRegister(addr & 0xF); + return ReadRegister((int)addr & 0xF); } public void Poke(int addr, byte val) { - WriteRegister((addr & 0xF), val); + WriteRegister((int)(addr & 0xF), val); } public byte Read(int addr) diff --git a/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/Sid.Registers.cs b/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/Sid.Registers.cs index 26e2f8b75d..f6ebe11cfb 100644 --- a/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/Sid.Registers.cs +++ b/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/Sid.Registers.cs @@ -7,14 +7,24 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64.MOS { sealed public partial class Sid { + public byte Peek(long addr) + { + return ReadRegister((int)(addr & 0x1F)); + } + + public void Poke(long addr, byte val) + { + WriteRegister((int)(addr & 0x1F), val); + } + public byte Peek(int addr) { - return ReadRegister((addr & 0x1F)); + return ReadRegister((int)(addr & 0x1F)); } public void Poke(int addr, byte val) { - WriteRegister((addr & 0x1F), val); + WriteRegister((int)(addr & 0x1F), val); } public byte Read(int addr) diff --git a/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/Vic.Registers.cs b/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/Vic.Registers.cs index 3c51a8c843..ad7a9740de 100644 --- a/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/Vic.Registers.cs +++ b/BizHawk.Emulation.Cores/Computers/Commodore64/MOS/Vic.Registers.cs @@ -7,14 +7,24 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64.MOS { sealed public partial class Vic { + public byte Peek(long addr) + { + return ReadRegister((int)(addr & 0x3F)); + } + + public void Poke(long addr, byte val) + { + WriteRegister((int)(addr & 0x3F), val); + } + public byte Peek(int addr) { - return ReadRegister((addr & 0x3F)); + return ReadRegister((int)(addr & 0x3F)); } public void Poke(int addr, byte val) { - WriteRegister((addr & 0x3F), val); + WriteRegister((int)(addr & 0x3F), val); } public byte Read(int addr) diff --git a/BizHawk.Emulation.Cores/Consoles/Atari/2600/Atari2600.IMemoryDomains.cs b/BizHawk.Emulation.Cores/Consoles/Atari/2600/Atari2600.IMemoryDomains.cs index 18f7b2e1ba..a52456f8f7 100644 --- a/BizHawk.Emulation.Cores/Consoles/Atari/2600/Atari2600.IMemoryDomains.cs +++ b/BizHawk.Emulation.Cores/Consoles/Atari/2600/Atari2600.IMemoryDomains.cs @@ -53,8 +53,8 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600 "Cart Ram", _mapper.CartRam.Len, MemoryDomain.Endian.Little, - addr => _mapper.CartRam[addr], - (addr, value) => _mapper.CartRam[addr] = value)); + addr => _mapper.CartRam[(int)addr], + (addr, value) => _mapper.CartRam[(int)addr] = value)); } MemoryDomains = new MemoryDomainList(domains); diff --git a/BizHawk.Emulation.Cores/Consoles/Atari/7800/Atari7800.IMemoryDomains.cs b/BizHawk.Emulation.Cores/Consoles/Atari/7800/Atari7800.IMemoryDomains.cs index 0b3bae3fd3..cb06fc0ef1 100644 --- a/BizHawk.Emulation.Cores/Consoles/Atari/7800/Atari7800.IMemoryDomains.cs +++ b/BizHawk.Emulation.Cores/Consoles/Atari/7800/Atari7800.IMemoryDomains.cs @@ -22,13 +22,13 @@ namespace BizHawk.Emulation.Cores.Atari.Atari7800 { _MemoryDomains.Add(new MemoryDomain( "RAM1", 0x800, MemoryDomain.Endian.Unknown, - delegate(int addr) + delegate(long addr) { if (addr < 0 || addr >= 0x800) throw new ArgumentOutOfRangeException(); return ((Machine7800)theMachine).RAM1[(ushort)addr]; }, - delegate(int addr, byte val) + delegate(long addr, byte val) { if (addr < 0 || addr >= 0x800) throw new ArgumentOutOfRangeException(); @@ -36,13 +36,13 @@ namespace BizHawk.Emulation.Cores.Atari.Atari7800 })); _MemoryDomains.Add(new MemoryDomain( "RAM2", 0x800, MemoryDomain.Endian.Unknown, - delegate(int addr) + delegate(long addr) { if (addr < 0 || addr >= 0x800) throw new ArgumentOutOfRangeException(); return ((Machine7800)theMachine).RAM2[(ushort)addr]; }, - delegate(int addr, byte val) + delegate(long addr, byte val) { if (addr < 0 || addr >= 0x800) throw new ArgumentOutOfRangeException(); @@ -50,44 +50,44 @@ namespace BizHawk.Emulation.Cores.Atari.Atari7800 })); _MemoryDomains.Add(new MemoryDomain( "BIOS ROM", bios.Length, MemoryDomain.Endian.Unknown, - delegate(int addr) + delegate(long addr) { return bios[addr]; }, - delegate(int addr, byte val) + delegate(long addr, byte val) { })); if (hsc7800 != null) { _MemoryDomains.Add(new MemoryDomain( "HSC ROM", hsbios.Length, MemoryDomain.Endian.Unknown, - delegate(int addr) + delegate(long addr) { return hsbios[addr]; }, - delegate(int addr, byte val) + delegate(long addr, byte val) { })); _MemoryDomains.Add(new MemoryDomain( "HSC RAM", hsram.Length, MemoryDomain.Endian.Unknown, - delegate(int addr) + delegate(long addr) { return hsram[addr]; }, - delegate(int addr, byte val) + delegate(long addr, byte val) { hsram[addr] = val; })); } _MemoryDomains.Add(new MemoryDomain( "System Bus", 65536, MemoryDomain.Endian.Unknown, - delegate(int addr) + delegate(long addr) { if (addr < 0 || addr >= 0x10000) throw new ArgumentOutOfRangeException(); return theMachine.Mem[(ushort)addr]; }, - delegate(int addr, byte val) + delegate(long addr, byte val) { if (addr < 0 || addr >= 0x10000) throw new ArgumentOutOfRangeException(); diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBA/Meteor.IMemoryDomains.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBA/Meteor.IMemoryDomains.cs index aa76a6e90a..593b44d9a0 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBA/Meteor.IMemoryDomains.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBA/Meteor.IMemoryDomains.cs @@ -37,13 +37,13 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBA // special domain for system bus { MemoryDomain sb = new MemoryDomain("System Bus", 1 << 28, MemoryDomain.Endian.Little, - delegate(int addr) + delegate(long addr) { if (addr < 0 || addr >= 0x10000000) throw new IndexOutOfRangeException(); return LibMeteor.libmeteor_peekbus((uint)addr); }, - delegate(int addr, byte val) + delegate(long addr, byte val) { if (addr < 0 || addr >= 0x10000000) throw new IndexOutOfRangeException(); @@ -56,7 +56,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBA var ew = _domainList[1]; var iw = _domainList[0]; MemoryDomain cr = new MemoryDomain("Combined WRAM", (256 + 32) * 1024, MemoryDomain.Endian.Little, - delegate(int addr) + delegate(long addr) { if (addr < 0 || addr >= (256 + 32) * 1024) throw new IndexOutOfRangeException(); @@ -65,7 +65,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBA else return ew.PeekByte(addr); }, - delegate(int addr, byte val) + delegate(long addr, byte val) { if (addr < 0 || addr >= (256 + 32) * 1024) throw new IndexOutOfRangeException(); diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBA/VBANext.IMemoryDomains.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBA/VBANext.IMemoryDomains.cs index 256836352f..e3d47bd543 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBA/VBANext.IMemoryDomains.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBA/VBANext.IMemoryDomains.cs @@ -25,24 +25,24 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBA mm.Add(MemoryDomain.FromIntPtr("ROM", 32 * 1024 * 1024, l, s.rom)); mm.Add(new MemoryDomain("System Bus", 0x10000000, l, - delegate(int addr) + delegate(long addr) { if (addr < 0 || addr >= 0x10000000) throw new ArgumentOutOfRangeException(); - return LibVBANext.SystemBusRead(Core, addr); + return LibVBANext.SystemBusRead(Core, (int)addr); }, - delegate(int addr, byte val) + delegate(long addr, byte val) { if (addr < 0 || addr >= 0x10000000) throw new ArgumentOutOfRangeException(); - LibVBANext.SystemBusWrite(Core, addr, val); + LibVBANext.SystemBusWrite(Core, (int)addr, val); })); // special combined ram memory domain { var ew = mm[1]; var iw = mm[0]; MemoryDomain cr = new MemoryDomain("Combined WRAM", (256 + 32) * 1024, MemoryDomain.Endian.Little, - delegate(int addr) + delegate(long addr) { if (addr < 0 || addr >= (256 + 32) * 1024) throw new IndexOutOfRangeException(); @@ -51,7 +51,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBA else return ew.PeekByte(addr); }, - delegate(int addr, byte val) + delegate(long addr, byte val) { if (addr < 0 || addr >= (256 + 32) * 1024) throw new IndexOutOfRangeException(); diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/Gambatte.IMemoryDomains.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/Gambatte.IMemoryDomains.cs index bfa0464e12..e5e7e9b95a 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/Gambatte.IMemoryDomains.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/Gambatte.IMemoryDomains.cs @@ -36,13 +36,13 @@ namespace BizHawk.Emulation.Cores.Nintendo.Gameboy // also add a special memory domain for the system bus, where calls get sent directly to the core each time _memoryDomains.Add(new MemoryDomain("System Bus", 65536, MemoryDomain.Endian.Little, - delegate(int addr) + delegate(long addr) { if (addr < 0 || addr >= 65536) throw new ArgumentOutOfRangeException(); return LibGambatte.gambatte_cpuread(GambatteState, (ushort)addr); }, - delegate(int addr, byte val) + delegate(long addr, byte val) { if (addr < 0 || addr >= 65536) throw new ArgumentOutOfRangeException(); diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/N64/N64.IMemoryDomains.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/N64/N64.IMemoryDomains.cs index 6f0416df72..0e4e7e96a8 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/N64/N64.IMemoryDomains.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/N64/N64.IMemoryDomains.cs @@ -25,49 +25,49 @@ namespace BizHawk.Emulation.Cores.Nintendo.N64 IntPtr memPtr = api.get_memory_ptr(id); - Func peekByte; - Action pokeByte; + Func peekByte; + Action pokeByte; if (swizzled) { - peekByte = delegate(int addr) + peekByte = delegate(long addr) { if (addr < 0 || addr >= size) { throw new ArgumentOutOfRangeException(); } - return Marshal.ReadByte(memPtr, (addr ^ 3)); + return Marshal.ReadByte(memPtr, (int)(addr ^ 3)); }; - pokeByte = delegate(int addr, byte val) + pokeByte = delegate(long addr, byte val) { if (addr < 0 || addr >= size) { throw new ArgumentOutOfRangeException(); } - Marshal.WriteByte(memPtr, (addr ^ 3), val); + Marshal.WriteByte(memPtr, (int)(addr ^ 3), val); }; } else { - peekByte = delegate(int addr) + peekByte = delegate(long addr) { if (addr < 0 || addr >= size) { throw new ArgumentOutOfRangeException(); } - return Marshal.ReadByte(memPtr, (addr)); + return Marshal.ReadByte(memPtr, (int)(addr)); }; - pokeByte = delegate(int addr, byte val) + pokeByte = delegate(long addr, byte val) { if (addr < 0 || addr >= size) { throw new ArgumentOutOfRangeException(); } - Marshal.WriteByte(memPtr, (addr), val); + Marshal.WriteByte(memPtr, (int)(addr), val); }; } @@ -116,15 +116,15 @@ namespace BizHawk.Emulation.Cores.Nintendo.N64 } - Func peekByte; - Action pokeByte; + Func peekByte; + Action pokeByte; - peekByte = delegate(int addr) + peekByte = delegate(long addr) { return api.m64p_read_memory_8((uint)addr); }; - pokeByte = delegate(int addr, byte val) + pokeByte = delegate(long addr, byte val) { api.m64p_write_memory_8((uint)addr, val); }; @@ -132,7 +132,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.N64 _memoryDomains.Add(new MemoryDomain ( name: "System Bus", - size: 0, // special case for full 32bit memorydomain + size: 0, // special case for full 32bit memorydomain // int to long TODO: remove this special case! endian: MemoryDomain.Endian.Big, peekByte: peekByte, pokeByte: pokeByte diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/FDS/FDS.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/FDS/FDS.cs index 8fea83ef46..090c5736f0 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/FDS/FDS.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/FDS/FDS.cs @@ -228,7 +228,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES public MemoryDomain GetDiskPeeker() { - return new MemoryDomain("FDS SIDE", diskdrive.NumBytes, MemoryDomain.Endian.Little, diskdrive.PeekData, null); + return new MemoryDomain("FDS SIDE", diskdrive.NumBytes, MemoryDomain.Endian.Little, diskdrive.PeekData, null); // silent poke fail TODO: don't pass null! Throw a not implemented exception, handle this exception in ram tools } void SetIRQ() diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/FDS/RamAdapter.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/FDS/RamAdapter.cs index 488b88db8d..16a5fcd66c 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/FDS/RamAdapter.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/FDS/RamAdapter.cs @@ -290,7 +290,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES /// /// /// - public byte PeekData(int addr) + public byte PeekData(long addr) { if (disk != null && disk.Length > addr) return disk[addr]; diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/NES.IMemoryDomains.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/NES.IMemoryDomains.cs index 95fa877e9c..af9bb6759f 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/NES.IMemoryDomains.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/NES.IMemoryDomains.cs @@ -16,9 +16,9 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES var RAM = new MemoryDomain("RAM", 0x800, MemoryDomain.Endian.Little, addr => ram[addr], (addr, value) => ram[addr] = value); var SystemBus = new MemoryDomain("System Bus", 0x10000, MemoryDomain.Endian.Little, - addr => PeekMemory((ushort)addr), (addr, value) => ApplySystemBusPoke(addr, value)); + addr => PeekMemory((ushort)addr), (addr, value) => ApplySystemBusPoke((int)addr, value)); var PPUBus = new MemoryDomain("PPU Bus", 0x4000, MemoryDomain.Endian.Little, - addr => ppu.ppubus_peek(addr), (addr, value) => ppu.ppubus_write(addr, value)); + addr => ppu.ppubus_peek((int)addr), (addr, value) => ppu.ppubus_write((int)addr, value)); var CIRAMdomain = new MemoryDomain("CIRAM (nametables)", 0x800, MemoryDomain.Endian.Little, addr => CIRAM[addr], (addr, value) => CIRAM[addr] = value); var OAMdoman = new MemoryDomain("OAM", 64 * 4, MemoryDomain.Endian.Unknown, diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/QuickNES/QuickNES.IMemoryDomains.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/QuickNES/QuickNES.IMemoryDomains.cs index b56a11e446..27a61eb3a4 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/QuickNES/QuickNES.IMemoryDomains.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/QuickNES/QuickNES.IMemoryDomains.cs @@ -32,23 +32,23 @@ namespace BizHawk.Emulation.Cores.Consoles.Nintendo.QuickNES "System Bus", 0x10000, MemoryDomain.Endian.Unknown, - delegate(int addr) + delegate(long addr) { if (addr < 0 || addr >= 0x10000) { throw new ArgumentOutOfRangeException(); } - return LibQuickNES.qn_peek_prgbus(Context, addr); + return LibQuickNES.qn_peek_prgbus(Context, (int)addr); }, - delegate(int addr, byte val) + delegate(long addr, byte val) { if (addr < 0 || addr >= 0x10000) { throw new ArgumentOutOfRangeException(); } - LibQuickNES.qn_poke_prgbus(Context, addr, val); + LibQuickNES.qn_poke_prgbus(Context, (int)addr, val); } )); diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/SNES/LibsnesCore.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/SNES/LibsnesCore.cs index c3e3ba9f18..cb28490a1c 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/SNES/LibsnesCore.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/SNES/LibsnesCore.cs @@ -1026,7 +1026,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES var md = new MemoryDomain("System Bus", 0x1000000, MemoryDomain.Endian.Little, (addr) => { - var a = FakeBusMap(addr); + var a = FakeBusMap((int)addr); if (a.HasValue) return blockptr[a.Value]; else @@ -1034,7 +1034,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES }, (addr, val) => { - var a = FakeBusMap(addr); + var a = FakeBusMap((int)addr); if (a.HasValue) blockptr[a.Value] = val; }); diff --git a/BizHawk.Emulation.Cores/Consoles/PC Engine/PCEngine.cs b/BizHawk.Emulation.Cores/Consoles/PC Engine/PCEngine.cs index b109f78bb9..534ffa70a5 100644 --- a/BizHawk.Emulation.Cores/Consoles/PC Engine/PCEngine.cs +++ b/BizHawk.Emulation.Cores/Consoles/PC Engine/PCEngine.cs @@ -479,13 +479,13 @@ namespace BizHawk.Emulation.Cores.PCEngine { if (addr < 0 || addr >= 0x200000) throw new ArgumentOutOfRangeException(); - return Cpu.ReadMemory21(addr); + return Cpu.ReadMemory21((int)addr); }, (addr, value) => { if (addr < 0 || addr >= 0x200000) throw new ArgumentOutOfRangeException(); - Cpu.WriteMemory21(addr, value); + Cpu.WriteMemory21((int)addr, value); }); domains.Add(SystemBusDomain); diff --git a/BizHawk.Emulation.Cores/Consoles/Sega/Genesis/Genesis.cs b/BizHawk.Emulation.Cores/Consoles/Sega/Genesis/Genesis.cs index 02215810ca..ef74d601bf 100644 --- a/BizHawk.Emulation.Cores/Consoles/Sega/Genesis/Genesis.cs +++ b/BizHawk.Emulation.Cores/Consoles/Sega/Genesis/Genesis.cs @@ -474,7 +474,7 @@ namespace BizHawk.Emulation.Cores.Sega.Genesis (addr, value) => RomData[addr & (RomData.Length - 1)] = value); var SystemBusDomain = new MemoryDomain("System Bus", 0x1000000, MemoryDomain.Endian.Big, - addr => (byte)ReadByte(addr), + addr => (byte)ReadByte((int)addr), (addr, value) => Write8((uint)addr, (uint)value)); domains.Add(MainMemoryDomain); diff --git a/BizHawk.Emulation.Cores/Consoles/Sega/gpgx/GPGX.cs b/BizHawk.Emulation.Cores/Consoles/Sega/gpgx/GPGX.cs index 1d29e016b0..555e82adb8 100644 --- a/BizHawk.Emulation.Cores/Consoles/Sega/gpgx/GPGX.cs +++ b/BizHawk.Emulation.Cores/Consoles/Sega/gpgx/GPGX.cs @@ -600,17 +600,17 @@ namespace BizHawk.Emulation.Cores.Consoles.Sega.gpgx { byte* p = (byte*)area; mm.Add(new MemoryDomain(name, size, MemoryDomain.Endian.Unknown, - delegate(int addr) + delegate(long addr) { if (addr < 0 || addr >= 65536) throw new ArgumentOutOfRangeException(); return p[addr ^ 1]; }, - delegate(int addr, byte val) + delegate(long addr, byte val) { if (addr < 0 || addr >= 65536) throw new ArgumentOutOfRangeException(); - LibGPGX.gpgx_poke_vram(addr ^ 1, val); + LibGPGX.gpgx_poke_vram(((int)addr) ^ 1, val); })); } else