Mercurial > hg > dmlib
annotate jssplr.h @ 100:f16d102dbbac
Add a function for setting bitmapped font palette.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Tue, 02 Oct 2012 20:33:01 +0300 |
parents | 2884a611042b |
children | 8ac24d753304 |
rev | line source |
---|---|
0 | 1 /* |
2 * miniJSS - Module playing routines | |
3 * Programmed and designed by Matti 'ccr' Hamalainen | |
4 * (C) Copyright 2006-2007 Tecnic Software productions (TNSP) | |
5 */ | |
6 #ifndef JSSPLR_H | |
7 #define JSSPLR_H | |
8 | |
9 #include "jss.h" | |
10 #include "jssmod.h" | |
11 #include "jssmix.h" | |
12 | |
13 | |
14 // Player general constants | |
15 #define mpMinVol (0) | |
16 #define mpMaxVol (64) | |
17 #define mpPanCenter (0) | |
18 #define mpMaxFadeoutVol (65535) | |
19 | |
20 | |
21 // Channel New-Data flags | |
22 #define cdfNONE (0x00) // Set nothing | |
23 #define cdfNewInstr (0x01) // Set a new instrument | |
24 #define cdfNewPitch (0x02) // Set a new pitch | |
25 #define cdfNewPos (0x04) // Set a new position | |
26 #define cdfNewVolume (0x08) // Set a new volume | |
27 #define cdfNewPanPos (0x10) // Set a new panning position | |
28 #define cdfNewGlobalVol (0x20) // Set a new global volume | |
29 #define cdfStop (0x80) // Stop channel playing | |
30 | |
31 | |
55
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
32 // Player channel structure |
0 | 33 typedef struct |
34 { | |
55
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
35 int iPatLoopRow, // Pattern loop start row |
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
36 iPatLoopCount, // Pattern loop count |
0 | 37 |
38 iLastPortaParam, // Last portamento effect parameter | |
39 iLastPortaToNoteParam, // Last porta-to-note parameter | |
40 iLastPortaToNotePitch, // Last porta-to-note pitch | |
41 | |
42 iVibratoPos, // Vibrato waveform position | |
43 iVibratoSpeed, // Vibrato speed | |
44 iVibratoDepth, // Vibrato depth | |
45 iVibratoWC, // Vibrato wave control | |
46 | |
47 iTremoloPos, // Tremolo waveform position | |
48 iTremoloSpeed, // Tremolo speed | |
49 iTremoloDepth, // Tremolo depth | |
50 | |
51 iTremoloWC, // Tremolo wave control | |
52 | |
53 iLastTremorParam, | |
54 iTremorCount, | |
55 iLastSampleOffset, | |
56 iLastRetrigParam, | |
57 iLastVolSlideParam, | |
58 | |
59 iRetrigNDFlags, // For retrig-effect | |
60 iSaveNDFlags; // For notedelay-effect | |
61 | |
62 // Current channel data | |
55
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
63 JSSInstrument *iCInstrument; // Instrument |
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
64 JSSExtInstrument *iCExtInstrument; // ExtInstrument |
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
65 int iCInstrumentN, |
0 | 66 iCExtInstrumentN, |
55
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
67 iCNote, // Current note |
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
68 iCPitch, // Pitch (NOT actual frequency!) |
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
69 iCOldPitch, |
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
70 iCPosition, // Sample position |
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
71 iCVolume, // Volume |
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
72 iCPanning, // Panning position |
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
73 |
0 | 74 iCNewDataFlags, // New data flags |
75 | |
76 iCFadeOutVol, | |
77 | |
78 iCPanEnv, | |
79 iCVolEnv, | |
80 | |
81 iCAutoVib_Frames, | |
82 iCPanEnv_Frames, | |
83 iCVolEnv_Frames, | |
84 | |
85 iCLastFineVolumeslideUpParam, | |
86 iCLastFineVolumeslideDownParam, | |
87 iCLastExtraFinePortamentoUpParam, | |
88 iCLastExtraFinePortamentoDownParam, | |
89 iCLastFinePortamentoUpParam, | |
90 iCLastFinePortamentoDownParam; | |
91 | |
55
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
92 BOOL iCPanEnv_Exec, |
0 | 93 iCVolEnv_Exec, |
94 iCKeyOff; | |
55
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
95 } JSSPlayerChannel; |
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
96 |
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
97 |
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
98 // Struct holding all player related information |
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
99 typedef struct |
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
100 { |
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
101 // General variables |
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
102 int tempo, // Current values |
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
103 speed, |
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
104 tick, |
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
105 order, |
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
106 npattern, |
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
107 row, |
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
108 globalVol, |
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
109 options; // Playing option flags |
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
110 BOOL isPlaying; // Are we playing? |
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
111 |
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
112 int newOrder, // NEW order number |
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
113 newRow; // NEW row number |
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
114 BOOL newOrderSet, // TRUE if new order has been set |
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
115 newRowSet; // TRUE if new row has been set |
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
116 |
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
117 int patternDelay, // Pattern delay tick-counter |
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
118 lastPatLoopRow; // Latest set pattern loop row (any channel) |
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
119 |
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
120 |
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
121 // All channels for this player |
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
122 // int nchannels; |
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
123 JSSPlayerChannel channels[jsetNChannels]; |
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
124 |
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
125 // Parameters for effects, etc |
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
126 BOOL jumpFlag, // Pattern jump flag |
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
127 breakFlag; // Pattern break flag |
0 | 128 |
129 // Module and sounddevice specific | |
55
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
130 JSSModule *module; // Current module in this player |
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
131 JSSPattern *pattern; // Current pattern |
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
132 JSSMixer *device; // Pointer to mixing device structure |
0 | 133 |
134 #ifdef JSS_SUP_THREADS | |
135 DMMutex *mutex; | |
136 #endif | |
137 | |
138 } JSSPlayer; | |
139 | |
140 | |
141 /* External functions for end users | |
142 */ | |
143 int jmpPlayOrder(JSSPlayer *, int); | |
144 int jmpPlayPattern(JSSPlayer *, int); | |
145 void jmpStop(JSSPlayer *); | |
146 void jmpResume(JSSPlayer *); | |
147 void jmpSetModule(JSSPlayer *, JSSModule *); | |
148 JSSPlayer * jmpInit(JSSMixer *); | |
149 int jmpClose(JSSPlayer *); | |
150 void jmpExec(void *, void *); | |
151 | |
152 | |
153 /* Helper macros | |
154 */ | |
155 #define JMPMAKEPARAM(AIVAL, AVALX, AVALY) { AVALX = (((AIVAL) >> 4) & 0x0f); AVALY = ((AIVAL) & 0x0f); } | |
55
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
156 #define JMPSETNDFLAGS(IVAL) chn->iCNewDataFlags |= IVAL |
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
157 #define JMPUNSETNDFLAGS(IVAL) chn->iCNewDataFlags &= (~(IVAL)) |
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
158 #define JMPGETNOTE(MNOTE, MROW, MCHAN) assert(mp); assert(mp->pattern); assert((MROW) >= 0); assert((MROW) < mp->pattern->nrows); MNOTE = &mp->pattern->data[(mp->pattern->nchannels * MROW) + (MCHAN)] |
0 | 159 #define JMPGETEFFECT(MEFF, MIEFF) if ((MIEFF >= 0) && (MIEFF < jmpNMODEffectTable)) MEFF = jmpMODEffectTable[MIEFF]; else MEFF = 0 |
55
e0e470c3fc8e
Initial round of cleaning up the player code a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
160 #define JMPGETMODFLAGS(Q, Z) ((Q->module->defFlags & (Z)) == (Z)) |
0 | 161 |
162 | |
163 /* Debugging macros | |
164 */ | |
165 #if !defined(JSS_LIGHT) && defined(JSS_DEBUG) | |
97
2884a611042b
Fix building with debug mode.
Matti Hamalainen <ccr@tnsp.org>
parents:
55
diff
changeset
|
166 # define JMPDEBUG(QQ) { fprintf(stderr, "[o=%03d:p=%03d:r=%03d] (%c/%x:%x) %s\n", mp->order, mp->npattern, mp->row, effect, currNote->effect, currNote->param, QQ ); } |
0 | 167 #else |
168 # define JMPDEBUG(QQ) // stub | |
169 #endif | |
170 | |
171 #endif // JSSPLR_H |