Post subject: Lua memory.register disaster
Banned User
Joined: 12/23/2004
Posts: 1850
Setting memory.register on some values will cause extreme problems. This one is 0x2007 (though most of the PPU ones will probably do it.) A sample script that does this is http://xkeeper.shacknet.nu:5/emu/nes/lua/kaboom.lua. Don't use this if you have a risk of seizures, because, well.
Perma-banned
Player (121)
Joined: 2/11/2007
Posts: 1522
Sorry to hijack and ask a stupid question but: you can read/write the ppu? Are they a set range?
I make a comic with no image files and you should read it. While there is a lower class, I am in it, and while there is a criminal element I am of it, and while there is a soul in prison, I am not free. -Eugene Debs
Banned User
Joined: 12/23/2004
Posts: 1850
;NES specific hardware defines

PPU_CTRL_REG1         = $2000
PPU_CTRL_REG2         = $2001
PPU_STATUS            = $2002
PPU_SPR_ADDR          = $2003
PPU_SPR_DATA          = $2004
PPU_SCROLL_REG        = $2005
PPU_ADDRESS           = $2006
PPU_DATA              = $2007

SND_REGISTER          = $4000
SND_SQUARE1_REG       = $4000
SND_SQUARE2_REG       = $4004
SND_TRIANGLE_REG      = $4008
SND_NOISE_REG         = $400c
SND_DELTA_REG         = $4010
SND_MASTERCTRL_REG    = $4015

SPR_DMA               = $4014
JOYPAD_PORT           = $4016
JOYPAD_PORT1          = $4016
JOYPAD_PORT2          = $4017
I'm not reading/writing from the PPU or anywhere else, just setting a sort of breakpoint to count how many times it is done, as memory.register is relatively useless (now if it was called iwth the old/new value, then...) For real fun, try memory.register(0x4000). It calls your function with every single memory write :D
Perma-banned
Banned User
Joined: 12/23/2004
Posts: 1850
Also, holy balls. Could we get something like this? That would be so incredibly useful it isn't funny :(
Perma-banned
Joined: 4/25/2004
Posts: 615
Location: The Netherlands
Yeah that would be cool. I've already posted a todo about that. I'd be happy with just the mouse.
qfox.nl
Banned User
Joined: 12/23/2004
Posts: 1850
Wow, aparrently setting memory.register completely breaks the emulation even though the Hex Editor already has that functionality outside of Lua via "write breakpoint". And somehow, memory.register aparrently manages to fuck up everything related to registers or some garbage. Better hope you don't accidentally and unknowlingly change some somewhere! Nevermind the fact this has been a part of FCEU XD since 2005: But nope, let's create our own breakpoint function that completely fucks over the emulation if you happen to watch specific bytes, even when the original (still included!) debugger works fine. Jesus christ. I simply propose that memory.register works like this:
function somefunction(address, newvalue) 
	gui.text(1, 1, address .. " was changed to ".. newvalue);
end;

memory.register(0x2007, somefunction);
Which can actually provide new uses for things! These would include - Being able to use the same function for multiple addresses - Being able to read values written to registers that are otherwise only readable with the debugger - And more! Instead of the current method, which as demonstrates has the amazing ability to completely blow up the emulation if you dare read something unexpected! GASP
Perma-banned