Common practices of programming the AY-3-8910 on Amstrad CPC: via Firmware routines or directly?












6















I'm starting to learn how to program in assembly (z80) on the Amstrad CPC
computer. As an high level developper i find it pretty fun and i learn a lot of
things about computer and CPU architecture.



As of now i mainly want to play with the embedded AY-3-8910 sound chip because
my little project is mainly "sound focused". The Amstrad CPC embeds a Firmware
in its ROM containing routines to control the sound chip. This set of routines
is called "The Sound Manager".



I wonder what were common practices to program the AY-3-8910 on this computer:
Did almost every assembly programmers of music / sound software made use of
theses firmware routines or did they bypassed them and addressed the chip
directly ? Does theses routines perform well compared to addressing the chip
directly ?



The aim of my question is to know if it is worth learning and mastering theses
routines or is it better to learn how to program the chip directly, using the
chip datasheet.










share|improve this question









New contributor




sgt-hartman is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
















  • 1





    As always both ways where used. Since the CPC featured rather advanced internal mechanics it's always a good idea to use the ROM routines. Then again, as so often, larger projects spend considerable amount of code on project specific sound functions, where adding low level funcionalty wouldn't add much - but maybe offer additional freedom. So, unless you're doing something realy big, I'd say go with the ROM routines - it'll simplify coding now and can be replaced later if there is need for further optimization. Get it going fist - optimize later.

    – Raffzahn
    13 hours ago
















6















I'm starting to learn how to program in assembly (z80) on the Amstrad CPC
computer. As an high level developper i find it pretty fun and i learn a lot of
things about computer and CPU architecture.



As of now i mainly want to play with the embedded AY-3-8910 sound chip because
my little project is mainly "sound focused". The Amstrad CPC embeds a Firmware
in its ROM containing routines to control the sound chip. This set of routines
is called "The Sound Manager".



I wonder what were common practices to program the AY-3-8910 on this computer:
Did almost every assembly programmers of music / sound software made use of
theses firmware routines or did they bypassed them and addressed the chip
directly ? Does theses routines perform well compared to addressing the chip
directly ?



The aim of my question is to know if it is worth learning and mastering theses
routines or is it better to learn how to program the chip directly, using the
chip datasheet.










share|improve this question









New contributor




sgt-hartman is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
















  • 1





    As always both ways where used. Since the CPC featured rather advanced internal mechanics it's always a good idea to use the ROM routines. Then again, as so often, larger projects spend considerable amount of code on project specific sound functions, where adding low level funcionalty wouldn't add much - but maybe offer additional freedom. So, unless you're doing something realy big, I'd say go with the ROM routines - it'll simplify coding now and can be replaced later if there is need for further optimization. Get it going fist - optimize later.

    – Raffzahn
    13 hours ago














6












6








6








I'm starting to learn how to program in assembly (z80) on the Amstrad CPC
computer. As an high level developper i find it pretty fun and i learn a lot of
things about computer and CPU architecture.



As of now i mainly want to play with the embedded AY-3-8910 sound chip because
my little project is mainly "sound focused". The Amstrad CPC embeds a Firmware
in its ROM containing routines to control the sound chip. This set of routines
is called "The Sound Manager".



I wonder what were common practices to program the AY-3-8910 on this computer:
Did almost every assembly programmers of music / sound software made use of
theses firmware routines or did they bypassed them and addressed the chip
directly ? Does theses routines perform well compared to addressing the chip
directly ?



The aim of my question is to know if it is worth learning and mastering theses
routines or is it better to learn how to program the chip directly, using the
chip datasheet.










share|improve this question









New contributor




sgt-hartman is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.












I'm starting to learn how to program in assembly (z80) on the Amstrad CPC
computer. As an high level developper i find it pretty fun and i learn a lot of
things about computer and CPU architecture.



As of now i mainly want to play with the embedded AY-3-8910 sound chip because
my little project is mainly "sound focused". The Amstrad CPC embeds a Firmware
in its ROM containing routines to control the sound chip. This set of routines
is called "The Sound Manager".



I wonder what were common practices to program the AY-3-8910 on this computer:
Did almost every assembly programmers of music / sound software made use of
theses firmware routines or did they bypassed them and addressed the chip
directly ? Does theses routines perform well compared to addressing the chip
directly ?



The aim of my question is to know if it is worth learning and mastering theses
routines or is it better to learn how to program the chip directly, using the
chip datasheet.







assembly cpc cpc464






share|improve this question









New contributor




sgt-hartman is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











share|improve this question









New contributor




sgt-hartman is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









share|improve this question




share|improve this question








edited 14 hours ago







sgt-hartman













New contributor




sgt-hartman is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









asked 17 hours ago









