It is currently Fri Feb 23, 2018 5:26 am

All times are UTC - 7 hours





Post new topic Reply to topic  [ 10 posts ] 
Author Message
PostPosted: Sun Jan 31, 2016 3:27 pm 
Offline
User avatar

Joined: Fri May 08, 2015 7:17 pm
Posts: 1961
Location: DIGDUG
Hello all,

Yesterday I got a PowerPak, and I'm testing my games today...

Sadly, I'm getting errant button presses from DMC music corruption.

This is the code I've been working with...(and is the sample code on my blog, btw...)

Code:
_Get_Input:
   lda _joypad1
   sta _joypad1old
   lda _joypad2
   sta _joypad2old
   
   ldx #$01   ;strobe controller 1
   stx $4016
   dex
   stx $4016
   
   ldy #$08
GetInput2:      ;get first read, store them as a test
   lda $4016
   and #$03
   cmp #$01
   rol _joypad1test
   lda $4017
   and #$03
   cmp #$01
   rol _joypad2test
   dey
   bne GetInput2
   
   ldx #$01   ;restrobe strobe controller 1
   stx $4016
   dex
   stx $4016
   
   ldy #$08
GetInput3:      ;read again, store them as joypads
   lda $4016
   and #$03
   cmp #$01
   rol _joypad1
   lda $4017
   and #$03
   cmp #$01
   rol _joypad2
   dey
   bne GetInput3
   
CompareInput:
   lda _joypad1
   cmp _joypad1test
   bne :+
   lda _joypad2
   cmp _joypad2test
   bne :+
   rts            ;if same, done
   
:   lda _joypad1
   sta _joypad1test
   lda _joypad2
   sta _joypad2test
   ldy #$08
   jmp GetInput3   ;if different, reread


I can't spot an error.

But, from blargg's sample code, (circuitously directed to from the wiki), he's reading the joypads 4 times, and I'm only reading 3 x. Could this be the source of the error?

_________________
nesdoug.com -- blog/tutorial on programming for the NES


Last edited by dougeff on Sun Jan 31, 2016 9:08 pm, edited 1 time in total.

Top
 Profile  
 
PostPosted: Sun Jan 31, 2016 3:31 pm 
Offline

Joined: Sun Sep 19, 2004 11:12 pm
Posts: 19663
Location: NE Indiana, USA (NTSC)
Usually if there's a DPCM glitch, the spurious press will be Right. Is that what you're seeing?

Would it be acceptable to read only twice and discard the reads (instead using the previous frame's presses) if they differ? Because the gamepad driver I use does that and has no problem with spurious presses.


Top
 Profile  
 
PostPosted: Sun Jan 31, 2016 3:37 pm 
Offline
User avatar

Joined: Fri May 08, 2015 7:17 pm
Posts: 1961
Location: DIGDUG
The games are pausing randomly (START) when DMC sounds play. And occasionally Select. I'm not sure if R is or not.

_________________
nesdoug.com -- blog/tutorial on programming for the NES


Top
 Profile  
 
PostPosted: Sun Jan 31, 2016 4:00 pm 
Offline
User avatar

Joined: Fri May 08, 2015 7:17 pm
Posts: 1961
Location: DIGDUG
Hmm. Maybe DMC is a 'red herring', because I'm pretty sure one of the problem games doesn't even use DMC samples.

I'm very confused/annoyed.

_________________
nesdoug.com -- blog/tutorial on programming for the NES


Top
 Profile  
 
PostPosted: Sun Jan 31, 2016 5:06 pm 
Offline

Joined: Sun Sep 19, 2004 11:12 pm
Posts: 19663
Location: NE Indiana, USA (NTSC)
Do random pauses occur while holding Up?


Top
 Profile  
 
PostPosted: Sun Jan 31, 2016 5:29 pm 
Offline
User avatar

Joined: Fri May 08, 2015 7:17 pm
Posts: 1961
Location: DIGDUG
Not holding UP, but if I tap UP repeatedly, it goes into Pause mode, as if START was pressed.

_________________
nesdoug.com -- blog/tutorial on programming for the NES


Top
 Profile  
 
PostPosted: Sun Jan 31, 2016 5:32 pm 
Offline
User avatar

Joined: Sun Jan 22, 2012 12:03 pm
Posts: 6037
Location: Canada
You may want to do controllers individually, rather than reading them in parallel like that? I seem to recall notes from blargg that roughly 2 read loops of a single controller can fit between samples, but 3 read loops might not fit. (I might be misremembering though.)

Edit: probably isn't the problem here, though.


Last edited by rainwarrior on Sun Jan 31, 2016 5:39 pm, edited 2 times in total.

Top
 Profile  
 
PostPosted: Sun Jan 31, 2016 5:34 pm 
Offline
User avatar

Joined: Sun Jan 22, 2012 12:03 pm
Posts: 6037
Location: Canada
Spotted an error: if the test fails at the end, you jmp to GetInput3 but don't restrobe the controllers.


Top
 Profile  
 
PostPosted: Sun Jan 31, 2016 5:36 pm 
Offline
User avatar

Joined: Fri May 08, 2015 7:17 pm
Posts: 1961
Location: DIGDUG
Aha, that could be it. Thanks.

I'll test it later tonight.

_________________
nesdoug.com -- blog/tutorial on programming for the NES


Top
 Profile  
 
PostPosted: Sun Jan 31, 2016 9:07 pm 
Offline
User avatar

Joined: Fri May 08, 2015 7:17 pm
Posts: 1961
Location: DIGDUG
That was it. Thanks rainwarrior. I can now confirm that my game is hardware compliant.

This is what it looks like now...

Code:
_Get_Input:
   lda _joypad1
   sta _joypad1old
   lda _joypad2
   sta _joypad2old
   
   ldx #$01   ;strobe controller 1
   stx $4016
   dex
   stx $4016
   
   ldy #$08
Get_Input2:      ;get first read, store them as a test
   lda $4016
   and #$03
   cmp #$01
   rol _joypad1test
   lda $4017
   and #$03
   cmp #$01
   rol _joypad2test
   dey
   bne Get_Input2

GetInputFix:
   ldx #$01   ;restrobe strobe controller 1
   stx $4016
   dex
   stx $4016
   
   ldy #$08
Get_Input3:      ;read again, store them as joypads
   lda $4016
   and #$03
   cmp #$01
   rol _joypad1
   lda $4017
   and #$03
   cmp #$01
   rol _joypad2
   dey
   bne Get_Input3
   
CompareInput:
   lda _joypad1
   cmp _joypad1test
   bne :+
   lda _joypad2
   cmp _joypad2test
   bne :+
   rts            ;if same, done
   
:   lda _joypad1
   sta _joypad1test
   lda _joypad2
   sta _joypad2test
   ; ldy #$08
   jmp GetInputFix   ;if different, reread


Give me a little time to redo the links to my game, thanks.

_________________
nesdoug.com -- blog/tutorial on programming for the NES


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

All times are UTC - 7 hours


Who is online

Users browsing this forum: Fiskbit, Google Adsense [Bot], Pokun and 10 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:  
cron
Powered by phpBB® Forum Software © phpBB Group