ttlworks wrote:
When the hour counter reaches 12, PM toggles.
Note, that the ML output carry doesn't go into the equation,
so writing decimal 12 into the hours if the hours already were not 12 this will toggle PM.
;...
PM flag:
We have sort of a comparator which checks if HH=1 and if HL=$2.
The rising edge of the comparator output toggles the PM flag.
Again, note that the MH output carry doesn't go into this.
The PM flag toggles when TOD reaches 12:00:00, that yes.
But a side effect is that when writing "HH=1 and HL=$2" to the TOD_HR register,
and the TOD_HR register previously was not "HH=1 and HL=$2", this toggles the PM flag.
In this case, you would have to write with the PM Bit _inverted_ into the TOD_HR register
to compensate for this.
This strongly implies (but reading carefully, it doesn't literally say it) that writing $12 to the Hours register when it already contains that value will *not* toggle PM.
But it seems that that is not the case. Even writing $12 when it was $12 already toggles PM, according to tests that have been reported to the VICE team:
https://sourceforge.net/p/vice-emu/bugs/1988/Was this how the above explanation was meant, or is this unexpected? If the latter, could this work out differently on different CIA models perhaps?