1 /* 2 PLIB - A Suite of Portable Game Libraries 3 Copyright (C) 1998,2002 Steve Baker 4 5 This library is free software; you can redistribute it and/or 6 modify it under the terms of the GNU Library General Public 7 License as published by the Free Software Foundation; either 8 version 2 of the License, or (at your option) any later version. 9 10 This library is distributed in the hope that it will be useful, 11 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 Library General Public License for more details. 14 15 You should have received a copy of the GNU Library General Public 16 License along with this library; if not, write to the Free Software 17 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 19 For further information visit http://plib.sourceforge.net 20 21 $Id: slMODPrivate.h 1732 2002-11-30 00:41:50Z sjbaker $ 22 */ 23 24 25 #include "ul.h" 26 #include <stdio.h> 27 #include <stdlib.h> 28 #include <string.h> 29 #include <fcntl.h> 30 #include <sys/stat.h> 31 32 #ifdef UL_MSVC 33 #include <windows.h> 34 #include <io.h> 35 #else 36 #include <unistd.h> 37 #endif 38 39 #ifndef TRUE 40 #define TRUE 1 41 #define FALSE 0 42 #endif 43 44 int *dacioGetBuffer () ; 45 void dacioInit( int speed, int stereo ); 46 void dacioFlush(void); 47 void dacioIncomingBufLen(int len); 48 void dacioGlobalVol(int v); 49 void dacioOut(void); 50 void dacioEmpty () ; 51 void dacioSubtract ( int n ) ; 52 int dacioGetLen () ; 53 unsigned char *dacioGetOutBuffer () ; 54 55 #define MAX_OUTRATE 65536 56 #define MIN_TEMPO 32 57 #define DEF_OUTRATE 44100 58 #define DEF_TEMPO 125 59 #define DEF_SPEED 6 60 61 62 struct InstHirevInfo 63 { 64 unsigned int w; /* omega: 65536 = 2*pi */ 65 unsigned int wAcc; /* w accumlator */ 66 unsigned char *ptr; 67 unsigned char *end; 68 unsigned char *loopBeg; 69 int x_or; 70 int volL; 71 int volR; 72 int fadeout; 73 int lastL; 74 int lastR; 75 } ; 76 77 void _MOD_instHirevInit(void); 78 void _MOD_instHirevSetFrameLen(int l); 79 void _MOD_instHirevEraseBuf(void); 80 void _MOD_instHirevFlushBuf(void); 81 void _MOD_instHirevLoop(InstHirevInfo *ihip); 82 83 /* sample info */ 84 85 struct SampleInfo 86 { 87 unsigned char *beg; 88 unsigned char *end; 89 int x_or; /* 0x80 (or 0x8000?) */ 90 unsigned char *loopBeg; 91 int c4spd; 92 int vol; 93 int mag; /* magnification */ 94 } ; 95 96 void _MOD_instOutRate(unsigned int _or); 97 void _MOD_instSelectCh(int ch); 98 void _MOD_instClearPFW(void); 99 void _MOD_instDoPerFrameWorks(int frame); 100 void _MOD_instLoop(void); 101 void _MOD_instInit(void); 102 void _MOD_instNote(int n, int delay); 103 void _MOD_instMono(int n); 104 void _MOD_instVol(int v, int delay); 105 void _MOD_instTuning(int c4spd); 106 void _MOD_instSample(SampleInfo *sip, int delay); 107 void _MOD_instVolSlide(void); 108 void _MOD_instSetVolSlideParams(int d, int mul, int div, int nthFrame, int fine); 109 void _MOD_instSetVolSlideFast(int onOff); 110 void _MOD_instPeriodSlideUp(void); 111 void _MOD_instPeriodSlideDown(void); 112 void _MOD_instSetPeriodSlideParams(int speed, int fine); 113 void _MOD_instSetPeriodAmigaLimit(int onOff); 114 void _MOD_instPortamento(void); 115 void _MOD_instSetPortamentoTo(int to); 116 void _MOD_instSetPortamentoSpeed(int speed); 117 void _MOD_instSetPortamentoDefaultVol(void); 118 void _MOD_instSetPortamentoGlissando(int onOff); 119 void _MOD_instArpeggio(void); 120 void _MOD_instSetArpeggioParams(int plus1, int plus2); 121 void _MOD_instRetrig(void); 122 void _MOD_instSetRetrigParam(int nthFrame); 123 void _MOD_instSampleOffset(int offset); 124 void _MOD_instVibrato(void); 125 void _MOD_instSetVibratoParams(int d, int depth); 126 void _MOD_instSetVibratoWave(int type, int noRetrig); 127 void _MOD_instTremolo(void); 128 void _MOD_instSetTremoloParams(int d, int depth); 129 void _MOD_instSetTremoloWave(int type, int noRetrig); 130 void _MOD_instNoteCut(int frame); 131 void _MOD_instTremor(void); 132 void _MOD_instSetTremorParams(int onTime, int offTime); 133 void _MOD_instNoteOff(int delay); 134 int _MOD_instIsNoteOff(void); 135 void _MOD_instPanPosition(int pos); 136 void _MOD_instEmptyCmd(void); 137 138 139 struct Note 140 { 141 unsigned char note ; 142 unsigned char ins ; 143 unsigned char vol ; 144 unsigned char cmd ; 145 unsigned char info ; 146 } ; 147 148 void _MOD_playNoteSetMono(int m); 149 void _MOD_playNoteSetMasterVol(int mv); 150 void _MOD_playNoteSetGlobalVol(int gv); 151 void _MOD_playNoteSetSample(SampleInfo *sip); 152 void _MOD_playNoteInit(void); 153 void _MOD_playNoteSetOutRate(int _or); 154 void _MOD_playNoteSetTempo(int n); 155 void _MOD_playNoteSetSpeed(int n); 156 void _MOD_playNoteSetNote(int ch, Note *np); 157 void _MOD_playNoteSetPatRepeat(int n); 158 void _MOD_playNote(void); 159 160