From 0545cb64fa969f1b905ee58b532092c065c6629b Mon Sep 17 00:00:00 2001 From: zeromus Date: Wed, 26 Dec 2012 18:25:45 +0000 Subject: [PATCH] snes-make hex editor faster --- .../Consoles/Nintendo/SNES/LibsnesCore.cs | 42 ++++++------------- BizHawk.Emulation/DiscSystem/CCD_format.cs | 2 + 2 files changed, 15 insertions(+), 29 deletions(-) diff --git a/BizHawk.Emulation/Consoles/Nintendo/SNES/LibsnesCore.cs b/BizHawk.Emulation/Consoles/Nintendo/SNES/LibsnesCore.cs index 8c03de805a..0436f3d470 100644 --- a/BizHawk.Emulation/Consoles/Nintendo/SNES/LibsnesCore.cs +++ b/BizHawk.Emulation/Consoles/Nintendo/SNES/LibsnesCore.cs @@ -728,42 +728,26 @@ namespace BizHawk.Emulation.Consoles.Nintendo.SNES { int size = api.snes_get_memory_size(id); int mask = size - 1; + + byte* blockptr = api.snes_get_memory_data(id); + MemoryDomain md; - ////have to bitmask these somehow because it's unmanaged memory and we would hate to clobber things or make them nondeterministic - //if (Util.IsPowerOfTwo(size)) - //{ - // //can &mask for speed - // md = new MemoryDomain(name, size, endian, - // (addr) => blockptr[addr & mask], - // (addr, value) => blockptr[addr & mask] = value); - //} - //else - //{ - // //have to use % (only OAM needs this, it seems) - // //(OAM is actually two differently sized banks of memory which arent truly considered adjacent. maybe a better way to visualize it would be with an empty bus and adjacent banks) - // md = new MemoryDomain(name, size, endian, - // (addr) => blockptr[addr % size], - // (addr, value) => blockptr[addr % size] = value); - //} - - //EXTERNAL PROCESS CONVERSION: MUST MAKE THIS SAFE - //speed it up later - if (Util.IsPowerOfTwo(size)) + if(id == LibsnesApi.SNES_MEMORY.OAM) { - //can &mask for speed + //OAM is actually two differently sized banks of memory which arent truly considered adjacent. + //maybe a better way to visualize it is with an empty bus and adjacent banks + //so, we just throw away everything above its size of 544 bytes + if (size != 544) throw new InvalidOperationException("oam size isnt 544 bytes.. wtf?"); md = new MemoryDomain(name, size, endian, - (addr) => api.peek(id, (uint)(addr & mask)), - (addr, value) => api.poke(id, (uint)(addr & mask), value)); + (addr) => (addr < 544) ? blockptr[addr] : (byte)0x00, + (addr, value) => { if (addr < 544) blockptr[addr] = value; } + ); } else - { - //have to use % (only OAM needs this, it seems) - //(OAM is actually two differently sized banks of memory which arent truly considered adjacent. maybe a better way to visualize it would be with an empty bus and adjacent banks) md = new MemoryDomain(name, size, endian, - (addr) => api.peek(id, (uint)(addr % size)), - (addr, value) => api.poke(id, (uint)(addr % size), value)); - } + (addr) => blockptr[addr & mask], + (addr, value) => blockptr[addr & mask] = value); MemoryDomains.Add(md); diff --git a/BizHawk.Emulation/DiscSystem/CCD_format.cs b/BizHawk.Emulation/DiscSystem/CCD_format.cs index 70ece3e948..7dfac1787f 100644 --- a/BizHawk.Emulation/DiscSystem/CCD_format.cs +++ b/BizHawk.Emulation/DiscSystem/CCD_format.cs @@ -4,6 +4,8 @@ using System.Collections.Generic; namespace BizHawk.DiscSystem { //TBD CCD format + //check out ccd2iso linux program? + //https://wiki.archlinux.org/index.php/CD_Burning#TOC.2FCUE.2FBIN_for_mixed-mode_disks advice here public class CCDFormat { }