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