| |
mhindsbo
Registered: Dec 2014 Posts: 51 |
$DC08 / TOD issue in Vice?
I am using $DC08 as the seed value for a random function and in Vice it always reads as 0 whereas when I run it on real hardware it has the expected behavior.
I do "unlatch" the TOD in my initialization code and when I use the monitor in Vice it shows values != 0 in $DC08 - $DC0B (as you would expect), but lda $DC08 always returns 0 in AR.
Is this a known Vice issue or am I doing something wrong? |
|
| |
Flavioweb
Registered: Nov 2011 Posts: 463 |
If you see right values with monitor, i guess is your fault.
Do you modify $01 to turn off I/O in your code?
Do you have some irq code that trashes .A? |
| |
chatGPZ
Registered: Dec 2001 Posts: 11386 |
are you using autostart? then you might always get the same value. also there were a couple odd bugs in the TOD emulation in 2.4 - try a nightly build from vice.pokefinder.org |
| |
mhindsbo
Registered: Dec 2014 Posts: 51 |
thanks. yes using auto start, but checking at different intervals. the weird thing was that the value read (0), as shown in the vice monitor was different than what the memory window showed. I am using 2.4 so will try a nightly build.
as mentioned on actual hardware it was working as expected.
thanks again for the pointer. |
| |
chatGPZ
Registered: Dec 2001 Posts: 11386 |
the monitor can not always be trusted, unfortunately... sometimes the value doesnt show what it should be, and sometimes (even worse imho) when you show it it will have side effects (like reading $dd0d will ACK the irq, or sth like that) |
| |
mhindsbo
Registered: Dec 2014 Posts: 51 |
is this also true when you simply looking at the memory window? or only when stepping through code and watching the register window? I was not entering code in the monitor, just watching it. |
| |
TheRyk
Registered: Mar 2009 Posts: 2246 |
Some of the CIA regs are even initialised/set zero by LDA. Spooky stuff if ViceMon really does the same after entering IO to display values. Wouldn't have expected that, but hopefully is not the case :) Edit: Not sure about AR/other cartridge monitors though...
Workaraound to make it a little "more random"
a) Implement some "Press Space/Any Key" before you call TOD for the first time, so that most users won't always trigger your TOD stuff at always exactly the same cycle
b) Combine TOD with other stuff such as SID noise, Frame counters, or even weirder stuff
PS: Wasn't there some Autostart option to prevent exactly this issue...? |
| |
Bitbreaker
Registered: Oct 2002 Posts: 508 |
Quoting TheRykSome of the CIA regs are even initialised/set zero by LDA. Spooky stuff if ViceMon really does the same after entering IO to display values. Wouldn't have expected that, but hopefully is not the case :) Edit: Not sure about AR/other cartridge monitors though...
Built in monitors like AR will for sure just read the registers via some ld* opcode and by that also trigger things like irq acknowledgements. As for the VICE monitor i thought it might show values without really touching the registers. At least here it would be technically possible. |
| |
MagerValp
Registered: Dec 2001 Posts: 1078 |
Syntax: sidefx [on|off|toggle]
Abbreviation: sfx
Control how monitor generated reads affect memory locations that have read side-effects. If the argument is 'on' then reads may cause side-effects. If the argument is 'off' then reads don't cause side-effects. If the argument is 'toggle' then the current mode is switched. No argument displays the current state. |
| |
soci
Registered: Sep 2003 Posts: 480 |
Quoting TheRykPS: Wasn't there some Autostart option to prevent exactly this issue...?
-autostart-delay-random
Enable random initial autostart delay. |
| |
soci
Registered: Sep 2003 Posts: 480 |
Quoting mhindsboI am using $DC08 as the seed value for a random function and in Vice it always reads as 0 whereas when I run it on real hardware it has the expected behavior
Same on some real machines running off switching power supplies. I think I've put in a 50Hz oscillator in most of my machines by now, for rare cases like above. Still I don't like to use the TOD as a clock in my code as it might not run for everyone. |
| |
chatGPZ
Registered: Dec 2001 Posts: 11386 |
- yes, the monitor _should_ not have side-effects when accessing I/O. however, that part of the code apparently wasn't implemented properly in all cases (i have fixed a bunch of things related to that since 2.4, but i still would'nt guarantee it works 100%)
- the random autostart delay is 5 frames maximum (by default anyway), you'd have to make that value quite a bit larger to see values other than 0 in dc08 often enough (iirc the TOD cant expected to be running after plain reset/kernal init though) |