Earthworm Jim 2 [Solved]

Discuss emulation of the Nintendo Entertainment System and Famicom.

Moderator: Moderators

Post Reply
User avatar
zeroone
Posts: 939
Joined: Mon Dec 29, 2014 1:46 pm
Location: New York, NY
Contact:

Earthworm Jim 2 [Solved]

Post by zeroone »

As you can see in the image below, Earthworm Jim 2 loads and runs in my emulator, but the background tiles look messed up. The sprites, the music and sound effects, and the game play seem to be working aside from the scrambled background.

Image

Since there is no wiki page on mapper UNL-H2288, I have been relying on the source code of other emulators for details. Earthworm Jim 2 executes perfectly in Nintendulator and FCEUX. Their mapper implementations are almost identical. However, Nintendulator includes this extra bit, likely related to the copy protection mechanism:

Code: Select all

int	MAPINT	Read (int Bank, int Addr)
{
	if (Addr & 0x800)
		return (*EMU->OpenBus & 0xFE) | (((~Addr >> 8) | Addr) & 1);
	else	return -1;
}
Since FCEUX doesn't have the equivalent code, I assume it is not completely necessary.

Could the scrambled background tiles in my emulator be copy protection related? I followed the register remapping per the aforementioned sources; so, I am looking for other possibilities. I appreciate any input on this issue. Thanks.
Last edited by zeroone on Wed May 11, 2016 7:51 pm, edited 1 time in total.
Joe
Posts: 650
Joined: Mon Apr 01, 2013 11:17 pm

Re: Earthworm Jim 2

Post by Joe »

zeroone wrote:I followed the register remapping per the aforementioned sources; so, I am looking for other possibilities.
Are you sure the PRG mapping is working correctly? It looks like the game might be loading data from the wrong part of the ROM.
User avatar
Zepper
Formerly Fx3
Posts: 3262
Joined: Fri Nov 12, 2004 4:59 pm
Location: Brazil
Contact:

Re: Earthworm Jim 2

Post by Zepper »

If I have the correct one, it gives an error

Code: Select all

Filename....: Earth Worm Jim 2 (Unl) [p1][!].nes
Format......: NES
Mapper......: 004 - TxROM (MMC3) 
Data size...: 256K PRG ROM (16 x 16K banks)
             (PRG CRC $B9AA4EEB)
              256K CHR ROM (32 x 8K banks)

---------------------------
RockNES 5.21 32bit - May  9 2016, 23:15:18
---------------------------
ERROR:
unofficial opcode 02 trapped at PC 810B!
The emulator has stopped now.
---------------------------
OK   
---------------------------
User avatar
zeroone
Posts: 939
Joined: Mon Dec 29, 2014 1:46 pm
Location: New York, NY
Contact:

Re: Earthworm Jim 2

Post by zeroone »

Joe wrote:Are you sure the PRG mapping is working correctly? It looks like the game might be loading data from the wrong part of the ROM.
It's a bit difficult to believe that the game runs correctly except for the backgrounds if the PRG mapping were off. However, I agree that it appears that the wrong data is being transferred to the nametables. This either means that the source pointer to the data is wrong--possibly from bad bank mapping--or there is missing mapping required to write to the nametables. Unfortunately, there is nothing in the other emulator sources that suggest a missing component like that.

Does anyone have any logging comparison suggestions maybe?
User avatar
zeroone
Posts: 939
Joined: Mon Dec 29, 2014 1:46 pm
Location: New York, NY
Contact:

Re: Earthworm Jim 2

Post by zeroone »

I just came across this:

http://blog.kevtris.org/blogfiles/EWJ2PROT.TXT

I'll study it to see if it reveals something.

Edit: I also noticed that this mapper has some similarity to mapper 182 in regards to the registers mapping.

Edit 2: I did a comparison of the dynamically generated code at $0740--$07FF and my emulator matches FCEUX. If it is a copy protection related issue, I would expect it to just not run.
User avatar
zeroone
Posts: 939
Joined: Mon Dec 29, 2014 1:46 pm
Location: New York, NY
Contact:

Re: Earthworm Jim 2

Post by zeroone »

Problem solved!!!

It turns out that my mapper implementation is failing to set the nametable mirroring, a consequence of it being a UNIF mapper, a concept that I only recently introduced into my emulator.

On a side note, my emulator doesn't do anything special for open bus; it is mostly treated as 0 except in the case of the upper-bits of the controller values. Per the FCEUX code, it doesn't seem to play much of a roll here.
User avatar
zeroone
Posts: 939
Joined: Mon Dec 29, 2014 1:46 pm
Location: New York, NY
Contact:

Re: Earthworm Jim 2 [Solved]

Post by zeroone »

Zepper wrote:If I have the correct one, it gives an error

Code: Select all

Filename....: Earth Worm Jim 2 (Unl) [p1][!].nes
Format......: NES
Mapper......: 004 - TxROM (MMC3) 
Data size...: 256K PRG ROM (16 x 16K banks)
             (PRG CRC $B9AA4EEB)
              256K CHR ROM (32 x 8K banks)

---------------------------
RockNES 5.21 32bit - May  9 2016, 23:15:18
---------------------------
ERROR:
unofficial opcode 02 trapped at PC 810B!
The emulator has stopped now.
---------------------------
OK   
---------------------------
I located the iNES ROM with that CRC. It's a mislabeled Earthworm Jim 3, not Earthworm Jim 2. It is a mapper 4 ROM that should work in most emulators.
Post Reply