"The RIOT timer isn't being updated when a WSYNC is set. In other words, all the cycles from the time of the WSYNC to the end of the scan line don't update timer. Am I missing something or is this incorrect?"
and
"Also, it wasn't adding cycles to the timer when Maria was executing, and I am pretty certain this is incorrect as several PAL games use the timer (Xevious and Commando)."
I didn't know the answers so I devised the following tests :-
Test 1 - Wait for VBLANK to occur and time the duration of WSYNC.
Test 2 - Wait for VBLANK and then wait for MARIA to be in the active part of the display (zone 1) and time WSYNC.
Test 3 - Wait for VBLANK and then wait for MARIA to be in the active part of the display (zone 2) and time WSYNC.
WSYNC was timed because Sally (6502) would be held in HALT during that period and I wanted to see what would happen to PHI2 (supplying RIOTs clock).
I also wanted to time the WSYNC in two zones because the time taken by MARIA processing the Display List entries for those zones (in one of my games) would be different. Just in case DMA would have an effect.
All the tests would be run with DMA off and then DMA on.
Here is the code I used on the real hardware :-
; Test 1 ; ====== ; Time WSYNC in VBLANK jsr WaitForVBlank lda #255 sta WSYNC sta TIM1T sta WSYNC lda INTIM jsr DebugOut ; Test 2 ; ====== ; Time WSYNC in the active frame's 1st zone jsr WaitForVBlank @L1: lda MSTAT bmi @L1 lda #255 sta WSYNC sta TIM1T sta WSYNC lda INTIM jsr DebugOut ; Test 3 ; ====== ; Time WSYNC in the active frame's 2nd zone sta WSYNC sta WSYNC sta WSYNC sta WSYNC sta WSYNC sta WSYNC sta WSYNC sta WSYNC sta WSYNC sta WSYNC sta WSYNC sta WSYNC sta WSYNC sta WSYNC sta WSYNC sta WSYNC; Zone is 16 pixels high lda #255 sta WSYNC sta TIM1T sta WSYNC lda INTIM jsr DebugOut rts WaitForVBlank: @L2: bit MSTAT bmi @L2 @L3: bit MSTAT bpl @L3 rts
The function DebugOut just displays the contents of the A,X and Y registers. You'll also notice a write to WSYNC before I load the timer. That was to ensure that the timer is loaded in the HBLANK porch.
With DMA off the results are as follows :-
Test 1 INTIM is 0x8E
Test 2 INTIM is 0x8E
Test 3 INTIM is 0x8E
With DMA on the results are as follows :-
Test 1 INTIM is 0x8E
Test 2 INTIM is 0x8E
Test 3 INTIM is 0x8E
So in all cases the total 1.79MHz clocks are :-
0xFF-0x8E=0x71
=113 x 1.79MHz cycles
In the MARIA docs it quotes 114 x 1.79MHz will occur during WSYNC. So from this I conclude that PHI2 is clocked during WSYNC and Sally is HALTed. It also doesn't matter if DMA is on or off. This makes sense because the POKEY enabled carts would sound pretty weird if PHI2 was stopped or altered dramatically during audio playback.
Hopefully more cycle accurate emulators will be in the pipeline now
Edited by GroovyBee, Mon Jun 8, 2009 8:15 AM.














