Page 2 of 3

Re: Grumpy NES emulator

Posted: Sun Oct 24, 2021 12:31 pm
by pgimeno
I've had trouble too. Blockage works great, but it's kind of repetitive and not very demanding. Cowlitz Gamers 1st Adventure works, but it slows down at times; I guess that's expectable. The 2nd adventure doesn't work at all. The Legends of Owlia crashes upon entering the game, if not earlier, and often ends with this traceback:

Code: Select all

Error: gnes/PPU/init.lua:148: BUG: write to 42c6: no writer at 3
stack traceback:
	[string "boot.lua"]:777: in function <[string "boot.lua"]:773>
	[C]: in function 'write'
	gnes/PPU/init.lua:148: in function <gnes/PPU/init.lua:146>
	gnes/CPU/init.lua:160: in function '_step'
	gnes/CPU/init.lua:26: in function 'stepC'
	gnes/NES.lua:150: in function '_frameStep'
	gnes/NES.lua:81: in function 'tick'
	gnes/gnes.lua:121: in function 'draw'
	gnes/gnes.lua:145: in function <gnes/gnes.lua:133>
	[C]: in function 'xpcall'

Re: Grumpy NES emulator

Posted: Sun Oct 24, 2021 5:04 pm
by ReFreezed
grump wrote: Sun Oct 24, 2021 8:16 am Keyboard or gamepad?
Both. And I can add that the timing of the releases range from usually near-instant to rarely maybe a second, so very random.

Actually, I just tried Contra again today, and it seems to work most of the time now. Weird indeed. Maybe it's also a hardware timing related thing.

Re: Grumpy NES emulator

Posted: Mon Oct 25, 2021 3:58 pm
by grump
pgimeno wrote: Sun Oct 24, 2021 12:31 pm Cowlitz Gamers 1st Adventure works, but it slows down at times;
I forgot about the F10 key. Start the ROM and watch the MEM value. If it goes straight up above 4 MB or so and doesn't stop, press F10 (super-hard reset, JIT flushes). Repeat until it remains stationary below 4 MB. Now all the LuaJIT dice were adequately rolled and you should be able to enjoy your game at best performance. It's ridiculous, lol
pgimeno wrote: Sun Oct 24, 2021 12:31 pm The Legends of Owlia crashes upon entering the game, if not earlier, and often ends with this traceback:
I would like to try this because that stack trace is crazy and makes no sense, but the ROM is not available for download anymore. There's a demo ROM but it doesn't crash on me.

Re: Grumpy NES emulator

Posted: Wed Oct 27, 2021 1:03 pm
by pgimeno
I've found a copy of The Legend of Owlia here, together with many other homebrew games for several platforms (including the other ones I tested with Grumpy NES):

https://github.com/FunKey-Project/FunKe ... _files.zip

Re: Grumpy NES emulator

Posted: Thu Oct 28, 2021 5:54 pm
by grump
Thanks @pgimeno, I found the issue with Owlia. It wasn't as interesting as I first thought and only this and one other game are affected.

Re: Grumpy NES emulator

Posted: Sat Oct 30, 2021 11:48 pm
by Gunroar:Cannon()
grump wrote: Thu Oct 28, 2021 5:54 pm Thanks @pgimeno, I found the issue with Owlia. It wasn't as interesting as I first thought and only this and one other game are affected.
Can you spread insight on the issue, if you may?

Re: Grumpy NES emulator

Posted: Sun Oct 31, 2021 5:06 am
by grump
Gunroar:Cannon() wrote: Sat Oct 30, 2021 11:48 pm Can you spread insight on the issue, if you may?
Sure, why not. I'll happily bore anyone to death.

NES games are cartridges, and cartridge is hardware and must be emulated. Many different cartridge boards have been identified, documented and assigned so called mapper numbers. A game dump has a header that contains the mapper number.

The problematic game in this case works with mapper 2 hardware, which provides extra memory that can be bank-switched.

In my bank-switching code, I only used the lowest 4 bits of the bank number to select one of 16 memory banks (as suggested by the documentation). But this game here has 512 KiB of ROM (32 pages), requiring 5 address lines instead of just 4 to select a bank.

The bug was fixed by using all 8 bits of the bank number when switching banks. It's even right there in the article:
Emulator implementations of iNES mapper 2 treat this as a full 8-bit bank select register, without bus conflicts. This allows the mapper to be used for similar boards that are compatible.

Code: Select all

mapper.write = (addr, val) =>
	if addr >= 0x8000
		banks[0] = lshift(val, 14)
I could identify one other game that uses this mapper with 5+ address lines, so that makes this my first obscure game bug fixed after a user report ;)

Re: Grumpy NES emulator

Posted: Sun Oct 31, 2021 6:23 am
by Gunroar:Cannon()
Dang, you're a NES expert :shock:

Re: Grumpy NES emulator

Posted: Wed Nov 03, 2021 2:38 pm
by milon
Gunroar:Cannon() wrote: Sun Oct 31, 2021 6:23 am Dang, you're a NES expert :shock:
That's kind of a requirement for writing an emulator. ;)

Re: Grumpy NES emulator

Posted: Mon Dec 13, 2021 2:12 pm
by ivan
Wow, this is super impressive, Grump!
grump wrote: Wed Jun 02, 2021 4:14 pm Sometimes performance is superb, other times it slows down to a crawl. It accumulates more garbage per second than a neckbeard in his nest in a month, for reasons unknown.
Wish I could help with this issue, but I have no experience with MoonScript at all.
Looks great, anyways!