Sync-tricks/fullscreen discussion

GFA, ASM, STOS, ...

Moderators: exxos, simonsunnyboy, Mug UK, Zorro 2, Moderator Team

User avatar
troed
Atari God
Atari God
Posts: 1179
Joined: Mon Apr 30, 2012 6:20 pm
Location: Sweden

Re: Sync-tricks/fullscreen discussion

Postby troed » Tue Apr 12, 2016 9:33 am

larsbrinkhoff wrote:
troed wrote:I've spent some time with the GLUE statemachine for ST/STE not only in 50Hz but also 60Hz (and 71Hz, but I still need to wrap my head around a few things there).


Thanks, I think that's a good improvement.

Regarding 71... is there a LINE = 224 too?


I'm unsure what it is that happens at cycle 28/30 on a low res line (I think but haven't tested that it's the same position for 50/60Hz). I'm equally unsure what it is that happens at cycle 108 on a high res line. I'm currently testing with a flat screen monitor that's very quick to go out of sync at the slightest of sync disturbances and I might need to hook up something analog instead.

So, 28/30 and 108 are unexplained things, which might or might not be relevant to have an opinion on where LINE = 224 happens. It might be cycle 54/56, I simply don't know yet. It would probably be extremely easy to use a logic analyzer to find out, I just don't have one :)

/Troed

User avatar
npomarede
Atari God
Atari God
Posts: 1128
Joined: Sat Dec 01, 2007 7:38 pm
Location: France

Re: Sync-tricks/fullscreen discussion

Postby npomarede » Tue Apr 12, 2016 9:43 am

troed wrote:So, 28/30 and 108 are unexplained things, which might or might not be relevant to have an opinion on where LINE = 224 happens. It might be cycle 54/56, I simply don't know yet. It would probably be extremely easy to use a logic analyzer to find out, I just don't have one :)
/Troed

Or maybe Ijor could get some details from the decaped glue chip ? But I don't know if it's easy to study some precise time spots using the chip's picture.

ijor
Hardware Guru
Hardware Guru
Posts: 3022
Joined: Sat May 29, 2004 7:52 pm
Contact:

Re: Sync-tricks/fullscreen discussion

Postby ijor » Tue Apr 12, 2016 9:39 pm

I know more or less what is going on. Main problem is that is difficult, at least for me, to express this with a single monolithic state machine. I'm not sure it would even be correct and accurate to do so.

As I already mentioned, GLUE doesn't have just a single horizontal counter but two. One counter controls hsync and line length. The other counter controls hDE and hBLANK. Each counter runs in opposite edges of the 2 MHz clock. That's why sync and length switches are aligned in a different 4 cycles boundary, in relation to hDE and hBLANK ones.

Line length is decided by setting the initial counter value, depending on the frecuency, when it overwraps. That's why it looks like there is some kind of register.

Between 50 Hz and 60 Hz is simple. GLUE uses exactly the same value to decide when to start and when to end hsync in both frequencies (remember that they don't start counting at the same value, that's the trick). But between mono and color is more complicated. In other words, the hsync comparators check only the rez register (mono or color).

I'll try to write some seudo code of the hsync logic alone later.

ijor
Hardware Guru
Hardware Guru
Posts: 3022
Joined: Sat May 29, 2004 7:52 pm
Contact:

Re: Sync-tricks/fullscreen discussion

Postby ijor » Wed Apr 13, 2016 4:26 am

Ok. This is GLUE horizontal sync video seudo code.Integrating this as a single monolithic state machine is left as an exercise to the reader. :)

Don't pay too much attention to the absolute value of the counter. Obviously they don't match the positions we used historically just by convention. What matters is the relation. Also remember the counters run at 2 MHz, so you have to multiply by four to convert it to 8 MHz cycles.

Code: Select all

// Divide 8 Mhz clock into 2 MHz
// Two opposite edges, two (8 Mhz) cycles apart
CLOCK_DIVISOR_2MHZ = 0
DO
   IF CLK_8MHZ_TICK
      IF CLOCK_DIVISOR_2MHZ == 0  THEN HS_TICK = TRUE
      ELSE HS_TICK = FALSE

      IF CLOCK_DIVISOR_2MHZ == 2  THEN HV_TICK = TRUE
      ELSE HV_TICK = FALSE

      IF CLOCK_DIVISOR_2MHZ == 3 THEN
         CLOCK_DIVISOR_2MHZ = 0
      ELSE
         CLOCK_DIVISOR_2MHZ++   
   ENDIF
