a couple nestopia apu questions

Discuss NSF files, FamiTracker, MML tools, or anything else related to NES music.

Moderator: Moderators

Post Reply
User avatar
*Spitfire_NES*
Posts: 306
Joined: Fri May 21, 2010 4:10 pm

a couple nestopia apu questions

Post by *Spitfire_NES* » Thu Feb 12, 2015 7:42 pm

Regarding this website:

http://tasvideos.org/EmulatorResources/ ... Tests.html

I was looking through some of the notes at the bottom of the page and found these 3 little tidbits:

apu_reset/4017_timing: fail "Frame IRQ flag should be set sooner after power/reset. Failed #3"

apu_reset/4017_written: "At power, $4017 should be written with $00. Failed #2"

apu_reset/len_ctrs_enabled: "At reset, length counters should be enabled, triangle unaffected. Failed #3"

Regarding these 3 errors: I thought that $4017 was written with $00 on start-up or am i missing something here. (or maybe i am confusing this with something else) I'm currently tracing through the NstApu.cpp source and do not see the code regarding the $00 at power up for $4017. The other 2 i am not so sure about so maybe someone can help shed some light or if its simple enough maybe help me come up with a patch.

Now i know nestopia undead has a ticketing system for issues but i would like to try to use this as a learning experience. I also have seen where a lot of issues with nestopia stuff were popping up on here so i am certainly not using this as a place to post issues as well, but i find all the issues with nestopia's apu interesting since its among the "more accurate" emulators still out there.

User avatar
koitsu
Posts: 4215
Joined: Sun Sep 19, 2004 9:28 pm
Location: A world gone mad

Re: a couple nestopia apu questions

Post by koitsu » Thu Feb 12, 2015 8:25 pm

Old post, may be relevant for #1, which indicates that CPU cycle counts were incorrect for some opcodes in the emulator: viewtopic.php?p=91613#p91613

As for the 2nd issue ("At power, $4017 should be written with $00. Failed #2"), I would suggest that right before starting ROM code (i.e. before running any code at the RESET vector), see what $4017 "should" contain by looking at the code for that register and ensuring the default value is $00. I don't have my Windows development VM set up otherwise I'd step through and look myself.

According to http://wiki.nesdev.com/w/index.php/CPU_power_up_state $4017 should be $00 on power-on, but upon reset may be whatever the last value in the register was (i.e. pre-setting of $00 only applies to power-on).

User avatar
*Spitfire_NES*
Posts: 306
Joined: Fri May 21, 2010 4:10 pm

Re: a couple nestopia apu questions

Post by *Spitfire_NES* » Fri Feb 13, 2015 2:17 pm

Thanks for the reply koitsu. Any place you might think i can look? Im not finding much in Apu.cpp, which is where i thought it would be, but i will keep looking through the code.

User avatar
koitsu
Posts: 4215
Joined: Sun Sep 19, 2004 9:28 pm
Location: A world gone mad

Re: a couple nestopia apu questions

Post by koitsu » Fri Feb 13, 2015 4:27 pm

Random thoughts (no evidence this is in the code at all):

i) Memory allocations for blocks of memory relating to the $4xxx range (e.g. malloc() + memset()), depending on if code uses values from post-malloc as defaults (I do not know)

ii) What the actual $4017 register is assigned to variable-name-wise and work things back from there. This could be easy, it could be complex (e.g. variable may be part of a struct, and that struct may be pre-allocated and pre-zeroed by a malloc() during emulator launch but not zeroed during power-on every time).

Like with any emulator, the code base is going to be massive, and I wouldn't be surprised if the answer lied within some other file than Apu.cpp. No software I know of, including OO (despite socially proliferated as operating this way), is "fully independent" with all of its things. You really do have to know how something works/behaves "all the way down".

Post Reply