NESDev and Strangulation Records messageboards
Forum Index | FAQ | New User | Login | Search

Previous ThreadView All ThreadsNext ThreadShow in Flat Mode*


SubjectIndexed read/write of ports?  
Posted byphoenix
Posted on8/14/04 6:15 PM
From IP68.75.30.96  



I've run across something that seems inconsistent on different emulators, so I'd like some opinions on which behavior is most correct.

In my NES programming, I've been accessing ports, such as $4016, using indexed addressing. For example:

ldx #$0 ;Read controller 0 first
lda #$1 ;Strobe controller port
sta $4016, x
lda #$0
sta $4016, x
lda $4016, x ;Read a button
...

I had found this handy for writing tight code, for instance, to read both controllers at once.

This works on some emulators (Nesten, Nesticle), but has disasterous consequences on other emulators (Nestopia, Nintendulator). For instance, somehow the code above causes the status for the A button to be skipped on the first read, instead returning the status of the B button. If I remove the indexing, the code works fine for all emulators. These same conditions seem to be true for any memory-mapped port that I access.

Which set of emulators is being more true to the NES hardware? Is this some arcane behavior of the 6502 that is emulated by Nintendulator and Nestopia that I am encountering? Or is this an emulator bug?

Thanks,
Phoenix



-
Entire Thread
Subject  Posted byPosted On
.Indexed read/write of ports?  phoenix8/14/04 6:15 PM
.*Re: Indexed read/write of ports?  tepples8/15/04 00:42 AM
..*Re: Indexed read/write of ports?  Memblers8/15/04 01:51 AM
...*Re: Indexed read/write of ports?  phoenix8/16/04 2:46 PM
...*Re: Indexed read/write of ports?  tepples8/15/04 05:27 AM
....*Re: Indexed read/write of ports?  blargg8/15/04 7:28 PM
.*Re: Indexed read/write of ports?  Memblers8/14/04 11:10 PM
..*Reproducing the Issue on $2007  phoenix8/19/04 03:51 AM
...*Re: Reproducing the Issue on $2007  blargg8/19/04 05:21 AM
...*Re: Reproducing the Issue on $2007  Memblers8/19/04 04:08 AM
....*Re: Reproducing the Issue on $2007  phoenix8/19/04 11:10 AM
..*Re: Indexed read/write of ports?  phoenix8/16/04 2:54 PM
...*Re: Indexed read/write of ports?  blargg8/16/04 8:35 PM
....*Re: Indexed read/write of ports?  quietust8/16/04 9:18 PM
.....*Re: Indexed read/write of ports?  phoenix8/18/04 02:38 AM
Jump to

Memblers' homepage             Contact Me

Forums powered by WWWThreads Demo