a couple nestopia apu questions

This is an archive of a topic from NESdev BBS, taken in mid-October 2019 before a server upgrade.
View original topic
a couple nestopia apu questions
by on (#141111)
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.
Re: a couple nestopia apu questions
by on (#141114)
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).
Re: a couple nestopia apu questions
by on (#141133)
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.
Re: a couple nestopia apu questions
by on (#141137)
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".