Load ht->ht_Tracks into tune->struct track trk[]. Seems I got it working for lft...
[pineappletracker.git] / pineapple.h
blobc701b643ca20e01443c3938d9a3db8ac51fc434a
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
29 void normalmode(int c);
30 void cmdlinemode(void);
31 void insertmode(void);
32 void jammermode(void);
33 void visualmode(void);
34 void visuallinemode(void);
36 typedef enum {
37 WF_TRI = 0,
38 WF_SAW,
39 WF_PUL,
40 WF_NOI,
41 WF_SINE
42 } waveform_t;
44 volatile struct oscillator {
45 u16 freq;
46 u16 phase;
47 u16 duty;
48 waveform_t waveform;
49 u8 volume; // 0-255
50 } osc[4];
52 struct trackline {
53 u8 note;
54 u8 instr;
55 u8 cmd[2];
56 u8 param[2];
59 struct track {
60 struct trackline line[TRACKLEN];
63 struct instrline {
64 u8 cmd;
65 u8 param;
68 struct instrument {
69 int length;
70 struct instrline line[256];
73 struct songline {
74 u8 track[4];
75 u8 transp[4];
78 struct instrument instrument[256], iclip[256];
79 struct track track[256], tclip[256];
80 struct songline song[256];
82 //int songlen;
83 int tracklen;
85 void initchip(void);
86 u8 interrupthandler(void);
88 void readsong(int pos, int ch, u8 *dest);
89 void readtrack(int num, int pos, struct trackline *tl);
90 void readinstr(int num, int pos, u8 *il);
92 void silence(void);
93 void iedplonk(int, int);
95 void initgui(void);
96 void eventloop(void);
98 void display(void);
100 int hexdigit(char c);
101 int nextfreetrack(void);
102 int nextfreeinstr(void);
104 void startplaysong(int);
105 void startplaytrack(int);
107 void parsecmd(char cmd[]);
109 // just some poorly-named variables for hackin together the repeat command
110 int cmdrepeat;
111 int cmdrepeatnum;
112 int lastaction;
113 int lastrepeatnum;
115 /* lines to be highlighted in visual line mode */
116 int highlight_firstline, highlight_lastline, highlight_lineamount;
118 /* lines to be highlighted in visual mode */
119 int highlight_firstx, highlight_firsty, highlight_lasty, highlight_lastx;
121 /* ACTIONS */
122 void act_bigmvdown(void);
123 void act_bigmvup(void);
124 void act_mvbottom(void);
125 void act_mvtop(void);
126 void act_clritall(void);
127 void act_clronething(void);
128 void act_clrinsongtab(int y);
129 void act_clrintracktab(int t, int y);
130 void act_clrininstrtab(int instr, int y);
131 void act_fxdec(void);
132 void act_fxinc(void);
133 void act_instrdec(void);
134 void act_instrinc(void);
135 void act_mvdown(void);
136 void act_mvleft(void);
137 void act_mvright(void);
138 void act_mvup(void);
139 void act_notedec(void);
140 void act_noteinc(void);
141 void act_octavedec(void);
142 void act_octaveinc(void);
143 void act_paramdec(void);
144 void act_paraminc(void);
145 void act_trackdec(void);
146 void act_trackinc(void);
147 void act_transpdec(void);
148 void act_transpinc(void);
149 void act_undo(void);
150 void act_viewinstrdec(void);
151 void act_viewinstrinc(void);
152 void act_viewtrackdec(void);
153 void act_viewtrackinc(void);
154 void act_addline(void);
155 void act_delline(void);
157 /*u8 trackpos;
158 u8 songpos;
159 int songlen;*/
160 int playtrack;
161 int playsong;
163 struct config_params {
164 int buffersize;
165 char *gui;
166 char *audio_driver;
167 int samplefreq;
170 /*audio functions*/
172 void lftSdlCallback(void *userdata, u8 *buf, int len);
173 u8 (*audioInit)(void); //function that changes depending on which audiodriver is specified
174 u8 sdl_init(void);
175 void (*sdlCallback)(void); //function that changes depending on which type of file is loaded
176 //void hvlSdlCallBack(struct hvl_tune *ht, uint8 *stream, int length);
178 typedef struct _pineapple_tune {
179 char *type; //.pt, .mod, .hvl, .ahx
181 char *filename;
182 u8 callbacktime; //ht_SpeedMultiplier
183 u16 tempo; //ht_Tempo
184 char *comment;
185 struct oscillator osc[4];
186 struct instrument instr[256]; //struct hvl_instrument *ht_Instruments
187 struct track trk[256]; //struct hvl_step ht_Tracks[256][64]
188 struct songline sng[256]; //struct hvl_position *ht_Positions
189 int songlen; //ht_PositionNr
190 int songpos; //ht_PosNr
191 int trackpos;
192 int tracklen; //ht_TrackLength
193 int trackNum; //number of tracks that are used, ht_TrackNr
194 int instrx, instry, instroffs;
195 int songx, songy, songoffs;
196 int trackx, tracky, trackoffs;
197 int currtrack, currinstr;
198 int currtab;
199 int saved;
200 } pineapple_tune;
202 pineapple_tune *tune;
205 #endif /* PINEAPPLE_H */