Problems with AY sound. Experts needed. :-)

edited June 2015 in Development
I need to play some AY sound effects, so I've been experimenting with Shiru's AYFX Editor package (and his player code) as that seems simple and suitable, but there's a couple of things I don't understand.

This is what I'm working with btw: https://dl.dropboxusercontent.com/u/2697142/aytest.zip (1.5kb)

I've taken the player and stripped all non-essential code away and made some changes to not use interrupt or have self-modifying code. Compile the file "compilethis.asm" and it will then import the two other files. You can then press space to play a sound. Simple enough.

But to use it I need to understand it...and I don't.

Look at the first 3 lines of the source code. The label musInitAd (currently) points to $9000 but can be changed to anything really.
...but there is nothing there! Yet, it still it works. If I place a RET on that address nothing happens and if I place a RST 0 there it resets, so it does go there (obviously). If I omit the call to that address it doesn't work at all - it resets.

I've disabled the calls to the two other addresses with EQU statements and that doesn't seem to have any effect, but the first one needs to be there...but those two other calls has to be there for a reason. But I'm stumped. 

...so what exactly happens and how can I get it under control?

Suggestions on how to fix/understand this would be appreciated - even an alternative solution would. ;)
Post edited by Sokurah on
Website: Tardis Remakes / Mostly remakes of Arcade and ZX Spectrum games.
My games for the Spectrum: Dingo, The Speccies, The Speccies 2, Vallation, SQIJ.
Twitter: Sokurah

Comments

  • edited June 2015
    The sound effects are separate and independent of the background music (which can be omitted if required).

    I have got this going in z88dk and I added a PUSH IX / POP IX to the interrupt code and added conditionals around the music portion.

    .asm file is here if you are interested.

    I use the ISR for sound effects

    LD HL,INTPROC ; Set up interrupt service routine pointer
    LD ($5CFF),HL ; This is somewhere in the first CHANS area

    CALL STARTISR

    LD HL,SFXBANKAD ; Address where .afx file is loaded
      CALL AFXINIT

    LD A,8 ; Play Effect number in .afx file -1
    CALL AFXPLAY

    JR $

    STARTISR DI
    LD A,$5C ; Point to $5CFF
    LD I,A
    IM 2
    EI
    RET

    Then when you are finished

    KILLISR DI
    LD A,$3F
    LD I,A
    IM 1
    EI
    RET

    Regards,
    Derek.


    Post edited by dbolli on
    1985: ZX Spectrum+ 48K Interface 1 ZX81 16KB ASZMIC/SP ROM Philips 12" B/W TV Epson Dot Matrix Printer ZX Printer Now: Late 2015 iMac 5K 27" 4GHz i7 32GB RAM macOS 10.15.7 1TB Ext SSD USB C Drive Ext 4TB 3TB and 2TB USB 3 Hard Disks Ext USB 3 Blu-Ray iPad R7 32GB iPhone 6s 64GB iOS 14.0.1 Apple TV Gen 2
  • dbolli said:

    I have got this going in z88dk and I added a PUSH IX / POP IX to the interrupt code and added conditionals around the music portion.

    .asm file is here if you are interested.

    Regards,
    Derek.
    Awesome, thanks @dbolli. :)

    I'll see if I can figure out how to make it work (not using z88dk). I may have to get it working on a Spectrum first but once I have it working I'll port it to run on some other hardware, although I may work it into any future Spectrum games too. \m/
    Website: Tardis Remakes / Mostly remakes of Arcade and ZX Spectrum games.
    My games for the Spectrum: Dingo, The Speccies, The Speccies 2, Vallation, SQIJ.
    Twitter: Sokurah
  • edited June 2015
    Yes, it is not dependent on z88dk and will work on its own.

    Just a couple of additional notes, where I refer to an .afx file above, I mean an .afb bank file.

    To enable background music just

    #define AYFXEDPLAYMUSIC 1               // Include music routines


    at the start of assembly or equivalent command line directive)

    CALL MUSINITAD ; $620A $C000 MUSINITAD


    after the call to AFXINIT

    for example an .xm file loaded at $C000 will usually map to something like (i.e. the first few bytes of the .xm file)

    MUSINITAD LD HL,$C864 ; $C000

    JR $C03F ; $C003

    MUSPLAYAD JP $C4AF ; $C005

    MUSSHUTAD JR $C033 ; $C008


    If you do not need music, do

    #define AYFXEDPLAYMUSIC 0               // Exclude music routines

    to save yourself a few bytes.

    Regards,
    Derek.
     
    Post edited by dbolli on
    1985: ZX Spectrum+ 48K Interface 1 ZX81 16KB ASZMIC/SP ROM Philips 12" B/W TV Epson Dot Matrix Printer ZX Printer Now: Late 2015 iMac 5K 27" 4GHz i7 32GB RAM macOS 10.15.7 1TB Ext SSD USB C Drive Ext 4TB 3TB and 2TB USB 3 Hard Disks Ext USB 3 Blu-Ray iPad R7 32GB iPhone 6s 64GB iOS 14.0.1 Apple TV Gen 2
  • dbolli said:

    Yes, it is not dependent on z88dk and will work on its own.


    Just a couple of additional notes, where I refer to an .afx file above, I mean an .afb bank file. 
    Cool, thanks. I've got it working on the Spectrum now.
    ...and I learned about the bankfiles as well. That makes things a lot easier. :)

    Next up is rewriting it to use the ports on the arcade hardware I'm coding for at the moment. ;)
    Website: Tardis Remakes / Mostly remakes of Arcade and ZX Spectrum games.
    My games for the Spectrum: Dingo, The Speccies, The Speccies 2, Vallation, SQIJ.
    Twitter: Sokurah
Sign In or Register to comment.