Bomberman hangs on opening title

Discuss emulation of the Nintendo Entertainment System and Famicom.

Moderator: Moderators

austere
Posts: 8
Joined: Sun Dec 28, 2014 12:04 am

Bomberman hangs on opening title

Post by austere » Thu Jan 08, 2015 3:57 am

This had me stumped for ages, in my emulator, bomberman hangs on the opening title. I've coded up loopy's register model and Super Mario Bros works fine -- hell, I've got most MMC3 games working fine and glitch free. But Bomberman still doesn't run. :mrgreen: Any clue what it could be? Does it check the sprite overflow flag before displaying the menu select sprite (not displayed before it hangs)?

User avatar
Zepper
Formerly Fx3
Posts: 3192
Joined: Fri Nov 12, 2004 4:59 pm
Location: Brazil
Contact:

Re: Bomberman hangs on opening title

Post by Zepper » Thu Jan 08, 2015 4:10 am

The easy way is to spot the PC register and analyze the CPU code there. In short words, a disassembler.

WedNESday
Posts: 1236
Joined: Thu Sep 15, 2005 9:23 am
Location: Berlin, Germany
Contact:

Re: Bomberman hangs on opening title

Post by WedNESday » Thu Jan 08, 2015 5:02 am

Bomberman uses sprite 0 to get the game running. But I don't know if that would cause the title screen to freeze like SMB.

User avatar
Zepper
Formerly Fx3
Posts: 3192
Joined: Fri Nov 12, 2004 4:59 pm
Location: Brazil
Contact:

Re: Bomberman hangs on opening title

Post by Zepper » Thu Jan 08, 2015 7:05 pm

austere wrote:This had me stumped for ages, in my emulator, bomberman hangs on the opening title. I've coded up loopy's register model and Super Mario Bros works fine -- hell, I've got most MMC3 games working fine and glitch free. But Bomberman still doesn't run. :mrgreen: Any clue what it could be? Does it check the sprite overflow flag before displaying the menu select sprite (not displayed before it hangs)?
Check if the game file has a good iNES header.
a) The DiskDude string found at the 8th byte.
b) The mapper number is incorrect (should be zero).
c) If a) is true, then b) is really true.
d) Check the CRC32 to identify a good/bad dump.

austere
Posts: 8
Joined: Sun Dec 28, 2014 12:04 am

Re: Bomberman hangs on opening title

Post by austere » Thu Jan 08, 2015 9:08 pm

I checked the CRC and it looks ok (F2FC8212), it's quite likely something to do with sprite 0 but I'm not sure what yet.
WedNESday wrote:Bomberman uses sprite 0 to get the game running. But I don't know if that would cause the title screen to freeze like SMB.
I suspected this, I ran blargg's sprite0 tests. I passes most non-timing tests except 07.screen_bottom.nes where it fails with status #3.
3) Can hit when Y < 239

User avatar
Zepper
Formerly Fx3
Posts: 3192
Joined: Fri Nov 12, 2004 4:59 pm
Location: Brazil
Contact:

Re: Bomberman hangs on opening title

Post by Zepper » Fri Jan 09, 2015 5:47 am

You're running the japanese version.

Japan ROM should be CRC $F2FC8212.
http://bootgod.dyndns.org:7777/profile.php?id=1495

austere
Posts: 8
Joined: Sun Dec 28, 2014 12:04 am

Re: Bomberman hangs on opening title

Post by austere » Fri Jan 09, 2015 8:31 am

Excellent resource thanks for the link!

Yup, ran the NES (US) version (DB9DCF89) and it showed identical behaviour. I disassembled Japanese bomberman ROM to see where it access the sprite hit flag:

Code: Select all

reset:
		sei
		cld
		ldx #$ff
		txs
lbl_c005:	lda $2002		;PPU Status Register
		bpl lbl_c005       ;Wait for vblank
lbl_c00a:	lda $2002		;PPU Status Register
		bpl lbl_c00a       ;Wait for vblank
		jmp main_game

...
(end of nmi routine)
lbl_c16a:	lda $2002		;PPU Status Register
		and #$40          ;Check sprite 0 hit
		bne lbl_c16a      ;Wait until not hit
lbl_c171:	lda $2002		;PPU Status Register
		and #$40		;Check sprite 0 hit
		beq lbl_c171      ;Wait until hit
		lda $e
		sta $2005		;VRAM Address Register #1
		lda $f
		sta $2005		;VRAM Address Register #1
lbl_c182:	lda #$5
		eor $db
		sta $db
		pla
		tay
		pla
		tax
		pla
		rti

...
lbl_c11e:	lda $2002		;PPU Status Register (clear vblank)
		jsr lbl_c28e
...
lbl_c28e:	lda $d
		sta $2001		;PPU Control Register #2
		lda #$0
		ldx #$0
		jsr lbl_c18e
		lda #$0
		sta $2005		;VRAM Address Register #1
		sta $2005		;VRAM Address Register #1
		lda $c
		sta $2000		;PPU Control Register #1 
		rts

main_routine -> lbl_c1ea ... -> lbl_c283

lbl_c283:	lda $2002		;PPU Status Register
		bmi $c283
lbl_c288:	lda $2002		;PPU Status Register
		bpl lbl_c288
		rts
