Odd - Interesting - Forgotten

Anything QL Software or Programming Related.
User avatar
bwinkel67
QL Wafer Drive
Posts: 1511
Joined: Thu Oct 03, 2019 2:09 am

Re: Odd - Interesting - Forgotten

Post by bwinkel67 »

Ok, that didn't quite work. I'd have to think about a better way of doing this. The color test isn't quite in the order I wanted. I just went white to black twice but that gives repeating patters instead of a gradient. Here's the simple BASIC program:

Code: Select all

5 REMark Dithvide lores color palette
10 k = 0: BORDER #1,4,255
15 FOR i=7 TO 0 STEP -1
20   FOR j=0 TO i
25      BLOCK #1,12,192,k,0,i
30      k = k + 12
35   NEXT j
40 NEXT i
45 SBYTES mdv1_loColorTest1_scr,131072,32768
50 k = 0: CLS #1
55 FOR i=7 TO 0 STEP -1
60   FOR j=i TO 0 STEP -1
65     BLOCK #1,12,192,k,0,j
70      k = k + 12
75   NEXT j
80 NEXT i
85 SBYTES mdv1_loColorTest2_scr,131072,32768
90 BORDER #1,0,0
Here are the two source images:

COLORl1.png
COLORl2.png

Here's the final combined image (approximate since done on Q-emuLator and then video captured):

DithvideLoresPalette.png

Here is the MDV to run it yourself on actual hardware.

COLORl.zip
(20.95 KiB) Downloaded 26 times


User avatar
bwinkel67
QL Wafer Drive
Posts: 1511
Joined: Thu Oct 03, 2019 2:09 am

Re: Odd - Interesting - Forgotten

Post by bwinkel67 »

Ok, finally got to try it on my 128K QL and it worked (reminder that I have an NTSC machine). Here are the two mixed-mode pictures. The image was solid, couldn't tell it was swapping images quickly. Note that this is a composite output hooked through a cheap upscaler (mini av2vga), so there is lots of interference (plus, my LCD tv/monitor makes red look more pinkish). I do have a SCART tv which gives a perfect picture and I'll try that next time.

RTYPEm_QL_JSU.jpg
DOOMm_QL_JSU.jpg

Everything worked as expected, except for my own creation, the lores color test screen. On my QL it behaved the same as on Q-emuLator, constantly flashing. I'm not quite sure why that would be the case. You have two mode 8 images and all I'd expect is a solid picture of 36 color bars. So why do the bars flash?

Here are the 6 MDV files that I used (well, 5 of them at least, since one is just the source code of Dithvide). I've modified it so that if you add them all as a collection in vDrive, you just run the boot program from one of the 5 and it'll ask you for a new device each time and you can then just go through each of the 5 images to see what they look like (i.e. the boot program only sets aside memory at the start and then loops asking for device and calling the machine code).

DITHVIDE.zip
(298.21 KiB) Downloaded 30 times

...and if you have vDrive, here is the entry you'd make in VDRIVEQL.CFG (assuming you have a TEMP folder that these files reside in). This could be either your entire configuration file, or you'd just add the [Hires] part and point the [SETUP] to it. Each image file ends in l, h, or m before the number, signifying which mode to use it in.

Code: Select all

[SETUP]
Hires

[Hires]
TEMP\DITHVIDE.MDV  ;
TEMP\DLAIRh.MDV    ;
TEMP\DOOMm.MDV     ;
TEMP\RTYPEl.MDV    ;
TEMP\RTYPEm.MDV    ;
TEMP\COLORl.MDV    ;


Derek_Stewart
Font of All Knowledge
Posts: 4653
Joined: Mon Dec 20, 2010 11:40 am
Location: Sunny Runcorn, Cheshire, UK

Re: Odd - Interesting - Forgotten

Post by Derek_Stewart »

All you need to do now is write a device driver to produce the screen output.


Regards,

Derek
omega
ROM Dongle
Posts: 19
Joined: Mon Jan 23, 2017 7:59 pm

Re: Odd - Interesting - Forgotten

Post by omega »

Hi everyone,

I'm the author of ql_dithvide, and I just wanted to share some thoughts after reading Mike’s incredible journey to get my messy code up and running. What a challenge! 😊 You truly have my respect, Mike. I’m seriously impressed by how you managed to figure everything out—great job!

