Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/lua/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何从Lua中的FCEUX获取PPU内存?_Lua_Emulation_Nintendo - Fatal编程技术网

如何从Lua中的FCEUX获取PPU内存?

如何从Lua中的FCEUX获取PPU内存?,lua,emulation,nintendo,Lua,Emulation,Nintendo,我不确定这是否是一个合适的社区,但我想我会尝试一下 是一个令人惊叹的NES模拟器,具有丰富的调试工具功能。它还为用户提供了运行Lua脚本的能力,这些脚本可以访问。然而,我似乎不知道如何访问网元的地址。它提供对和ROM数据的直接访问,但似乎无法直接访问PPU内存。由于NES使用,从理论上讲,从特殊的CPU内存地址获取数据是可能的,但这似乎很麻烦,而且可能会干扰仿真 有人知道通过FCEUX的LUAAPI以编程方式提取PPU内存的方法吗?如果没有,是否有人知道一个仿真器,它具有一个API以编程方式提取

我不确定这是否是一个合适的社区,但我想我会尝试一下

是一个令人惊叹的NES模拟器,具有丰富的调试工具功能。它还为用户提供了运行Lua脚本的能力,这些脚本可以访问。然而,我似乎不知道如何访问网元的地址。它提供对和ROM数据的直接访问,但似乎无法直接访问PPU内存。由于NES使用,从理论上讲,从特殊的CPU内存地址获取数据是可能的,但这似乎很麻烦,而且可能会干扰仿真


有人知道通过FCEUX的LUAAPI以编程方式提取PPU内存的方法吗?如果没有,是否有人知道一个仿真器,它具有一个API以编程方式提取PPU内存?

在意识到“哦,等等,我是一个程序员,FCEUX是开源的!所以也许我应该花时间看看他们的源代码/存储库,看看我是否可以自己回答这个问题!”,我找到了我想要的答案:

因此,在撰写本文时,在当前版本(2016年7月28日发布)中,似乎无法通过Lua访问PPU内存,但在未来版本中可能会提供

此外,在签出和(其他两个看起来最流行的NES仿真器)后,这些仿真器似乎不提供此类功能。至于是否有其他模拟器提供此功能仍然是一个悬而未决的问题,因为目前有许多其他模拟器需要检查。

以下是我使用的:

function memory.readbyteppu(a)
    memory.writebyte(0x2001,0x00) -- Turn off rendering
    memory.readbyte(0x2002) -- PPUSTATUS (reset address latch)
    memory.writebyte(0x2006,math.floor(a/0x100)) -- PPUADDR high byte
    memory.writebyte(0x2006,a % 0x100) -- PPUADDR low byte
    if a < 0x3f00 then 
        dummy=memory.readbyte(0x2007) -- PPUDATA (discard contents of internal buffer if not reading palette area)
    end
    ret=memory.readbyte(0x2007) -- PPUDATA
    memory.writebyte(0x2001,0x1e) -- Turn on rendering
    return ret
end

function memory.readbytesppu(a,l)
    memory.writebyte(0x2001,0x00) -- Turn off rendering
    local ret
    local i
    ret=""
    for i=0,l-1 do
        memory.readbyte(0x2002) -- PPUSTATUS (reset address latch)
        memory.writebyte(0x2006,math.floor((a+i)/0x100)) -- PPUADDR high byte
        memory.writebyte(0x2006,(a+i) % 0x100) -- PPUADDR low byte
        if (a+i) < 0x3f00 then 
            dummy=memory.readbyte(0x2007) -- PPUDATA (discard contents of internal buffer if not reading palette area)
        end
        ret=ret..string.char(memory.readbyte(0x2007)) -- PPUDATA
    end
    memory.writebyte(0x2001,0x1e) -- Turn on rendering
    return ret
end


function memory.writebyteppu(a,v)
    memory.writebyte(0x2001,0x00) -- Turn off rendering
    memory.readbyte(0x2002) -- PPUSTATUS (reset address latch)
    memory.writebyte(0x2006,math.floor(a/0x100)) -- PPUADDR high byte
    memory.writebyte(0x2006,a % 0x100) -- PPUADDR low byte
    memory.writebyte(0x2007,v) -- PPUDATA
    memory.writebyte(0x2001,0x1e) -- Turn on rendering
end

function memory.writebytesppu(a,str)
    memory.writebyte(0x2001,0x00) -- Turn off rendering

    local i
    for i = 0, #str-1 do
        memory.readbyte(0x2002) -- PPUSTATUS (reset address latch)
        memory.writebyte(0x2006,math.floor((a+i)/0x100)) -- PPUADDR high byte
        memory.writebyte(0x2006,(a+i) % 0x100) -- PPUADDR low byte
        memory.writebyte(0x2007,string.byte(str,i+1)) -- PPUDATA
    end

    memory.writebyte(0x2001,0x1e) -- Turn on rendering
end
function memory.readbyteppu(a)
memory.writebyte(0x2001,0x00)--关闭渲染
memory.readbyte(0x2002)--PPUSTATUS(重置地址锁存器)
memory.writebyte(0x2006,数学地板(a/0x100))--PPUADDR高字节
memory.writebyte(0x2006,a%0x100)--PPUADDR低字节
如果a<0x3f00,则
dummy=memory.readbyte(0x2007)——PPUDATA(如果不读取调色板区域,则丢弃内部缓冲区的内容)
终止
ret=memory.readbyte(0x2007)——PPUDATA
memory.writebyte(0x2001,0x1e)--打开呈现
回程网
终止
函数存储器。readbytesppu(a,l)
memory.writebyte(0x2001,0x00)--关闭渲染
本地网
本地i
ret=“”
对于i=0,l-1 do
memory.readbyte(0x2002)--PPUSTATUS(重置地址锁存器)
memory.writebyte(0x2006,数学地板((a+i)/0x100))--PPUADDR高字节
memory.writebyte(0x2006,(a+i)%0x100)——PPUADDR低字节
如果(a+i)<0x3f00,则
dummy=memory.readbyte(0x2007)——PPUDATA(如果不读取调色板区域,则丢弃内部缓冲区的内容)
终止
ret=ret..string.char(memory.readbyte(0x2007))--PPUDATA
终止
memory.writebyte(0x2001,0x1e)--打开呈现
回程网
终止
函数存储器。写字节数(a,v)
memory.writebyte(0x2001,0x00)--关闭渲染
memory.readbyte(0x2002)--PPUSTATUS(重置地址锁存器)
memory.writebyte(0x2006,数学地板(a/0x100))--PPUADDR高字节
memory.writebyte(0x2006,a%0x100)--PPUADDR低字节
memory.writebyte(0x2007,v)--PPUDATA
memory.writebyte(0x2001,0x1e)--打开呈现
终止
函数内存。writebytesppu(a,str)
memory.writebyte(0x2001,0x00)--关闭渲染
本地i
对于i=0,#str-1 do
memory.readbyte(0x2002)--PPUSTATUS(重置地址锁存器)
memory.writebyte(0x2006,数学地板((a+i)/0x100))--PPUADDR高字节
memory.writebyte(0x2006,(a+i)%0x100)——PPUADDR低字节
memory.writebyte(0x2007,string.byte(str,i+1))--PPUDATA
终止
memory.writebyte(0x2001,0x1e)--打开呈现
终止
在2.2.3中,它在旧PPU内核上似乎不起作用,但在2.2.2中起作用。可在两个版本上与新ppu core配合使用