Dithvide on expanded QL

Anything QL Software or Programming Related.
User avatar
tofro
QL Wafer Drive
Posts: 1668
Joined: Sun Feb 13, 2011 10:53 pm
Location: SW Germany

Dithvide on expanded QL

Postby tofro » Tue Dec 03, 2019 10:24 am

For my Magnetic Scrolls interpreter mentioned in this thread, I'm currently trying to implement a 27-color picture display using interlacing first and second screen - much like the method described by Omega here.

Up to now, the method works fine on an expanded QL with a Trump Card. It displays (reasonably) well on a "real" CRT, albeit with noticeable flickering (but that's just intrinsic to this method of display). LCD screens (and my SCART-to-HDMI converter) seem to "somewhat" work with that method, although some colors seem to be off. The best picture impression is on an old TV that has a SCART input and (even in "normal" modes) a very mushy picture.

My problem is: I don't seem to be able to make that method work reliably on a GC/SGC QL and I'm running out of possible fixes. I can't get a stable, synced picture, instead the picture is steady (and "allright") for about half a second, then the monitor (both LCD and TV) loses sync, starts rolling for some ms, then syncs again. This is obviously very annoying.

After thinking about the problem for a while, I came up with several possible reasons:

  • The SGC is simply too fast and switches screen memory pages while the picture is still displaying (instead of doing it in the backporch). With my limited knowledge of display technology, I find that extremely improbable. Experimental delay loops inserted in the ISR change the behavior (and the amount of re-syncing), but still don't achieve a stable picture.
  • The SGC does not run in sync with the QL's video. On an unexpanded QL, the CPU is halted when the video circuitry is displaying the picture. The SGC that has shadow video memory doesn't need to do that - I have thus inserted a screen memory write to the ISR (I guess the SGC CPU needs to wait in this case until the display memory is completely read by the video circuitry, and thus I could achieve sync) - This improved the situation greatly, but still does not result in a completely stable picture.
  • The polling interrupt on the SGC is simply not running with reliable timing - Not very probable, but possible. No way to fix this if this should be the case
  • My main loop that displays the picture waits for IPC keypresses in a loop - Could it be the IPC comms on the SGC is simply too slow (rather than too fast) or disables interrupts for too long that the picture cannot sync any more?

Anyways, I'm stuck for the moment. Would be nice if someone has solved (or even encountered) this problem. Would be even nicer if someone had a solution to it.

Tobias.


ʎɐqǝ ɯoɹɟ ǝq oʇ ƃuᴉoƃ ʇou sᴉ pɹɐoqʎǝʞ ʇxǝu ʎɯ 'ɹɐǝp ɥO
User avatar
tofro
QL Wafer Drive
Posts: 1668
Joined: Sun Feb 13, 2011 10:53 pm
Location: SW Germany

Re: Dithvide on expanded QL

Postby tofro » Sat Dec 07, 2019 10:30 pm

I have solved the problem now. Both the random crashes and most of the flickering is gone now.

Instead of using the method of Dithvide (hooking the screen flip routine to the polling interrupt and waiting for a keypress outside) that I couldn't for the life of me get to run on SMSQ/E - albeit that seems to work fine in plain QDOS, I changed to a brute-force approach:

A tight loop that direcly polls the frame interrupt flag of the 8301 and also checks for keypresses seems to work perfecly. No interrupts involved at all any more.

Works.

Tobias


ʎɐqǝ ɯoɹɟ ǝq oʇ ƃuᴉoƃ ʇou sᴉ pɹɐoqʎǝʞ ʇxǝu ʎɯ 'ɹɐǝp ɥO
User avatar
Peter
Aurora
Posts: 918
Joined: Sat Jan 22, 2011 8:47 am

Re: Dithvide on expanded QL

Postby Peter » Sat Dec 07, 2019 10:50 pm

tofro wrote:A tight loop that direcly polls the frame interrupt flag of the 8301 and also checks for keypresses seems to work perfecly.

And the polling runs in a job?

tofro wrote:No interrupts involved at all any more.

Did you disable them? Otherwise at least the frame interrupt would still be active and potentially lead to job-switching.


User avatar
tofro
QL Wafer Drive
Posts: 1668
Joined: Sun Feb 13, 2011 10:53 pm
Location: SW Germany

Re: Dithvide on expanded QL

Postby tofro » Sun Dec 08, 2019 12:07 am

Peter wrote:
tofro wrote:A tight loop that direcly polls the frame interrupt flag of the 8301 and also checks for keypresses seems to work perfecly.

And the polling runs in a job?

Yes.
SV mode, Interrupts disabled, system variables moved away to free up the second screen, then a tight loop that busy-waits on both the frame interrupt flag in the interrupt register and frequently polls the IPC for keypresses. Once a key is pressed, evrything is brought back in place, interrupts are enabled and back to user mode. The job (and multitasking) continues just fine from there.

tofro wrote:No interrupts involved at all any more.

Did you disable them? Otherwise at least the frame interrupt would still be active and potentially lead to job-switching.[/quote]

Yes. When I used the polling interrupt list (and interrupts enabled to make the system use it) that worked just as well, but only for a few minutes - I'm assuming IPC comms gets garbled with some sort of random race. My ISR still ran fine (and the system didn't crash) as screens were still flipped at 50Hz, but the keyboard became unresponsive.

When in Supervisor Mode and when not calling non-atomic system calls, actually no task switch should occur, even with interrupts enabled.

On the BBQL with QDOS, this latter method apparently works much better - It seems to be SMSQ/E that doesn't like to be messed with ;)

Tobias


ʎɐqǝ ɯoɹɟ ǝq oʇ ƃuᴉoƃ ʇou sᴉ pɹɐoqʎǝʞ ʇxǝu ʎɯ 'ɹɐǝp ɥO
User avatar
QLvsJAGUAR
Gold Card
Posts: 326
Joined: Tue Feb 15, 2011 8:42 am
Location: Lucerne, Switzerland
Contact:

Re: Dithvide on expanded QL

Postby QLvsJAGUAR » Sun Dec 08, 2019 10:03 am

To try Omega's Dithvide on my BBQLs was still on my to-do list. Great to see that some other QLer took it up and even went deeper into the topic. Tobias, it would be great if in the very end* - maybe after your Magnetic Scrolls project(s) - you could release your rework for us to try and use. Great would be the possibility to use it even with non Assembler programming, a set of S*BASIC commands like DV_MODE, DV_ENABLE... for interpreted/compiled BASIC would rock the party.

* any preview, sample, demo to try is highly welcomed.

Keep on going your great QL work, Tobias.


http://www.sinclairql.net/ - Go and get THE DISTRIBUTION & QL/E!
http://www.youtube.com/QLvsJAGUAR
Sinclair, QL, ATARI, JAGUAR, NUON, APPLE & more
Videos, pictures & information

Who is online

Users browsing this forum: No registered users and 4 guests