Sinclair QL (cross) development and emulation questions

Anything QL Software or Programming Related.
spkr
Bent Pin Expansion Port
Posts: 98
Joined: Tue May 04, 2021 6:52 pm

Re: Sinclair QL (cross) development and emulation questions

Post by spkr »

M68008 wrote:
spkr wrote:
M68008 wrote:
The Windows version of Q-emuLator has a built-in debugger (disclaimer: I'm the author). It's very crude, but can be useful as it's non-intrusive.
This is wonderful! Thanks so much. Im curious as to why this feature did not make it into the OSX version; would you care to elaborate?

<edit> I suppose it has to do with the debugging capabilities being provided be a windows specific other party dependency
The debugger is a separate component I wrote as a Windows DLL and the UI uses Win32 API calls. It didn't seem worth porting it as I don't know of anybody other than me using it.
Understood. I can just as easily use the windows version under wine, no problem!


User avatar
M68008
Trump Card
Posts: 223
Joined: Sat Jan 29, 2011 1:55 am
Contact:

Re: Sinclair QL (cross) development and emulation questions

Post by M68008 »

spkr wrote:Some newbie question;

Im writing 128 bytes to screen locations in a loop, which is throttled by vsync (effectively, assumingly writing 1 row of pixels every vsync). Vsync is done as described at https://www.chibiakumas.com/68000/sinclairql.php

I _assume_ that vsync occurs at 50hz, and I would thus assume that the screen is filled in 5-odd seconds.

When testing my code on Q-emulator, it takes considerably longer.

Would anyone have an idea what the cause of this could be?
Yes, 50 Hz. If you can share the code or PM me, I can take a quick look.
[Update: I see you have already solved this issue, good]


spkr
Bent Pin Expansion Port
Posts: 98
Joined: Tue May 04, 2021 6:52 pm

Re: Sinclair QL (cross) development and emulation questions

Post by spkr »

M68008 wrote:
spkr wrote:Some newbie question;

Im writing 128 bytes to screen locations in a loop, which is throttled by vsync (effectively, assumingly writing 1 row of pixels every vsync). Vsync is done as described at https://www.chibiakumas.com/68000/sinclairql.php

I _assume_ that vsync occurs at 50hz, and I would thus assume that the screen is filled in 5-odd seconds.

When testing my code on Q-emulator, it takes considerably longer.

Would anyone have an idea what the cause of this could be?
Yes, 50 Hz. If you can share the code or PM me, I can take a quick look.
Ah sorry, I think I solved it. My code was lacking the 2 things that are documented to be important:
- Supervisor mode
- Turn off all interrupts

This makes me wonder tho, does the Sinclair QL have any programmable interrupts and or programmable interval timers, possibly not; Ill have to check.


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

Re: Sinclair QL (cross) development and emulation questions

Post by tofro »

spkr wrote: This makes me wonder tho, does the Sinclair QL have any programmable interrupts and or programmable interval timers, possibly not; Ill have to check.
Other than the 50Hz interrupt, no. The real time clock ticks independently from that in 1s intervals, but that might be a little bit slow for your purposes ;)


ʎɐqǝ ɯoɹɟ ǝq oʇ ƃuᴉoƃ ʇou sᴉ pɹɐoqʎǝʞ ʇxǝu ʎɯ 'ɹɐǝp ɥO
spkr
Bent Pin Expansion Port
Posts: 98
Joined: Tue May 04, 2021 6:52 pm

Re: Sinclair QL (cross) development and emulation questions

Post by spkr »

tofro wrote:
spkr wrote: This makes me wonder tho, does the Sinclair QL have any programmable interrupts and or programmable interval timers, possibly not; Ill have to check.
Other than the 50Hz interrupt, no. The real time clock ticks independently from that in 1s intervals, but that might be a little bit slow for your purposes ;)
Hi! I assume that the Vsync interrupt isnt programmable, but only observable. I have a few broad questions with regards to the cpu and the vsync behaviour:

Is it known how many cycles there are per vblank? I would guess around 150240, but I wonder if there is an exact number.
When the screen address bit is set though altering bit 7 of $18063 when is this effectuated? I wonder if its immediate, or if its at some fixed time or not.
Does the system allow for NTSC ouput? (Switching to 60hz vblank) or is it fixed at 50hz. I assume not, but doesnt hurt to ask.
How does the 8 bit data bus to the CPU compare to the more common 68000 databus. Cycletables for the 68000 cpu are known, Im wondering how much is known about the 68008.
Lastly, what are common practices to measure CPU time, is there a reliable way to count vblanks to measure execution of code, or is the interrupt behaviour limited to be observable alone?