sgt-hartmansgt-hartman

1334




1334




New contributor




sgt-hartman is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





sgt-hartman is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






sgt-hartman is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.








  • 1





    As always both ways where used. Since the CPC featured rather advanced internal mechanics it's always a good idea to use the ROM routines. Then again, as so often, larger projects spend considerable amount of code on project specific sound functions, where adding low level funcionalty wouldn't add much - but maybe offer additional freedom. So, unless you're doing something realy big, I'd say go with the ROM routines - it'll simplify coding now and can be replaced later if there is need for further optimization. Get it going fist - optimize later.

    – Raffzahn
    13 hours ago














  • 1





    As always both ways where used. Since the CPC featured rather advanced internal mechanics it's always a good idea to use the ROM routines. Then again, as so often, larger projects spend considerable amount of code on project specific sound functions, where adding low level funcionalty wouldn't add much - but maybe offer additional freedom. So, unless you're doing something realy big, I'd say go with the ROM routines - it'll simplify coding now and can be replaced later if there is need for further optimization. Get it going fist - optimize later.

    – Raffzahn
    13 hours ago








1




1





As always both ways where used. Since the CPC featured rather advanced internal mechanics it's always a good idea to use the ROM routines. Then again, as so often, larger projects spend considerable amount of code on project specific sound functions, where adding low level funcionalty wouldn't add much - but maybe offer additional freedom. So, unless you're doing something realy big, I'd say go with the ROM routines - it'll simplify coding now and can be replaced later if there is need for further optimization. Get it going fist - optimize later.

– Raffzahn
13 hours ago





As always both ways where used. Since the CPC featured rather advanced internal mechanics it's always a good idea to use the ROM routines. Then again, as so often, larger projects spend considerable amount of code on project specific sound functions, where adding low level funcionalty wouldn't add much - but maybe offer additional freedom. So, unless you're doing something realy big, I'd say go with the ROM routines - it'll simplify coding now and can be replaced later if there is need for further optimization. Get it going fist - optimize later.

– Raffzahn
13 hours ago










1 Answer
1






active

oldest

votes


















10














Especially for writing the sound registers, it is advisable to use the built-in routines.



According to the Schneider CPC firmware guide, the reason is the following:




  1. The CPC keyboard is directly connected to the AY chip - Thus, the keyboard service routine (which runs as an interrupt service routine) is accessing the AY ports directly.

  2. Accessing the sound chip sometimes needs non-atomic operations like "register select" + "register write" - If the interrupt service routine for the keyboard collides with such non-atomic access, it (or your own code) might become upset.

  3. You can definitely write code that can work around these collisions, but then you'd end up with writing more or less a copy of the BIOS routines. The overhead these BIOS routines add is not significantly more than you'd have to add in your own code.






share|improve this answer


























  • OK, so it seems more annoying than anything else to program it directly, especially because of the keyboard routine. I'm still interested to know what programmers did by the time (or even now, the Amstrad community seems alive and strong)

    – sgt-hartman
    14 hours ago













  • I'd be curious whether there's a split between bog-standard two-week Spectrum ports and proper Amstrad titles; that might reveal some nuance behind the decision.

    – Tommy
    10 hours ago






  • 1





    @Tommy Well, the Amstrad routines provide interrupt-driven sound queues and interesting features like Rendez-Vous. You basically just have to plop on your sound files - The Spectrum hasn't got much in comparison. On the other hand, if you don't use the CPC BIOS for sound, you'll also have to code your keyboard scanning from scratch.

    – tofro
    10 hours ago








  • 1





    I also guess I've stumbled upon a more nuanced topic than I realised: even cross-platform titles with great Amstrad-specific work — like Chase HQ or Robocop — may have gone lowest common denominator in their sound routines. It doesn't need to be a lazy port just to have no use for those advanced features.

    – Tommy
    7 hours ago











Your Answer








StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "648"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
noCode: true, onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});






sgt-hartman is a new contributor. Be nice, and check out our Code of Conduct.










draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fretrocomputing.stackexchange.com%2fquestions%2f9133%2fcommon-practices-of-programming-the-ay-3-8910-on-amstrad-cpc-via-firmware-routi%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









10














Especially for writing the sound registers, it is advisable to use the built-in routines.



According to the Schneider CPC firmware guide, the reason is the following:




  1. The CPC keyboard is directly connected to the AY chip - Thus, the keyboard service routine (which runs as an interrupt service routine) is accessing the AY ports directly.

  2. Accessing the sound chip sometimes needs non-atomic operations like "register select" + "register write" - If the interrupt service routine for the keyboard collides with such non-atomic access, it (or your own code) might become upset.

  3. You can definitely write code that can work around these collisions, but then you'd end up with writing more or less a copy of the BIOS routines. The overhead these BIOS routines add is not significantly more than you'd have to add in your own code.