LOOP

// Horizontal sync process
HSYNC_COUNTER = 0
DO
   IF HS_TICK
      IF HSYNC_COUNTER == 101 && REZ[1] == 0 THEN HSYNC = TRUE
      IF HSYNC_COUNTER == 111 && REZ[1] == 0 THEN HSYNC = FALSE
      IF HSYNC_COUNTER == 121 && REZ[1] == 1 THEN HSYNC = TRUE
      IF HSYNC_COUNTER == 127 && REZ[1] == 1 THEN HSYNC = FALSE

      IF HSYNC_COUNTER == 127
         IF REZ[1] == 1 THEN          HSYNC_COUNTER = 72
         ELSEIF FREQ[1] == 0 THEN     HSYNC_COUNTER = 1
         ELSE                         HSYNC_COUNTER = 0
      ELSE
         HSYNC_COUNTER++
      ENDIF
   ENDIF
LOOP

// Horizontal video process
HVID_COUNTER = 0
DO
   IF HSYNC THEN HVID_COUNTER = 0
   ELSE IF HV_TICK
      // hDE and hBLANK COMPARATORS here
      HVID_COUNTER++
   ENDIF
LOOP


User avatar
troed
Atari God
Atari God
Posts: 1179
Joined: Mon Apr 30, 2012 6:20 pm
Location: Sweden

Re: Sync-tricks/fullscreen discussion

Postby troed » Wed Apr 13, 2016 7:42 am

"28/30" is "108"* :) Thanks Ijor!!! I can't express enough how satisfying it is to have a hypothesis based on black box reverse engineering and then to be able to have it verified instead of just sitting on it for many years without ever knowing! This is from my notes after the latest batch of testing:

Q: Why isn’t there something similar to cycle 460 for 71Hz? Is its HSYNC handling so different? Also, no BLANK = FALSE for mono.
- or is this what ~cycle 30 is about?
- hmm, rather cycle 108 according to tests in mono!


(And for the ones keeping track: This means Paulo's "14 byte line" with the associated "strange logic analyzer diagram" by Dio is indeed due to triggering a new hsync in the middle of the left border in low res .. )

I'll get it into the state machine shortly. Indeed I created the "LINE" variable knowing full well that its purpose was to capture what you had already described as being two counters, not one. Whatever makes for the easiest explanation - I think linking to your exact description of how the hw works will be mandatory later ... ;)

/Troed

edit: The answer to "Don't pay too much attention to the absolute value of the counter. Obviously they don't match the positions we used historically just by convention" is that cycle 54 (ST) by our convention is where the hsync counter is reset.

*) Reading that again it made no sense ;) Cycle 30 (ST) in low res is the high res HSYNC position. Cycle 108 in high res is the low res HSYNC position. I'm not sure the state machine description will survive incorporating this. The easiest description of the behavior might be something like Ijor's pseudo-code. Let's see.

ijor
Hardware Guru
Hardware Guru
Posts: 3022
Joined: Sat May 29, 2004 7:52 pm
Contact:

Re: Sync-tricks/fullscreen discussion

Postby ijor » Fri Apr 15, 2016 2:46 pm

Minor update to the hsync seudo code

Code: Select all

// Divide 8 Mhz clock into 2 MHz
// Two opposite edges, two (8 Mhz) cycles apart
CLOCK_DIVISOR_2MHZ = 0
DO
   IF CLK_8MHZ_TICK
      IF CLOCK_DIVISOR_2MHZ == 0  THEN HS_TICK = TRUE
      ELSE HS_TICK = FALSE

      IF CLOCK_DIVISOR_2MHZ == 2  THEN HV_TICK = TRUE
      ELSE HV_TICK = FALSE

      IF CLOCK_DIVISOR_2MHZ == 3 THEN
         CLOCK_DIVISOR_2MHZ = 0
      ELSE
         CLOCK_DIVISOR_2MHZ++   
   ENDIF
LOOP

