QSound and Assembly

Anything QL Software or Programming Related.
Post Reply
spkr
Brittle Membrane
Posts: 110
Joined: Tue May 04, 2021 6:52 pm

QSound and Assembly

Post by spkr »

Hi there,

I recently obtained a QSound device, and now that I cobbled together a working oqtadrive, I *should* be able to get my own programs running on the QL using the QSound! However, currently that is not yet the case.

I was wondering if anyone went this way, or got some suggestions for me to try out. So far I tried to play one of the predetermined sounds:

Following https://dilwyn.theqlforum.com/docs/manua ... QPRINT.pdf :

Code: Select all

    moveq    #0,d0                  
    trap    #1                        ; MT INF
    move.l    $164(a0),d0                ; get $164 offsert from system vars, which is the AY.JMP (page 9)
    move.l    d0,a0                    ; use AY.JMP as address

    moveq    #9,d0                    ; play predefined noise (page 19)
    moveq    #1,d1                    ; play predefied noise (gunshot)
    jsr        (a0)                    ; jump into the thing (similar to page 8)
However this not yet yield sound. (I Confirmed the QSound working by using the basic command, which works).

Later today I will try and push raw data to the registers using the AY.WRALL; but Ideally Id like a really minimal example as a proof of concept that I can make the QSound make sound from assemble.

Any input is greatly appreciated; I hope to get some music going for my upcoming Sinclair QL intro :)

Kind regards,
Wietze


spkr
Brittle Membrane
Posts: 110
Joined: Tue May 04, 2021 6:52 pm

Re: QSound and Assembly

Post by spkr »

Quick followup; it seemed that setting individual AY regs using trap calls did work.

So I used this and that worked like a charm.

Kind regards,
Wietze


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

Re: QSound and Assembly

Post by Derek_Stewart »

Hi Wietze,

Truely excellent, I have been struggling with this for a long time.

I will have a play with the Qsound boards I have like writing in assembley language.
Last edited by Derek_Stewart on Tue Jan 23, 2024 7:29 pm, edited 1 time in total.


Regards,

Derek
spkr
Brittle Membrane
Posts: 110
Joined: Tue May 04, 2021 6:52 pm

Re: QSound and Assembly

Post by spkr »

Hi guys,

I've released a little prod using the qsound. It can be found here: https://www.pouet.net/prod.php?which=95891

It also contains a YouTube link in case you do not own a qsound.

Kind regards
Wietze


napsternds
Bent Pin Expansion Port
Posts: 95
Joined: Tue Jan 26, 2021 11:04 am

Re: QSound and Assembly

Post by napsternds »

spkr wrote: Tue Jan 23, 2024 4:33 pm I've released a little prod using the qsound. It can be found here: https://www.pouet.net/prod.php?which=95891
Great Job. What you achieve with a QL is amazing!


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

Re: QSound and Assembly

Post by M68008 »

Great demo!


thorsinclair
Trump Card
Posts: 209
Joined: Mon Jan 10, 2011 5:08 pm

Re: QSound and Assembly

Post by thorsinclair »

Congrats, looking and sounding great! Getting better and better!


User avatar
Chain-Q
Chuggy Microdrive
Posts: 69
Joined: Mon Nov 16, 2020 1:10 pm
Location: Berlin, DE, EU
Contact:

Re: QSound and Assembly

Post by Chain-Q »

Soooo... Allegedly I also got a QSound now (thanks to spkr, and whoever his contact is, who makes these cards), and also allegedly, I've been writing a small unit to make a QSound easy to use from Free Pascal. :) And I ran into exactly the same issue as the opening post in this thread, but after pulling my hair out for two days, I found the cause:

The current QSound firmware (my card has 1.94) is prepared to handle multi-chip/stereo cards. And this means, several functions now expect also the Chip ID (0 or 1) to be passed in register D2. Also at places where this is not documented, or wrongly documented. For example for function AY.WRALL it's documented that the Chip ID must be in register D1. However, in reality it must be in register D2. (Source: ... well, the source of the ROM, which also contains incorrect docs :) found in this post) This in turn leads us to why the code in the thread opening post doesn't work: it doesn't fill out D2, so most likely it gets a result of error -15 (Bad Parameter) in D0. This is because AY.NOISE just calls AY.WRALL internally, after setting up some things... Which expects a Chip ID, but just gets random() register contents in D2 instead.

Sadly, this also means the ABI of the current ROM is broken/changed, compared to the original QSound ROM, at least as far as it is documented - btw, the original ROM doc PDF also has several problems/inaccuracies -, because if the caller code doesn't set up D2 properly, you'll get errors, and no sound...

So, back to the opening post. This version of the code works:

Code: Select all

    moveq    #0,d0                  
    trap    #1                        ; MT INF
    move.l    $164(a0),d0                ; get $164 offsert from system vars, which is the AY.JMP (page 9)
    move.l    d0,a0                    ; use AY.JMP as address

    moveq    #9,d0                    ; play predefined noise (page 19)
    moveq    #1,d1                    ; play predefied noise (gunshot)
    moveq    #0,d2                    ; set Chip ID to 0/1 even if it's undocumented, only 0 works on single-chip cards! - THIS LINE IS THE FIX
    jsr        (a0)                    ; jump into the thing (similar to page 8)
Tested on my QL + QSound, real HW, and as I wrote, ROM 1.94.

It would be cool for mk79 to chime in, and tell us his take. I wonder if there would be a way to fix the ROM and the ABI, so this pass-on-the-chip-ID won't be a hard requirement any more... But I don't know the history of the QSound, maybe it's not a big deal at all, because existing software works anyway. I don't know.


Post Reply