share|improve this answer


























  • OK, so it seems more annoying than anything else to program it directly, especially because of the keyboard routine. I'm still interested to know what programmers did by the time (or even now, the Amstrad community seems alive and strong)

    – sgt-hartman
    14 hours ago













  • I'd be curious whether there's a split between bog-standard two-week Spectrum ports and proper Amstrad titles; that might reveal some nuance behind the decision.

    – Tommy
    10 hours ago






  • 1





    @Tommy Well, the Amstrad routines provide interrupt-driven sound queues and interesting features like Rendez-Vous. You basically just have to plop on your sound files - The Spectrum hasn't got much in comparison. On the other hand, if you don't use the CPC BIOS for sound, you'll also have to code your keyboard scanning from scratch.

    – tofro
    10 hours ago








  • 1





    I also guess I've stumbled upon a more nuanced topic than I realised: even cross-platform titles with great Amstrad-specific work — like Chase HQ or Robocop — may have gone lowest common denominator in their sound routines. It doesn't need to be a lazy port just to have no use for those advanced features.

    – Tommy
    7 hours ago
















10














Especially for writing the sound registers, it is advisable to use the built-in routines.



According to the Schneider CPC firmware guide, the reason is the following:




  1. The CPC keyboard is directly connected to the AY chip - Thus, the keyboard service routine (which runs as an interrupt service routine) is accessing the AY ports directly.

  2. Accessing the sound chip sometimes needs non-atomic operations like "register select" + "register write" - If the interrupt service routine for the keyboard collides with such non-atomic access, it (or your own code) might become upset.

  3. You can definitely write code that can work around these collisions, but then you'd end up with writing more or less a copy of the BIOS routines. The overhead these BIOS routines add is not significantly more than you'd have to add in your own code.






share|improve this answer


























  • OK, so it seems more annoying than anything else to program it directly, especially because of the keyboard routine. I'm still interested to know what programmers did by the time (or even now, the Amstrad community seems alive and strong)

    – sgt-hartman
    14 hours ago













  • I'd be curious whether there's a split between bog-standard two-week Spectrum ports and proper Amstrad titles; that might reveal some nuance behind the decision.

    – Tommy
    10 hours ago






  • 1





    @Tommy Well, the Amstrad routines provide interrupt-driven sound queues and interesting features like Rendez-Vous. You basically just have to plop on your sound files - The Spectrum hasn't got much in comparison. On the other hand, if you don't use the CPC BIOS for sound, you'll also have to code your keyboard scanning from scratch.

    – tofro
    10 hours ago








  • 1





    I also guess I've stumbled upon a more nuanced topic than I realised: even cross-platform titles with great Amstrad-specific work — like Chase HQ or Robocop — may have gone lowest common denominator in their sound routines. It doesn't need to be a lazy port just to have no use for those advanced features.

    – Tommy
    7 hours ago














10












10








10







Especially for writing the sound registers, it is advisable to use the built-in routines.



According to the Schneider CPC firmware guide, the reason is the following:




  1. The CPC keyboard is directly connected to the AY chip - Thus, the keyboard service routine (which runs as an interrupt service routine) is accessing the AY ports directly.

  2. Accessing the sound chip sometimes needs non-atomic operations like "register select" + "register write" - If the interrupt service routine for the keyboard collides with such non-atomic access, it (or your own code) might become upset.

  3. You can definitely write code that can work around these collisions, but then you'd end up with writing more or less a copy of the BIOS routines. The overhead these BIOS routines add is not significantly more than you'd have to add in your own code.






share|improve this answer















Especially for writing the sound registers, it is advisable to use the built-in routines.



According to the Schneider CPC firmware guide, the reason is the following:




  1. The CPC keyboard is directly connected to the AY chip - Thus, the keyboard service routine (which runs as an interrupt service routine) is accessing the AY ports directly.

  2. Accessing the sound chip sometimes needs non-atomic operations like "register select" + "register write" - If the interrupt service routine for the keyboard collides with such non-atomic access, it (or your own code) might become upset.

  3. You can definitely write code that can work around these collisions, but then you'd end up with writing more or less a copy of the BIOS routines. The overhead these BIOS routines add is not significantly more than you'd have to add in your own code.







share|improve this answer














share|improve this answer



share|improve this answer








edited 14 hours ago

























answered 15 hours ago









tofrotofro

15.1k33086




