// This code is a modified version of the Arkos 2 code by Arnaud Bouche.
// ArkosTracker 2 for CPCTelera
// Copyright (C) 2020 Arnaud Bouche (@Arnaud6128) for Throne Legacy.

#ifndef SOUND_H
#define SOUND_H

#include <cpctelera.h>
#include "arkos2/ArkosPlayer2.h"
#include "GameTypes.h"
#include "GameState.h"

// Must be defined in header file for wincpctelera.
#ifdef WINCPCTELERA
    extern void* E1_START;
    extern void* SFX_SOUNDEFFECTS;
#endif

// Sound effect for a switch.
#define SFX_SWITCH 1

// Sound effect for shooting a projectile weapon.
#define SFX_WEAPON_SHOT 2

// Sound effect for ending the game with death.
#define SFX_GAME_OVER 3

// Sound effect for taking damage.
#define SFX_TAKE_DAMAGE 4

// Sound effect for teleporting.
#define SFX_TELEPORT 5

// Sound effect for oxygen increase.
#define SFX_OXYGEN 6

// Sound effect for using the Amstrad CPC.
#define SFX_COMPUTER 7

// Sound effect when an item is picked up (not oxygen).
#define SFX_PICKUP 8

// Sound effect when using a pick to break a cracked block.
#define SFX_PICK 9

// Sound effect when machinery is repaired by the spanner.
#define SFX_REPAIR 10

// Channel A of the AY.
#define CHANNEL_A 1

// Channel B of the AY.
#define CHANNEL_B 2

// Channel C of the AY.
#define CHANNEL_C 3

// The maximum volume to play sound effects at.
#define MAX_VOL 0

// Sound disabled.
#define SOUND_MODE_SOUND_DISABLED 0

// Sound effects and music enabled and sound turned off.
#define SOUND_MODE_OFF 1

// Sound effects and music enabled and sound turned on.
#define SOUND_MODE_ON 2

// The current mode for playing sound (on, sound effects, music and sound effects).
extern u8 soundMode;

// Initialises all the arkos2 sound effects and music.
void initSound();

// Initialises the specified arkos2 sound effects data.
void initSoundEffects(void* soundData);

// Initialises the current arkos2 music data for playing (must be done before calling playMusic()).
void initMusic(void* musicData);

// Queues the specified sound effect and properties to be played on the next playSound() call.
void playSoundEffect(u8 effectNumber, u8 channel, u8 volume);

// Updates the current song to be played to the specified song number (this will be played on the next playSound() call).
// This allows us to support multiple songs within the arkos2 music data.
void playMusic(u8 songNumber);

// Players the currently selected arkos2 sound effects and music.
// This should be run in the interrupt at a regular interval.
void playSound();

// Stops the sound playing during the interrupt.
void stopSound();

#endif