Mixer is functional now. More signed/unsigned confusion was causing most of the probl...
[pineappletracker.git] / pineapple.h
blobc438fe7165e3c48d347dfd1d2aff89d43a75d9d0
1 #include <stdint.h>
3 #ifndef PINEAPPLE_H
4 #define PINEAPPLE_H
5 #define TRACKLEN 32
7 typedef uint8_t u8;
8 typedef uint16_t u16;
9 typedef uint32_t u32;
11 typedef int8_t s8;
12 typedef int16_t s16;
13 typedef int32_t s32;
15 u8 callbacktime;
16 char filename[1024];
17 char *infinitemsg;
18 char comment[1024];
20 /* MODES */
21 enum {
22 PM_NORMAL,
23 PM_VISUAL,
24 PM_VISUALLINE,
25 PM_CMDLINE,
26 PM_INSERT,
27 PM_JAMMER
30 void normalmode(int c);
31 void cmdlinemode(void);
32 void insertmode(void);
33 void jammermode(void);
34 void visualmode(void);
35 void visuallinemode(void);
37 typedef enum {
38 WF_TRI = 0,
39 WF_SAW,
40 WF_PUL,
41 WF_NOI,
42 WF_SINE
43 } waveform_t;
45 volatile struct oscillator {
46 u16 freq;
47 u16 phase;
48 u16 duty;
49 waveform_t waveform;
50 u8 volume; // 0-255
51 } osc[4];
53 struct trackline {
54 u8 note;
55 u8 instr;
56 u8 cmd[2];
57 u8 param[2];
60 struct track {
61 struct trackline line[TRACKLEN];
64 struct instrline {
65 u8 cmd;
66 u8 param;
69 struct instrument {
70 int length;
71 struct instrline line[256];
74 struct songline {
75 u8 track[4];
76 u8 transp[4];
79 struct instrument instrument[256], iclip[256];
80 //struct track track[256], tclip[256];
81 struct track tclip[256];
82 //struct songline song[256];
84 //int songlen;
85 int tracklen;
87 void initchip(void);
88 u8 interrupthandler(void);
90 void readsong(int pos, int ch, u8 *dest);
91 void readtrack(int num, int pos, struct trackline *tl);
92 void readinstr(int num, int pos, u8 *il);
94 void silence(void);
96 void initgui(void);
97 void eventloop(void);
99 void display(void);
101 int hexdigit(char c);
102 int nextfreetrack(void);
103 int nextfreeinstr(void);
105 void startplaysong(int);
106 void startplaytrack(int);
108 void parsecmd(char cmd[]);
110 // just some poorly-named variables for hackin together the repeat command
111 int cmdrepeat;
112 int cmdrepeatnum;
113 int lastaction;
114 int lastrepeatnum;
116 /* lines to be highlighted in visual line mode */
117 int highlight_firstline, highlight_lastline, highlight_lineamount;
119 /* lines to be highlighted in visual mode */
120 int highlight_firstx, highlight_firsty, highlight_lasty, highlight_lastx;
122 /* ACTIONS */
123 void act_bigmvdown(void);
124 void act_bigmvup(void);
125 void act_mvbottom(void);
126 void act_mvtop(void);
127 void act_clritall(void);
128 void act_clronething(void);
129 void act_clrinsongtab(int y);
130 void act_clrintracktab(int t, int y);
131 void act_clrininstrtab(int instr, int y);
132 void act_fxdec(void);
133 void act_fxinc(void);
134 void act_instrdec(void);
135 void act_instrinc(void);
136 void act_mvdown(void);
137 void act_mvleft(void);
138 void act_mvright(void);
139 void act_mvup(void);
140 void act_notedec(void);
141 void act_noteinc(void);
142 void act_octavedec(void);
143 void act_octaveinc(void);
144 void act_paramdec(void);
145 void act_paraminc(void);
146 void act_trackdec(void);
147 void act_trackinc(void);
148 void act_transpdec(void);
149 void act_transpinc(void);
150 void act_undo(void);
151 void act_viewinstrdec(void);
152 void act_viewinstrinc(void);
153 void act_viewtrackdec(void);
154 void act_viewtrackinc(void);
155 void act_addline(void);
156 void act_delline(void);
158 u8 trackpos;
159 /*u8 songpos;
160 int songlen;*/
161 int playtrack;
162 int playsong;
164 struct config_params {
165 int buffersize;
166 char *gui; //sdl, ncurses, caca
167 char *audio_driver; //sdl
168 int samplefreq;
171 /*audio functions*/
173 void lftSdlCallback(void *userdata, u8 *buf, int len);
174 u8 lft_sdl_init(void);
175 //u8 (*audioInit)(void); //function that changes depending on which audiodriver is specified
176 //u8 sdl_init(void);
177 void (*sdlCallback)(void); //function that changes depending on which type of file is loaded
178 //void hvlSdlCallBack(struct hvl_tune *ht, uint8 *stream, int length);
180 enum {
181 LFT,
185 typedef struct _pineapple_tune {
186 int type; // LFT, AHX
188 char *filename;
189 u8 callbacktime; //ht_SpeedMultiplier
190 u16 tempo; //ht_Tempo
191 char *comment;
192 struct oscillator osc[4];
193 struct instrument instr[256]; //struct hvl_instrument *ht_Instruments
194 struct track trk[256]; //struct hvl_step ht_Tracks[256][64]
195 struct songline sng[256]; //struct hvl_position *ht_Positions
196 int songlen; //ht_PositionNr
197 int songpos; //ht_PosNr
198 int trackpos;
199 int tracklen; //ht_TrackLength
200 int trackNum; //number of tracks that are used, ht_TrackNr
201 int instrx, instry, instroffs;
202 int songx, songy, songoffs;
203 int trackx, tracky, trackoffs;
204 int currtrack, currinstr;
205 int currtab;
206 int saved;
208 int plonked;
209 int currnote;
211 void (*iedplonk)(int note, int instr, void *t);
212 void (*silence)(void);
213 } pineapple_tune;
215 pineapple_tune *tune;
217 u8 hvl_sdl_init(void);
219 #endif /* PINEAPPLE_H */