You were absolutely right about the inconsistent coding style. I put it together quickly and in a rush. It was also my first attempt at mc68k coding, so there was a lot of learning on the fly. I had planned to do much more with it, but unfortunately, my QL broke during development. In the end, I decided to publish the work in progress since I couldn’t continue. One thing I was particularly proud of, though, was cracking the interrupt handler. It’s a key "enabler" for coding demo effects on the QL.

Regarding the comments about display modes and color depth, I completely agree—each mode has its own pros and cons. For example, even the hi-res mode is an upgrade to existing hi-res as it allows for greater color depth within the basic palette. The most saturated colors are in the low-res mode, while the mixed mode gives quite special images.

One thing that you might not have noticed about Mixed Mode is that every displayed line alternates between different display modes. What’s more, the order of the modes swaps with every interrupt. Here’s an example to illustrate:

Code: Select all

Loop:
interrupt odd
Mode 8              ; 1st line
Mode 4              ; 2nd line
Mode 8              ; 3rd line
Mode 4              ; 4th line
... until all 256 lines are shown

interrupt even
Mode 4              ; 1st line
Mode 8              ; 2nd line
Mode 4              ; 3rd line
Mode 8              ; 4th line
... until all 256 lines are shown

goto Loop
This approach is similar to the raster effects seen in ZX Spectrum demos, like Overscan from Busy, Shock Megademo, or Eklhaft2 https://www.youtube.com/watch?v=egJ7nIiv4ac (first part was made by me 😄, SID tune by Poke).

In Mixed Mode, the display mode changes at a precisely timed moment when the ULA begins pulling data from video memory for a specific line. Speaking of precise timing, there are two wait constants in the code that need to be adjusted for different QL setups. My setup was a BBQL with a Sandy Qboard (512k expansion). If I remember correctly, the upper 512k of expanded memory was “fast,” while the lower 128k (BBQL RAM) was “slow” due to the ULA accessing the memory.

Here are the constants:

bg_wait: This wait loop allows the beam to reach the first line of the monitor.
ln_wait: This wait loop lets the beam advance to the next line on the screen.

If you’re working with an unexpanded BBQL, you’ll likely need to reduce these constants since the code will run in contended memory, which slows things down. The slower the machine, the smaller these constants need to be.

Hope this helps clarify some of the code’s quirks! Thanks again, Mike, for all your hard work—it’s amazing to see this code being brought back to life.

Cheers, omega

PS: image conversion process is a bit tricky and requires several steps to get to the results. I am happy to convert some files for you.


omega
ROM Dongle
Posts: 19
Joined: Mon Jan 23, 2017 7:59 pm

Re: Odd - Interesting - Forgotten

Post by omega »

one more note... you probably figured out naming convention in the "latest" image package https://1ca7c9a646.cbaul-cdnwnd.com/c6d ... Screens.7z.
Each image has two files with the same name except of the last three characters:

AAn
-- AA = image mode: LR=low res, HR=high res.
-- n = screen: 1 lower, 2 upper

Display mode is then:
both LRs = low res dithvide
both HRs = hig res dithvide
LR and HR = mixed mode

In mixed mode you need to make sure to upload files in correct order to the memory (hires looks horrible in lores mode).

example of low res:
01_fighter_bomber.bmpLR1.raw
01_fighter_bomber.bmpLR2.raw


User avatar
bwinkel67
QL Wafer Drive
Posts: 1511
Joined: Thu Oct 03, 2019 2:09 am

Re: Odd - Interesting - Forgotten

Post by bwinkel67 »

omega wrote: Thu Jan 16, 2025 11:22 pm I'm the author of ql_dithvide, and I just wanted to share some thoughts after reading Mike’s incredible journey to get my messy code up and running. What a challenge! 😊 You truly have my respect, Mike. I’m seriously impressed by how you managed to figure everything out—great job!
Oh cool, I'm so glad you found your way to this thread. What a neat piece of software you created (back 15 years ago now, correct?) I came upon this from one of the comments on this thread, and am always fascinated with squeezing extra capabilities out of a machine solely in software, which shows what the QL was capable of, even back in 1984.

I can't take 100% credit for figuring this out, as without tofro's help I'd have been a bit lost. Once he figured out how to use the assembler I was off and running. Like you, my M68K assembly is pretty new, I'm more of a C/C++ programmer, although back in the 80s I did a lot of Z80 stuff, even wrote my own assembler https://www.youtube.com/watch?v=zR3F6vWAgiw as a kid.

