* Mod parser parses patterns, just got to figure out what the period values mean...
[pineappletracker.git] / pineapple.h
blob4af2e694d6988238840ae212eb0dd757ad44b7d9
1 /* vi:set ts=4 sts=4 sw=4 noexpandtab: */
2 #include <stdint.h>
4 #ifndef PINEAPPLE_H
5 #define PINEAPPLE_H
6 #define TRACKLEN 32
8 typedef uint8_t u8;
9 typedef uint16_t u16;
10 typedef uint32_t u32;
12 typedef int8_t s8;
13 typedef int16_t s16;
14 typedef int32_t s32;
16 u8 callbacktime;
17 char filename[1024];
18 char *infinitemsg;
19 char comment[1024];
21 /* MODES */
22 enum {
23 PM_NORMAL,
24 PM_VISUAL,
25 PM_VISUALLINE,
26 PM_CMDLINE,
27 PM_INSERT,
28 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 songline song[256];
83 int songlen, 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 guiloop(void);
98 void display(void);
100 void startplaysong(int);
101 void startplaytrack(int);
103 void parsecmd(char cmd[]);
105 // just some poorly-named variables for hackin together the repeat command
106 int cmdrepeat;
107 int cmdrepeatnum;
108 int lastaction;
109 int lastrepeatnum;
111 /* a linked list */
112 /*typedef struct list_node{
113 void *element;
114 struct list_node *next;
115 } NODE;
117 NODE *list_create(void *e);
118 NODE *list_contains(NODE *n, int(*func)(void *, void *), void *match);
119 int findu8(void *a, void *b);
121 NODE *highlightlines;*/
123 /* lines to be highlighted in visual line mode */
124 int highlight_firstline, highlight_lastline, highlight_lineamount;
126 /* lines to be highlighted in visual mode */
127 int highlight_firstx, highlight_firsty, highlight_lasty, highlight_lastx;
129 /* ACTIONS */
130 void act_bigmvdown(void);
131 void act_bigmvup(void);
132 void act_mvbottom(void);
133 void act_mvtop(void);
134 void act_clritall(void);
135 void act_clronething(void);
136 void act_clrinsongtab(int y);
137 void act_clrintracktab(int t, int y);
138 void act_clrininstrtab(int instr, int y);
139 void act_fxdec(void);
140 void act_fxinc(void);
141 void act_instrdec(void);
142 void act_instrinc(void);
143 void act_mvdown(void);
144 void act_mvleft(void);
145 void act_mvright(void);
146 void act_mvup(void);
147 void act_notedec(void);
148 void act_noteinc(void);
149 void act_octavedec(void);
150 void act_octaveinc(void);
151 void act_paramdec(void);
152 void act_paraminc(void);
153 void act_trackdec(void);
154 void act_trackinc(void);
155 void act_transpdec(void);
156 void act_transpinc(void);
157 void act_undo(void);
158 void act_viewinstrdec(void);
159 void act_viewinstrinc(void);
160 void act_viewtrackdec(void);
161 void act_viewtrackinc(void);
163 u8 trackpos;
164 u8 playtrack;
165 u8 playsong;
166 u8 songpos;
167 int songlen;
169 #endif /* PINEAPPLE_H */