// Horizontal sync process
HSYNC_COUNTER = 0
DO
   IF HS_TICK
      IF HSYNC_COUNTER == 101 && REZ[1] == 0 THEN HSYNC = TRUE
      IF HSYNC_COUNTER == 111 && REZ[1] == 0 THEN HSYNC = FALSE
      IF HSYNC_COUNTER == 121 && REZ[1] == 1 THEN HSYNC = TRUE
      IF HSYNC_COUNTER == 127 && REZ[1] == 1 THEN HSYNC = FALSE

      IF HSYNC_COUNTER == 127
         IF REZ[1] == 1 THEN          HSYNC_COUNTER = 72
         ELSEIF FREQ[1] == 0 THEN     HSYNC_COUNTER = 1
         ELSE                         HSYNC_COUNTER = 0
      ELSE
         HSYNC_COUNTER++
      ENDIF
   ENDIF
LOOP

// SYNC MUX
IF FREQ[0] THEN      HSYNC_MUX = EXTERNAL_HSYNC
ELSE             HSYNC_MUX = INTERNAL_HSYNC

// Horizontal video process
HVID_COUNTER = 0
DO
   IF HSYNC_MUX THEN
   // These resets happen asynchronously,
   // disregarding any clock.
   // And have higher priority than synchronous changes
      HVID_COUNTER = 0
      hDE = FALSE
      hBLANK = TRUE
   ELSE IF HV_TICK
      // hDE and hBLANK COMPARATORS here
      HVID_COUNTER++
   ENDIF
LOOP


User avatar
npomarede
Atari God
Atari God
Posts: 1128
Joined: Sat Dec 01, 2007 7:38 pm
Location: France

Re: Sync-tricks/fullscreen discussion

Postby npomarede » Fri Apr 15, 2016 5:31 pm

Hi
regarding the hi/lo switch in "no buddies land" at pos 500/508, we know it creates a blank line but also shift the display 1 line down (so bottom border would start at hbl 264 instead of 263). If 10 lines are used at 500/508, display will ends 10 lines later, which I suspected when emulating this in Hatari was due to a counter not incrementing.
From you pseudo code above, I guess it's this part that doesn't get executed in that case ?

Code: Select all

ELSE IF HV_TICK
      // hDE and hBLANK COMPARATORS here
      HVID_COUNTER++
   ENDIF


Nicolas

ijor
Hardware Guru
Hardware Guru
Posts: 3022
Joined: Sat May 29, 2004 7:52 pm
Contact:

Re: Sync-tricks/fullscreen discussion

Postby ijor » Fri Apr 15, 2016 9:27 pm

npomarede wrote:Hi
regarding the hi/lo switch in "no buddies land" at pos 500/508, we know it creates a blank line but also shift the display 1 line down (so bottom border would start at hbl 264 instead of 263). If 10 lines are used at 500/508, display will ends 10 lines later, which I suspected when emulating this in Hatari was due to a counter not incrementing.
From you pseudo code above, I guess it's this part that doesn't get executed in that case ?

Code: Select all

ELSE IF HV_TICK
      // hDE and hBLANK COMPARATORS here
      HVID_COUNTER++
   ENDIF


Nicolas


Not exactly. That counter is only for the horizontal hDE and hBLANK processing. Probably the name I used is a bit misleading. I was thinking in HorizontalVideo (in comparison to the other counter as HorizontalSync).

The effect you mention comes from the vertical process, which I didn't include at all in the seudo code, so far. One of the counters (there are also two vertical counters), the one that controls the borders, is incremented on every HSYNC edge. In the case of No Buddies Land, there are no HSYNC edges on those lines, so that vertical counter is not incremented.

User avatar
troed
Atari God
Atari God
Posts: 1179
Joined: Mon Apr 30, 2012 6:20 pm
Location: Sweden

Re: Sync-tricks/fullscreen discussion

Postby troed » Fri Nov 04, 2016 4:32 pm

Of interest to people participating here should be that the Hatari emulator, v2.0.0 released today, now supports emulating all four GLUE-MMU wakestates :) This is selectable (or use "random" for extra fun when developing - like the real hardware) so that you now can verify the TCB snow screen in SNYD1 behaving differently in WS2 compared to the others etc.

- video emulation now supports the 4 STF wakeup states for MMU/GLUE
and a much more accurate state machine for border removal


Many thanks to Nicolas having taken the time to rewrite the internals to allow this to happen.

http://hatari.tuxfamily.org/download.html

/Troed


Social Media

     

Return to “Coding”

Who is online

Users browsing this forum: No registered users and 1 guest