/***************************************************/ /* COP libray based on the NexT Byte Codes library */ /***************************************************/ #define SOUND_MODE_ONCE 0x00 /* W - Only play file once */ #define SOUND_MODE_LOOP 0x01 /* - Play file until writing "SOUND_STOP" into "State" or new "update" */ #define SOUND_MODE_TONE 0x02 /* W - Play tone specified in Freq for Duration ms */ #define TONE_A3 220 #define TONE_AS3 233 #define TONE_B3 247 #define TONE_C4 262 #define TONE_CS4 277 #define TONE_D4 294 #define TONE_DS4 311 #define TONE_E4 330 #define TONE_F4 349 #define TONE_FS4 370 #define TONE_G4 392 #define TONE_GS4 415 #define TONE_A4 440 #define TONE_AS4 466 #define TONE_B4 494 #define TONE_C5 523 #define TONE_CS5 554 #define TONE_D5 587 #define TONE_DS5 622 #define TONE_E5 659 #define TONE_F5 698 #define TONE_FS5 740 #define TONE_G5 784 #define TONE_GS5 831 #define TONE_A5 880 #define TONE_AS5 932 #define TONE_B5 988 #define TONE_C6 1047 #define TONE_CS6 1109 #define TONE_D6 1175 #define TONE_DS6 1245 #define TONE_E6 1319 #define TONE_F6 1397 #define TONE_FS6 1480 #define TONE_G6 1568 #define TONE_GS6 1661 #define TONE_A6 1760 #define TONE_AS6 1865 #define TONE_B6 1976 #define TONE_C7 2093 #define TONE_CS7 2217 #define TONE_D7 2349 #define TONE_DS7 2489 #define TONE_E7 2637 #define TONE_F7 2794 #define TONE_FS7 2960 #define TONE_G7 3136 #define TONE_GS7 3322 #define TONE_A7 3520 #define TONE_AS7 3729 #define TONE_B7 3951 /**/ /**/ /**/ /****************************/ /* this function plays tone */ /****************************/ void COP_SoundPlayTone(int freq,int duration,byte loop,byte volume) { inline "dseg segment"; inline "SPT TSoundPlayTone"; inline "dseg ends"; inline "mov SPT.Frequency, COP_SoundPlayTone_freq"; inline "mov SPT.Duration, COP_SoundPlayTone_duration"; inline "mov SPT.Loop, COP_SoundPlayTone_loop"; inline "mov SPT.Volume, COP_SoundPlayTone_volume"; inline "syscall SoundPlayTone, SPT"; } #define SOUND_FLAGS_IDLE 0x00 /* R - Idle */ #define SOUND_FLAGS_UPDATE 0x01 /* W - Make changes take effect */ #define SOUND_FLAGS_RUNNING 0x02 /* R - Processing tone or file */ #define SOUND_STATE_IDLE 0x00 /* R - Idle, ready for start sound (SOUND_UPDATE) */ #define SOUND_STATE_FILE 0x02 /* R - Processing file of sound/melody data */ #define SOUND_STATE_TONE 0x03 /* R - Processing play tone request */ #define SOUND_STATE_STOP 0x04 /* W - Stop sound immediately and close hardware */ /**/ /**/ /**/ /**************************************/ /* this function get sound state tone */ /**************************************/ byte COP_SoundGetState(void) { inline "dseg segment"; inline "SGS TSoundGetState"; inline "dseg ends"; inline "syscall SoundGetState, SGS"; inline "mov expr_byte_COP_SoundGetState, SGS.Flags"; } /**/ /**/ /**/ /**************************************/ /* this function set sound state tone */ /**************************************/ byte COP_SoundSetState(byte state,byte flags) { inline "dseg segment"; inline "SSS TSoundSetState"; inline "dseg ends"; inline "mov SSS.State, COP_SoundSetState_state"; inline "mov SSS.Flags, COP_SoundSetState_flags"; inline "syscall SoundSetState, SSS"; inline "mov expr_byte_COP_SoundSetState, SSS.Result"; } /**/ /**/ /**/ /**************************************/ /* this function play a file */ /**************************************/ byte COP_SoundPlayFile(char *name,byte loop,byte volume) { inline "dseg segment"; inline "SPF TSoundPlayFile"; inline "dseg ends"; inline "mov SPF.Filename, COP_SoundPlayFile_name"; inline "mov SPF.Loop, COP_SoundPlayFile_loop"; inline "mov SPF.Volume, COP_SoundPlayFile_volume"; inline "syscall SoundPlayFile, SPF"; inline "mov expr_byte_COP_SoundPlayFile, SPF.Result"; }