Interestingly, in mixed mode, I had no issues running on my 128K QL once I trimmed the code down to use only 66K of memory, with 34K set aside via RESPR and the other 32K needing to be free of anything at $28000 for the second image. The image was solid, though some shimmering effects due to my crappy monitor setup: composite hooked to a mini av2vga upscaler adds a lot of noise. I had planned to add the ability to set those wait values via BASIC by figuring out the offsets from the "a" variable that holds the RESPR memory, to where bg_wait and ln_wait exist. That way I could just poke in different values and try them in BASIC...but I put that on the back burner since it worked so far on my system.

I'm in the US so our machines run at 60 Hz, so maybe that made a difference, but I do have parts of a second QL that I've not fully put together that would be on a UK clock. I'm not sure if anyone else on the forum has tried my examples on their BBQL...I've seen things downloaded but no comments of it not working. I will be doing a video on this on my YouTube channel (maybe for May) and will be using RGB output which should give a really nice picture.

The one question I have is why my own creation of the color test image flashed? I was in lores mode using two mode 8 images, where I was trying to get all 36 distinct color combinations, and the image was flashing on my QL. It's not mixed mode, so the timing values shouldn't be at issue. Unfortunately emulators can't replicate most of it, but if you try the lores one on Q-emuLator, which comes closest to working in lores, you can kind of see what I mean (i.e. COLORl.MDV).
omega wrote: Thu Jan 16, 2025 11:22 pm PS: image conversion process is a bit tricky and requires several steps to get to the results. I am happy to convert some files for you.
I'm very interested in figuring out how to do that. My wife used to be handy with Adobe Photoshop and we kind of theorized how one could create a palette and then somehow create two images from one, but that process sounds challenging. Again, above I tried to create my own, simple color test image and since that didn't work, I'm wondering if not all color combinations are allowed.

I also saw you had some Java code you wrote as a plugin for ImageJ that helped with conversions, and I had hoped to track that down. I can't imagine this process would have been easy to automate, given any image, so I would suspect the steps would be involved. Also, not sure if we have access to Photoshop (my wive may still have a version on an old laptop running XP), but I do use Paint.net, which tried to be an open source version.


User avatar
bwinkel67
QL Wafer Drive
Posts: 1511
Joined: Thu Oct 03, 2019 2:09 am

Re: Odd - Interesting - Forgotten

Post by bwinkel67 »

Btw, I should have searched this forum. Looks like tcat viewtopic.php?p=15951#p15951 had the same idea I did and created a similar shortened version of the code that works in 128K of memory back in 2017. No need for me to make the assembly more efficient since he shrunk it down to 312 bytes.

https://github.com/SinclairQL/dithVide/ ... /dvdrv_bin


Derek_Stewart
Font of All Knowledge
Posts: 4653
Joined: Mon Dec 20, 2010 11:40 am
Location: Sunny Runcorn, Cheshire, UK

Re: Odd - Interesting - Forgotten

Post by Derek_Stewart »

Can "dithvide" be used on faster QL systems with a Super/Gold Card attached?

Can the code be used without using the dedicated 2nd screen area?


Regards,

Derek
User avatar
tofro
Font of All Knowledge
Posts: 3057
Joined: Sun Feb 13, 2011 10:53 pm
Location: SW Germany

Re: Odd - Interesting - Forgotten

Post by tofro »

Derek_Stewart wrote: Fri Jan 17, 2025 10:42 am Can "dithvide" be used on faster QL systems with a Super/Gold Card attached?

Can the code be used without using the dedicated 2nd screen area?
1.) Yes, no problems with an S/GC

2.) Definitely not. Its core functionality is based on the ability of the QL ULA to switch between two screen areas quickly.


ʎɐqǝ ɯoɹɟ ǝq oʇ ƃuᴉoƃ ʇou sᴉ pɹɐoqʎǝʞ ʇxǝu ʎɯ 'ɹɐǝp ɥO
User avatar
bwinkel67
QL Wafer Drive
Posts: 1511
Joined: Thu Oct 03, 2019 2:09 am

Re: Odd - Interesting - Forgotten

Post by bwinkel67 »

Derek_Stewart wrote: Fri Jan 17, 2025 10:42 am Can "dithvide" be used on faster QL systems with a Super/Gold Card attached?
Give it a try. If you are unable to read MDV files I can create a zip file with the stuff on it. If you have access to Q-emuLator, you can use that to read the MDV files and copy them to your favorite medium.


Post Reply