It is currently Wed Sep 19, 2018 11:14 am

All times are UTC - 7 hours





Post new topic Reply to topic  [ 15 posts ] 
Author Message
PostPosted: Thu Aug 23, 2018 9:55 am 
Offline
User avatar

Joined: Mon Dec 29, 2014 1:46 pm
Posts: 817
Location: New York, NY
I've noticed a few instances in Nintaco where Castlevania will randomly pause as if the Start button were pressed. Google search results seem to suggest that it might be a bug in the actual game (see here and here). Might this be APU DMC related? I currently do not have an easy way to reproduce this, else I would have done some debugging.


Top
 Profile  
 
PostPosted: Thu Aug 23, 2018 10:48 am 
Offline

Joined: Sun Sep 19, 2004 11:12 pm
Posts: 20558
Location: NE Indiana, USA (NTSC)
If a game doesn't compensate for the NTSC DMC DMA clock glitch, Up occasionally leaks into the previous button, which is Start. Are you holding Up when this occurs? Do you occasionally get random right presses out of nowhere?


Top
 Profile  
 
PostPosted: Thu Aug 23, 2018 11:13 am 
Offline
User avatar

Joined: Mon Dec 29, 2014 1:46 pm
Posts: 817
Location: New York, NY
tepples wrote:
If a game doesn't compensate for the NTSC DMC DMA clock glitch, Up occasionally leaks into the previous button, which is Start. Are you holding Up when this occurs? Do you occasionally get random right presses out of nowhere?


That's a good question. I vaguely remember this happening while walking up stairs, but I'm not 100% sure. I'll pay more attention to what I was pressing at the time if and when it happens again.

BTW, what can a game do to safeguard against this issue?


Top
 Profile  
 
PostPosted: Thu Aug 23, 2018 11:19 am 
Offline
User avatar

Joined: Fri Nov 19, 2004 7:35 pm
Posts: 4076
Read joystick twice, and if they don't agree read it again

_________________
Here come the fortune cookies! Here come the fortune cookies! They're wearing paper hats!


Top
 Profile  
 
PostPosted: Thu Aug 23, 2018 11:42 am 
Offline
User avatar

Joined: Mon Dec 29, 2014 1:46 pm
Posts: 817
Location: New York, NY
Dwedit wrote:
Read joystick twice, and if they don't agree read it again


Clever.


Top
 Profile  
 
PostPosted: Thu Aug 23, 2018 12:10 pm 
Offline
User avatar

Joined: Mon Jan 03, 2005 10:36 am
Posts: 3127
Location: Tampere, Finland
Dwedit wrote:
Read joystick twice, and if they don't agree read it again

Or use this recently discovered method (which in hindsight is quite obvious, but nobody had figured it out before Rahsennor): viewtopic.php?f=2&t=14319

However, It's highly unlikely that any commercial game from back in the days would be using this method, although it's plausible that some might depend on it unintentionally (I think Rainwarrior mentioned some ROM of his where he didn't get the DMC glitch even though he didn't prepare for it.)

Also, ironically, because some emulators attempt to emulate the DMC glitch but don't do it 100% correctly, you may lose some emulator compatibility by using this method (you'll get the glitch even though it would never occur on real NES).

_________________
Download STREEMERZ for NES from fauxgame.com! — Some other stuff I've done: fo.aspekt.fi


Top
 Profile  
 
PostPosted: Thu Aug 23, 2018 12:34 pm 
Offline
User avatar

Joined: Sun Jan 22, 2012 12:03 pm
Posts: 6804
Location: Canada
Yes, I accidentally used it in the original release of the 2A03 Puritans album compilation. Worked by luck because the NMI was simple and deterministic enough, and the controller poll happened to be done in there as well.

In fairness, though, it was hardware tested before release. I would have seen the "spurious right press" behaviour if it was happening, cause it'd cause the track to skip. When I noticed I'd forgotten to (intentionally) DPCM-safe my controller code though I was flabbergasted. I looked over and over for logic that might somehow suppress it, but I couldn't find any. (I updated the ROM and code on that website though, subsequently.)

Anyway, here's SMB3's version of the simple/standard version:
Code:
        jsr poll_controller  ; 0F:FEB9:20 0B FF  JSR $FF0B
reread: lda controller       ; 0F:FEBC:A5 00     LDA $0000 = #$00
        pha                  ; 0F:FEBE:48        PHA
        jsr poll_controller  ; 0F:FEBF:20 0B FF  JSR $FF0B
        pla                  ; 0F:FEC2:68        PLA
        cmp controller       ; 0F:FEC3:C5 00     CMP $0000 = #$00
        bne reread           ; 0F:FEC5:D0 F5     BNE $FEBC

Though, due to some lack of thread safety on SMB's part with the NMI, a robot can keep changing the gamepad bits for every read to lock up the polling thread until the NMI crashes into it, allowing a very short TAS. (TBH given that you need a machine to do this input I wouldn't really even call it a bug.)


Top
 Profile  
 
PostPosted: Thu Aug 23, 2018 12:44 pm 
Offline
User avatar

Joined: Thu Mar 31, 2016 11:15 am
Posts: 359
If zeroone didn't know about the DMC glitch, why would it be implemented in nintaco? :P

You have to specifically code the glitchy behavior in, no?


Top
 Profile  
 
PostPosted: Thu Aug 23, 2018 12:48 pm 
Offline
User avatar

