News:

Printed Amstrad Addict magazine announced, check it out here!

Main Menu

how can we play sound in assembly using i/o ports only?

Started by nitrofurano, 12:31, 25 March 16

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

nitrofurano

hi!
i'm trying to play sound on cpc in assembly using i/o ports only, and getting no success at all... :S


i tried:




    ld bc,$f782
    out (c),c
    ld bc,$f407
    out (c),c
    ld bc,$f638
    out (c),c
    ld bc,$f400
    out (c),c
    ld bc,$f6FE
    out (c),c
    ld bc,$f408
    out (c),c
    ld bc,$f60F
    out (c),c



and




    ld b,$F4
    out (c),c
    ld bc,$F607
    out (c),c
    ld bc,$F600
    out (c),c
    ld b,$F4
    out (c),c
    ld bc,$F638
    out (c),c
    ld bc,$F600
    out (c),c
    ld b,$F4
    out (c),c
    ld bc,$F600
    out (c),c
    ld bc,$F600
    out (c),c
    ld b,$F4
    out (c),c
    ld bc,$F6FE
    out (c),c
    ld bc,$F600
    out (c),c
    ld b,$F4
    out (c),c
    ld bc,$F608
    out (c),c
    ld bc,$F600
    out (c),c
    ld b,$F4
    out (c),c
    ld bc,$F60F
    out (c),c
    ld bc,$F600
    out (c),c


any idea? and thanks in advance!

(btw, please don't suggest me to use firmware routines, sound queues, etc. - i really just want to use i/o ports directly only - i'm all focused on multitargeting/multiplatform development (trying to cover all z80-based machines that uses ay-3-891x), since if i could access ay-3-891x directly on ZX-Spectrum and MSX, it seems totally nonsense for me if i couldn't do the same on CPC )



arnoldemu


    ld bc,$F407 ;;<< register
    out (c),c
ld bc,&f6c0 ;;<<<<<< select register
out (c),c ;; <<<<<<<
    ld bc,$F600
    out (c),c ;; << back to inactive
    ld bc,$F438 ;; << data
    out (c),c
ld bc,&f680 ;; << write data to register
out (c),c
    ld bc,$F600
    out (c),c


Note the F6c0, f680 for select register and write register. Data goes to f4 not f6.
My games. My Games
My website with coding examples: Unofficial Amstrad WWW Resource

arnoldemu

Quote from: arnoldemu on 13:17, 25 March 16

    ld bc,$F407 ;;<< register
    out (c),c
ld bc,&f6c0 ;;<<<<<< select register
out (c),c ;; <<<<<<<
    ld bc,$F600
    out (c),c ;; << back to inactive
    ld bc,$F438 ;; << data
    out (c),c
ld bc,&f680 ;; << write data to register
out (c),c
    ld bc,$F600
    out (c),c


Note the F6c0, f680 for select register and write register. Data goes to f4 not f6.

This writes 38 to register 07. Repeat the same pattern for all registers you want to write.
My games. My Games
My website with coding examples: Unofficial Amstrad WWW Resource

nitrofurano


arnoldemu

My games. My Games
My website with coding examples: Unofficial Amstrad WWW Resource

nitrofurano

thanks! and here is the bonus on the feedback, my very humble code made on ZX-Basic Compiler seems to play embedded .vgm files (almost) fine! :) (the bug is from my side, that i couldn't figure out exactly what is happening, might be something getting misinterpreted from the code i made) - the idea is to, later, convert files from VortexTracker into something similar to .vgm (perhaps a more optimized file, since .vgm is usually relatively huge because redundant data), and play there in similar way (humbly saying, might be quite useful for game development, at least for me! :) )

nitrofurano

btw, it's interesting that ay-3-891x runs in a lower frequency on CPC than on ZX-Spectrum and MSX - for the 440hz (A-4 in germanic notation), it seems that on the 12bit (frequency values between 0 and 4095) frequency area used in the 6 first registers, it's 142 on CPC, and 254 on ZX-Spectrum and MSX - is there any documentation or frequency table describing/confirming that?

jsa


If I recall right these things are clocked bit differently in all of those.

In MSX AY frequency is ~1.79 MHz contrary to Amstrad 1MHz. -> 142*1.79 = 254.18.
On ZX AY frequency is 1.77 so values should differ between ZX and MSX as well.








Bryce

The pitch difference between 1.77MHz and 1.79MHz AYs would be less 5Hz. Would you really notice a difference between 440Hz and 444Hz if you didn't have them playing at the same time in front of you?

Bryce.

jsa

I would not notice. But someone with "golden ears" might.  ;D . But then again why analyze music with "scope".



trabitboy

Quote from: nitrofurano on 13:39, 25 March 16
working excellently! thanks, @arnoldemu ! :)

Hi !
I'm trying direct AY access too, and couldn't help but see the source of your test is included :o )
It doesn't seem to be winape syntax, is it pasmo?

edit: my bad, just understood by looking at the .sh
instructive :)

Powered by SMFPacks Menu Editor Mod