nesdev.com
http://forums.nesdev.com/

Broken FDS emulation: Kiki Kaikai - Dotou Hen
http://forums.nesdev.com/viewtopic.php?f=3&t=6504
Page 1 of 5

Author:  procyon [ Thu Jun 17, 2010 1:15 pm ]
Post subject:  Broken FDS emulation: Kiki Kaikai - Dotou Hen

Hi everyone. I began to write a guide on how to play this FDS port of the Taito arcade game Kiki Kaikai (the series that came to be known as Pocky & Rocky on the SNES), but I have come across a strange problem. There are two boss fights that crash just about every modern NES emulator that I have tried, including FCEUX, Nestopia, Nintendulator, Mednafen, and VirtuaNES. The _only_ emulator that the game works properly on is the "old" emulator NNNesterJ. It's very strange, where those five other emulators hang, NNNesterJ goes swimmingly right along. (Interesting to note, for those of you who can read Japanese, a warning to this effect is present on this page: http://www25.atwiki.jp/famicomall/pages/244.html which you can run through Google Translator if need be.)

It's not too hard to get to the crash point, although it takes a few minutes of walking (if you avoid all of the enemies.) The ROM that I'm using (and the only one that seems to be available) is from the TOSEC set with a CRC of 4C791779. From the start point, walk straight up. Keep following the path north until you get the first chance to travel east (you'll cross a few bridges just before that point.) Head east as soon as you are able, and then take the very next path south. This will lead you down and around to the entrance of a cave. You need 50 Ofuda cards to enter the cave, which is what you start with (you earn Ofuda cards by defeating enemies with your wand). Once inside, the path to the boss never branches. You travel north, then east, and the north. At the top of the second north path is the boss room. The expected result (and the one which NNNesterJ produces) is that the room scrolls into view, turns blue, and a large boss starts to attack you. The actual result in the rest of the emulators I've tried is that they hang before the room turns blue, stuck playing one note.

I know this is the sort of thing that is incredibly low priority in the grand scheme of things, but I thought it might be interesting for some of the more active emulator developers to look at and try to figure out what NNNesterJ is doing differently (correctly or perhaps incorrectly) that allows the game to play in this one particular emulator. I would love to know myself. Thanks for taking a look!

Procyon

Author:  *Spitfire_NES* [ Wed Jul 13, 2011 8:25 pm ]
Post subject: 

no to raise the dead but thats interesting. just tried this game out and i wonder what the problem could be....

Author:  Drag [ Thu Jul 14, 2011 7:39 pm ]
Post subject: 

Does it actually crash the emulator into closing itself, or does the game just freeze?

Author:  *Spitfire_NES* [ Thu Jul 14, 2011 7:59 pm ]
Post subject: 

Drag wrote:
Does it actually crash the emulator into closing itself, or does the game just freeze?


the emulator neither freezes nor crashes, the game hangs when you enter the boss's room. Weird how nesterj could play this right but no others...seems like something blocks the boss from appearing or something...

Give it a try in nestopia, when you reach one of the boss's rooms it just kinda hangs, and nothing happens, the music freezes on one note, i used rewind to leave the room, but i know the emu does not crash.

Author:  3gengames [ Thu Jul 14, 2011 8:05 pm ]
Post subject: 

Illegal opcodes maybe? Maybe one not documented very well? Weird thing. And you can't track it down?

Author:  *Spitfire_NES* [ Thu Jul 14, 2011 8:09 pm ]
Post subject: 

3gengames wrote:
Illegal opcodes maybe? Maybe one not documented very well? Weird thing. And you can't track it down?


i have no clue whats causing it, i always thought fds was pretty much 100 percent working and great. i came across this thread yesterday and since then it has peaked my interest. comparing code from NNNnesterj to nestopia is hard to do lol, :shock:


***update. My mistake the game does in fact crash.

Author:  Gilbert [ Fri Jul 15, 2011 9:48 am ]
Post subject: 

The linked page indeed said that VirtuaNES reported an illegal opcode error.
Maybe someone who have time would try to trace the code there with a debugger enabled emulator (Nintendulator, FCE*whatever* or even No$NES).

Author:  plasturion [ Fri Jul 15, 2011 1:26 pm ]
Post subject: 

I walked to the 1st boss with Nestopia debug mode and it throws illegal opcodes BRK and JAM causing CPU JAM! At titlescreen throws Expression: modulator.writing with Fds::Sound::WriteReg7.

Author:  *Spitfire_NES* [ Fri Jul 15, 2011 1:31 pm ]
Post subject: 

plasturion wrote:
I walked to the 1st boss with Nestopia debug mode and it throws illegal opcodes BRK and JAM causing CPU JAM! At titlescreen throws Expression: modulator.writing with Fds::Sound::WriteReg7.


so we need to erase/modify the illegal opcodes then... so it threw an error with sound, writereg7...hmm.

Author:  plasturion [ Fri Jul 15, 2011 3:05 pm ]
Post subject: 

I think maybe something cause that this opcodes appears. So best way is try to find out if WriteReg7 don't make any mess.

Let's see what is doing - Nestopia NstFds.cpp

Code:
      NES_POKE_D(Fds,4088)
      {
         sound.WriteReg7( data );
      }
      
      void Fds::Sound::WriteReg7(uint data)
      {
         NST_VERIFY( modulator.writing );

         if (modulator.writing)
         {
            Update();
            std::memmove( modulator.table, modulator.table + 1, Modulator::SIZE-1 );
            modulator.table[Modulator::SIZE-1] = Modulator::steps[data & REG8_MOD_DATA];
         }
      }


and NNNesterJ 0.23 in fdssnd.c
Code:
static void FDSSoundWrite(uint32 address, uint8 value)
{
   if (0x4040 <= address && address <= 0x407F)
   {
      apu->fdssound.op[1].wave[address - 0x4040] = LinearToLog(((int32)value & 0x3f) - 0x20);
   }
   else if (0x4080 <= address && address <= 0x408F)
   {
      int ch = (address < 0x4084);
      FDS_FMOP *pop = &apu->fdssound.op[ch];
      apu->fdssound.reg[address - 0x4080] = value;
      switch (address & 15)
      {
...
         case 8:
            {
               static int8 lfotbl[8] = { 0,1,2,3,-4,-3,-2,-1 };
               uint32 v = LinearToLog(lfotbl[value & 7]);
               apu->fdssound.op[0].wave[apu->fdssound.waveaddr++] = v;
               apu->fdssound.op[0].wave[apu->fdssound.waveaddr++] = v;
               if (apu->fdssound.waveaddr == 0x40)
               {
                  apu->fdssound.waveaddr = 0;
               }
            }
            break;

that's only suggest, I'm not sure it can be somehow connected with this issue, however the soundtrack is changing while the boss appears. It takes only last hex digit of address, so we're looking case 8?

Damn... I need to register if I want using VC++ express. The time trial has expired. Maybe this time someone else wants to have fun ;).

Author:  3gengames [ Fri Jul 15, 2011 3:22 pm ]
Post subject: 

Is it running code from RAM? Maybe your CPU is causing something in RAM to be changed wrong and crash?

Author:  *Spitfire_NES* [ Fri Jul 15, 2011 3:36 pm ]
Post subject: 

3gengames wrote:
Is it running code from RAM? Maybe your CPU is causing something in RAM to be changed wrong and crash?


whatever it is, 5 diff emus are all proving to do the same thing including nestopia, virtuanes and others....

Author:  Drag [ Sat Jul 16, 2011 1:24 am ]
Post subject: 

Perhaps the image really seriously is broken (bad "dump", I guess), and the fact that nesterj allowed the game to run was due to a bug?

It could also be the result of copy protection of some kind; I know disk-based c64 software had some hardware-implemented copy protections, such as purposefully unreadable sectors.

Author:  plasturion [ Sat Jul 16, 2011 5:26 am ]
Post subject: 

I've checked where fce ultra debug tool stuck when the boss seems to appear and...
Code:
00:803B:03        UNDEFINED
00:803C:01 03     ORA ($03,X) @ $02F3 = #$72
00:803E:61 62     ADC ($62,X) @ $0000 = #$D3
00:8040:F0 00     BEQ $8042
00:8042:00        BRK
00:8043:00        BRK
00:8044:92        UNDEFINED // Here debug trace stuck
00:8045:24 49     BIT $0049 = #$00
00:8047:92        UNDEFINED
00:8048:24 49     BIT $0049 = #$00
00:804A:DB        UNDEFINED
00:804B:B6 6D     LDX $006D,Y @ $0080 = #$FE
00:804D:DB        UNDEFINED
00:804E:B6 6D     LDX $006D,Y @ $0080 = #$FE
00:8050:04        UNDEFINED

looks like this is not so good place to code execute.

Author:  *Spitfire_NES* [ Sat Jul 16, 2011 8:37 am ]
Post subject: 

So looks like something needs to be added or modified...maybe an exception to address while boss appears and music changing. Isn't fce issue the same as nestopia?

Page 1 of 5 All times are UTC - 7 hours
Powered by phpBB® Forum Software © phpBB Group
http://www.phpbb.com/