Joined: Mon Jan 03, 2005 10:36 am
Posts: 3127
Location: Tampere, Finland
pubby wrote:
If zeroone didn't know about the DMC glitch, why would it be implemented in nintaco? :P

You have to specifically code the glitchy behavior in, no?

Yeah, unless you do the emulation at an extremely low level (not really practical except in FPGAs and such), at which point it should happen naturally.

_________________
Download STREEMERZ for NES from fauxgame.com! — Some other stuff I've done: fo.aspekt.fi


Top
 Profile  
 
PostPosted: Thu Aug 23, 2018 1:47 pm 
Offline
User avatar

Joined: Mon Dec 29, 2014 1:46 pm
Posts: 817
Location: New York, NY
pubby wrote:
If zeroone didn't know about the DMC glitch, why would it be implemented in nintaco? :P

You have to specifically code the glitchy behavior in, no?


I coded those parts so long ago that I simply don't remember the details any more. I mentioned the DMC glitch in the OP, which demonstrated that I had a vague recollection of it. And I didn't know if that was the cause or if it was an emulation issue, and it still might be the latter.


Top
 Profile  
 
PostPosted: Fri Aug 24, 2018 6:24 am 
Offline
User avatar

Joined: Mon Dec 29, 2014 1:46 pm
Posts: 817
Location: New York, NY
When I get a chance, I'll study how Castlevania polls for input to see if it is performing a double check.

If I recall correctly, wasn't Castlevania a port of an FDS game. Did the FDS hardware also suffer from this issue?

Also, I reviewed the Nintaco source and it is indeed emulating the glitch. But is there really any reason to do so? Do any games actually depend on this glitch being present?


Top
 Profile  
 
PostPosted: Fri Aug 24, 2018 6:36 am 
Offline

Joined: Sun Sep 19, 2004 11:12 pm
Posts: 20558
Location: NE Indiana, USA (NTSC)
FDS runs on a Famicom, which is NTSC and therefore has this clock glitch issue.

But I imagine that some FDS games later ported to cartridge might double-check on cartridge but not on FDS, particularly if the cartridge version used the DMC to replace the FDS wavetable channel. The first place to look for these differences is four well-known ports: Metroid, The Legend of Zelda, Kid Icarus, and Doki Doki Panic (which became Super Mario Bros. 2: Mario Madness).


Top
 Profile  
 
PostPosted: Fri Aug 24, 2018 6:29 pm 
Offline
Site Admin
User avatar

Joined: Mon Sep 20, 2004 6:04 am
Posts: 3556
Location: Indianapolis
zeroone wrote:
Also, I reviewed the Nintaco source and it is indeed emulating the glitch. But is there really any reason to do so? Do any games actually depend on this glitch being present?

I doubt it could be desirable for anything, but there's a pretty wide library of stuff, so it's hard to say for sure. I was about to make a smart-ass remark about games not caring if sprite DMA takes only 1 cycle to complete, but quickly realized that's wrong, but rare.. only Bigfoot and Garage Cart menu come to mind as doing a mid-frame DMA.

I wouldn't rule out a game relying on DPCM clock glitch for something, but as far as I can tell it's just a useless annoyance. Re-reading the controller though does take extra CPU time, and that certainly could affect something, if the game was that close to overflowing some kind of CPU time limit. Weird corner cases, stuff like that.

On a side note, I remember when I first heard about the DPCM clock glitch, Castlevania was one of the first games I wondered about. First because it's an early 3rd-party game using DPCM, and second because when you get hit, the game plays the HUP! sample and you lose control for a moment. While the sample is playing, the game doesn't care what button you're pressing (though I haven't tried pausing it then, maybe I'm wrong). I see 3 possibilities: 1) Konami knew exactly what they were doing, 2) the glitch affected the game design (wouldn't that be funny), or 3) they thought to use DPCM because they're ignoring the controller anyways. At any rate, I would be surprised if it did multiple reads of the controller.


Top
 Profile  
 
PostPosted: Fri Aug 24, 2018 6:36 pm 
Offline

Joined: Sun Sep 19, 2004 11:12 pm
Posts: 20558
Location: NE Indiana, USA (NTSC)
Memblers wrote:
I wouldn't rule out a game relying on DPCM clock glitch for something

If anything, a ROM misbehaving in an emulator the same way it misbehaves on hardware is good for indicating to the ROM's developer that the ROM needs to be fixed.

Memblers wrote:
On a side note, I remember when I first heard about the DPCM clock glitch, Castlevania was one of the first games I wondered about. First because it's an early 3rd-party game using DPCM, and second because when you get hit, the game plays the HUP! sample and you lose control for a moment. While the sample is playing, the game doesn't care what button you're pressing (though I haven't tried pausing it then, maybe I'm wrong).

Does it care what buttons are pressed while drum samples are playing?


Top
 Profile  
 
PostPosted: Fri Aug 24, 2018 7:00 pm 
Offline
User avatar

Joined: Sun Sep 19, 2004 9:28 pm
Posts: 3589
Location: Mountain View, CA
There were also two versions/revisions of Castlevania. Linear binary file compare isn't helpful for this, too many changes, so disassembly + manual comparison would have to be done.

Code:
00d93c9f6b8aefb8b6c02b20147df4ec *Castlevania (U) (PRG0) [!].nes
52eb3f7e2c5fc765aa71f21c85f0770e *Castlevania (U) (PRG1) [!].nes


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 15 posts ] 

All times are UTC - 7 hours


Who is online

Users browsing this forum: No registered users and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group