Kind regards!


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

Re: Sinclair QL (cross) development and emulation questions

Post by tofro »

spkr wrote:
Hi! I assume that the Vsync interrupt isnt programmable, but only observable. I have a few broad questions with regards to the cpu and the vsync behaviour:
That assumption is correct.
spkr wrote: Is it known how many cycles there are per vblank? I would guess around 150240, but I wonder if there is an exact number.
I don't think anyone has bothered to measure yet.
spkr wrote: When the screen address bit is set though altering bit 7 of $18063 when is this effectuated? I wonder if its immediate, or if its at some fixed time or not.
The change seems to be immediate, like any change you do to the video register.
spkr wrote: Does the system allow for NTSC ouput? (Switching to 60hz vblank) or is it fixed at 50hz. I assume not, but doesnt hurt to ask.
This seems to be dependant on the ULA version: Apparently, there is a version produced for the US market that ended up in all Samsung-made QLs(?), and has an additional, non-documented bit (6) in the video register that will switch from 50 to 60Hz mode.
spkr wrote: How does the 8 bit data bus to the CPU compare to the more common 68000 databus. Cycletables for the 68000 cpu are known, Im wondering how much is known about the 68008.
Well, it's half the width ;)

If you have a look into the Motorola 68008 manuals, the information is all there. Note that the QL's own ROM frequently makes use of timed tight loops to achieve sub-timer-resolution delays, especially in the network and microdrive code.
spkr wrote: Lastly, what are common practices to measure CPU time, is there a reliable way to count vblanks to measure execution of code, or is the interrupt behaviour limited to be observable alone?
If you're referring to visual "load indications" like flipping the border colour in the vblank like the ZX Spectrum guys do - No, there is no such easy method.

When I'm really interested in cycle counts, I drop my code into the Easy68000 68k simulator and see what it counts there. (That hands you back 68000 cycle counts, though, and is not guaranteed to be accurate)


ʎɐqǝ ɯoɹɟ ǝq oʇ ƃuᴉoƃ ʇou sᴉ pɹɐoqʎǝʞ ʇxǝu ʎɯ 'ɹɐǝp ɥO
spkr
Bent Pin Expansion Port
Posts: 98
Joined: Tue May 04, 2021 6:52 pm

Re: Sinclair QL (cross) development and emulation questions

Post by spkr »

Once more, thank you so much for your answers!

The m68k instruction cycles I kinda know by heart by now, but Im sure the m68k8 is different because of the opcodes are read less fast.

If the changes written to the video register are immediate, this would imply that mixed video modes are possible? Like part of the screen using a 512 width and parts of the screen 256 width, assuming one can get the code to execute cycle exact. This is interesting to figure out!

Also, this trick, to some extend can be used to measure the cpu time, as long as the executed code and the video register flip is within the drawable area. The Atari st output counts 313 scanlines internally. Is it known how many scanlines are generated by the QL in total?

Regards!


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

Re: Sinclair QL (cross) development and emulation questions

Post by tofro »

spkr wrote: If the changes written to the video register are immediate, this would imply that mixed video modes are possible? Like part of the screen using a 512 width and parts of the screen 256 width, assuming one can get the code to execute cycle exact. This is interesting to figure out!
You might want to have a look here (not my page)


ʎɐqǝ ɯoɹɟ ǝq oʇ ƃuᴉoƃ ʇou sᴉ pɹɐoqʎǝʞ ʇxǝu ʎɯ 'ɹɐǝp ɥO
spkr
Bent Pin Expansion Port
Posts: 98
Joined: Tue May 04, 2021 6:52 pm

Re: Sinclair QL (cross) development and emulation questions

Post by spkr »

Awesome! Yes, very nice!

I wonder if the emulators support this as well, I will try as soon as I get the chance.


FrancoisLanciault
Trump Card
Posts: 167
Joined: Mon Aug 08, 2011 11:08 pm

Re: Sinclair QL (cross) development and emulation questions

Post by FrancoisLanciault »

tofro wrote:
spkr wrote: If the changes written to the video register are immediate, this would imply that mixed video modes are possible? Like part of the screen using a 512 width and parts of the screen 256 width, assuming one can get the code to execute cycle exact. This is interesting to figure out!
You might want to have a look here (not my page)
I also did my own implementation of a high color image viewer using this technic about 24 years ago. I can send you the source code if you wish. I have two versions, one that smash the system variables to use the second screen and thus would work in supervisor mode only, the other, when use with Minerva, would work without destroying everything and would exit gracefully.


Post Reply