GithubHelp home page GithubHelp logo

mvac7 / sdcc_ay38910_playfx_lib Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 0.0 73 KB

Functions for playing sound effects with the AY-3-8910.

C 57.89% Batchfile 2.82% C++ 39.29%
sdcc msx sound dev library ay-3-8910

sdcc_ay38910_playfx_lib's Introduction

PSG AY-3-8910 playFX MSX SDCC Library (fR3eL Project)

Author: mvac7 [[email protected]]
Architecture: MSX
Format: C Object (SDCC .rel)
Programming language: C and Z80 assembler

Description:

This project is an open source library with basic functions for the edition of sound and reproduction of effects in video games.

Designed for developing MSX applications using Small Device C Compiler (SDCC).

It does not use the BIOS so it can be used to program both ROMs or MSX-DOS executables.

This library is not designed to work with music players (like PT3player or WYZplayer). It is intended only for playing simple sound effects without background music.

Reading or writing to the PSG is done through calls to the assigned ports. In most of the known MSX the following are used: 0xA0, 0xA1 and 0xA2. If you want to use this library for a different architecture, you will have to change these assignments found at the start of the main source.

In the header file there is a definition of boolean type, need for the functions. This type uses the values "true" or "false" in lowercase, which equals 1 and 0 respectively.

The source code includes some applications to test or learn how to use the library.

This library is part of the MSX fR3eL Project.

Enjoy it!

Requirements

Constants & struts

Envelope shapes

The header file defines envelope shapes in case you prefer to use it instead of the numerical form:

  ENV_LowerBeat      0 
  ENV_Upper          4 
  ENV_LeftSaw        8
  ENV_LowerTriangle 10 
  ENV_LowerHold     11 
  ENV_RightSaw      12
  ENV_UpperHold     13
  ENV_UpperTriangle 14

FX struct

- [boolean]  isTone    enable tone
- [boolean]  isNoise   enable noise 
- [int]      Tone      Tone period      (0 - 4095)
- [char]     Noise     Noise period     (0 - 31)
- [int]      Period    Envelope Period  (0 - 65535)
- [char]     Shape     Envelope shape   (0-15)

Functions

  • SOUND(register, value) - Write into a register of PSG
  • PlayFX(channel, soundat) - Play FX
  • SetChannel(channel, isTone, isNoise) - Mixer. Enable/disable Tone and Noise channels.
  • SilencePSG() - Silence the three PSG channels.

How to use

This library provides functions to play simple effects (using the hardware), designed for to be used in videogames.

In our program we can include all the effects we need using the FX structure, which is defined in the library. This allows us to indicate a tone value, the noise, the state of these channels, an envelope period and a type of wave envelope.

To play an FX, we must use the PlayFX function. It allows us to select one of the three available channels, but because it is based on sounds produced by the wave envelope hardware and the AY-3-8910 can only play one at the same time, it is recommended to always send them through the same chanel to avoid generating unwanted sounds. If an FX is played without having finished the previous one, this last one will have priority over the previous one since it will overwrite the PSG registers.

If you want to take advantage of the other channels to include music using one of the existing AY players (PT3, WYZ, Arkos, ...), these functions will probably not work since the music players use a buffer that is modified every time it is executed and it is dumped directly to PSG on every VBLANK interruption. In order to get this working, this library should be modified so that instead of writing directly to the registers, it does it over the player's buffer.

Acknowledgments

I want to give a special thanks to all those who freely share their knowledge with the MSX developer community.

sdcc_ay38910_playfx_lib's People

Contributors

mvac7 avatar

Stargazers

 avatar

Watchers

 avatar

sdcc_ay38910_playfx_lib's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.