So I wonder what's going on, the NMI routine should be completing as the music doesn't hang, the selection sprite simply doesn't show. Interestingly, the sprite 0 code isn't run because it waits for a value in the zero page ($60) to be non-zero before running it, so I'll look for clues there as only the code in $C564-$c587 and $c5c6-$c5f7 writes to $60 explicitly.

User avatar
Zepper
Formerly Fx3
Posts: 3192
Joined: Fri Nov 12, 2004 4:59 pm
Location: Brazil
Contact:

Re: Bomberman hangs on opening title

Post by Zepper » Fri Jan 09, 2015 9:21 pm

I disabled sprite 0 hits in my emulator. For my surprise, the title screen is functional. The game freezes only when the gameplay starts.

User avatar
Anes
Posts: 604
Joined: Tue Dec 21, 2004 8:35 pm
Location: Argentina
Contact:

Re: Bomberman hangs on opening title

Post by Anes » Sat Jan 10, 2015 5:53 am

I It happened to me until i got a good nmi timming emulation. Check that.
ANes

User avatar
Zepper
Formerly Fx3
Posts: 3192
Joined: Fri Nov 12, 2004 4:59 pm
Location: Brazil
Contact:

Re: Bomberman hangs on opening title

Post by Zepper » Sat Jan 10, 2015 7:17 am

Yes. It is a problem with NMI timing. I just disabled it and the title screen is frozen. It's no way related with sprite zero.

austere
Posts: 8
Joined: Sun Dec 28, 2014 12:04 am

Re: Bomberman hangs on opening title

Post by austere » Sat Jan 10, 2015 8:52 am

Thanks guys! I guess something to add to the hard to emulate list :P (it's funny since Super Mario Bros 3 works with some glitches in roof crushing scenes heh). The NMI timing inaccuracy might stem from the fact that I use the best case cycle count for all opcodes in my 6502 and that seems to work for [almost?] all games I've tried so far. Are your cores fairly accurate in cycle count?

tepples
Posts: 21971
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Re: Bomberman hangs on opening title

Post by tepples » Sat Jan 10, 2015 9:38 am

Emulators that can run a wide variety of commercial NES games need to have accurate cycle counts for all instructions. Games' raster effect loops can and do depend on extra cycles inserted due to page crossing.

WedNESday
Posts: 1236
Joined: Thu Sep 15, 2005 9:23 am
Location: Berlin, Germany
Contact:

Re: Bomberman hangs on opening title

Post by WedNESday » Sat Jan 10, 2015 9:46 am

austere wrote:The NMI timing inaccuracy might stem from the fact that I use the best case cycle count for all opcodes in my 6502 and that seems to work for [almost?] all games I've tried so far. Are your cores fairly accurate in cycle count?
You mean you don't calculate the correct number of cycles an opcode might need in the correct manner?

No offense, but it annoys me so much that people come to this forum with problems like this before they have even implemented even the most basic of CPU accuracy and then ask us why game A or B doesn't work properly.

User avatar
Anes
Posts: 604
Joined: Tue Dec 21, 2004 8:35 pm
Location: Argentina
Contact:

Re: Bomberman hangs on opening title

Post by Anes » Sat Jan 10, 2015 9:59 am

WedNESday wrote:No offense, but it annoys me so much that people come to this forum with problems like this before they have even implemented even the most basic of CPU accuracy and then ask us why game A or B doesn't work properly.
The thing is that you have reached as experienced developer emu author and/or .rom author.
I remember when you were a beginner and made question such as "is there not a technical doc othat NES 2C02 reference??" Making note that it was too difficult to you. (i don't wan't to search the link for your old post, but you remember it don't you?)

And no offense to you, but everybody was a begginer at first and needed help (like you) to work around a problem.
So, if you think the question or issue somebody expose here is too "noob" remember your old days when you had the Signature "Wednesday, the best emulator in the net.... well according to the author" and don't reply the noob question if you think so.
ANes

austere
Posts: 8
Joined: Sun Dec 28, 2014 12:04 am

Re: Bomberman hangs on opening title

Post by austere » Sat Jan 10, 2015 10:18 am

tepples wrote:Emulators that can run a wide variety of commercial NES games need to have accurate cycle counts for all instructions. Games' raster effect loops can and do depend on extra cycles inserted due to page crossing.
I did assume so, I never really expected many games to run given that I didn't account for page crossing and branch adjustment cycles. I've made accommodations for adjustment in the code but haven't bothered changing the cycle count until I had everything else working. I was actually surprised that most things I've thrown at it worked fairly well, even Shatterhand which has faux parallax scrolling.
WedNESday wrote:No offense, but it annoys me so much that people come to this forum with problems like this before they have even implemented even the most basic of CPU accuracy and then ask us why game A or B doesn't work properly.
No offense taken but "most basic of CPU accuracy" is kind of vague, like I said, I assumed best case (i.e didn't account for zero page crossing or branch miss). It's not like I set the cycle count to 4 for all instructions, I used the correct base values. Anyway, I'm sure someone else who has this problem with bomberman in the future will find this post and not ask the question again thanks to Anes and Zepper's hints towards correct behaviour. I mean that's the point of a forum after all, WedNESday. ;)

Post Reply