15.1k33086













  • OK, so it seems more annoying than anything else to program it directly, especially because of the keyboard routine. I'm still interested to know what programmers did by the time (or even now, the Amstrad community seems alive and strong)

    – sgt-hartman
    14 hours ago













  • I'd be curious whether there's a split between bog-standard two-week Spectrum ports and proper Amstrad titles; that might reveal some nuance behind the decision.

    – Tommy
    10 hours ago






  • 1





    @Tommy Well, the Amstrad routines provide interrupt-driven sound queues and interesting features like Rendez-Vous. You basically just have to plop on your sound files - The Spectrum hasn't got much in comparison. On the other hand, if you don't use the CPC BIOS for sound, you'll also have to code your keyboard scanning from scratch.

    – tofro
    10 hours ago








  • 1





    I also guess I've stumbled upon a more nuanced topic than I realised: even cross-platform titles with great Amstrad-specific work — like Chase HQ or Robocop — may have gone lowest common denominator in their sound routines. It doesn't need to be a lazy port just to have no use for those advanced features.

    – Tommy
    7 hours ago



















  • OK, so it seems more annoying than anything else to program it directly, especially because of the keyboard routine. I'm still interested to know what programmers did by the time (or even now, the Amstrad community seems alive and strong)

    – sgt-hartman
    14 hours ago













  • I'd be curious whether there's a split between bog-standard two-week Spectrum ports and proper Amstrad titles; that might reveal some nuance behind the decision.

    – Tommy
    10 hours ago






  • 1





    @Tommy Well, the Amstrad routines provide interrupt-driven sound queues and interesting features like Rendez-Vous. You basically just have to plop on your sound files - The Spectrum hasn't got much in comparison. On the other hand, if you don't use the CPC BIOS for sound, you'll also have to code your keyboard scanning from scratch.

    – tofro
    10 hours ago








  • 1





    I also guess I've stumbled upon a more nuanced topic than I realised: even cross-platform titles with great Amstrad-specific work — like Chase HQ or Robocop — may have gone lowest common denominator in their sound routines. It doesn't need to be a lazy port just to have no use for those advanced features.

    – Tommy
    7 hours ago

















OK, so it seems more annoying than anything else to program it directly, especially because of the keyboard routine. I'm still interested to know what programmers did by the time (or even now, the Amstrad community seems alive and strong)

– sgt-hartman
14 hours ago







OK, so it seems more annoying than anything else to program it directly, especially because of the keyboard routine. I'm still interested to know what programmers did by the time (or even now, the Amstrad community seems alive and strong)

– sgt-hartman
14 hours ago















I'd be curious whether there's a split between bog-standard two-week Spectrum ports and proper Amstrad titles; that might reveal some nuance behind the decision.

– Tommy
10 hours ago





I'd be curious whether there's a split between bog-standard two-week Spectrum ports and proper Amstrad titles; that might reveal some nuance behind the decision.

– Tommy
10 hours ago




1




1





@Tommy Well, the Amstrad routines provide interrupt-driven sound queues and interesting features like Rendez-Vous. You basically just have to plop on your sound files - The Spectrum hasn't got much in comparison. On the other hand, if you don't use the CPC BIOS for sound, you'll also have to code your keyboard scanning from scratch.

– tofro
10 hours ago







@Tommy Well, the Amstrad routines provide interrupt-driven sound queues and interesting features like Rendez-Vous. You basically just have to plop on your sound files - The Spectrum hasn't got much in comparison. On the other hand, if you don't use the CPC BIOS for sound, you'll also have to code your keyboard scanning from scratch.

– tofro
10 hours ago






1




1





I also guess I've stumbled upon a more nuanced topic than I realised: even cross-platform titles with great Amstrad-specific work — like Chase HQ or Robocop — may have gone lowest common denominator in their sound routines. It doesn't need to be a lazy port just to have no use for those advanced features.

– Tommy
7 hours ago





I also guess I've stumbled upon a more nuanced topic than I realised: even cross-platform titles with great Amstrad-specific work — like Chase HQ or Robocop — may have gone lowest common denominator in their sound routines. It doesn't need to be a lazy port just to have no use for those advanced features.

– Tommy
7 hours ago










sgt-hartman is a new contributor. Be nice, and check out our Code of Conduct.










draft saved

draft discarded


















sgt-hartman is a new contributor. Be nice, and check out our Code of Conduct.













sgt-hartman is a new contributor. Be nice, and check out our Code of Conduct.












sgt-hartman is a new contributor. Be nice, and check out our Code of Conduct.
















Thanks for contributing an answer to Retrocomputing Stack Exchange!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fretrocomputing.stackexchange.com%2fquestions%2f9133%2fcommon-practices-of-programming-the-ay-3-8910-on-amstrad-cpc-via-firmware-routi%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Paul Cézanne

UIScrollView CustomStickyHeader Resize height generates problems when scroll is too fast

Angular material date-picker (MatDatepicker) auto completes the date on focus out