pimp_mod_context.h 1.4 KB
Newer Older
Erik Faye-Lund's avatar
Erik Faye-Lund committed
1
2
3
#ifndef PIMP_MOD_CONTEXT_H
#define PIMP_MOD_CONTEXT_H

Erik Faye-Lund's avatar
Erik Faye-Lund committed
4
#include "../include/pimpmobile.h"
Erik Faye-Lund's avatar
Erik Faye-Lund committed
5
6
7
#include "pimp_module.h"
#include "pimp_mixer.h"

8
9
10
11
12
13
14
15
16
17
18
19
#include "pimp_instrument.h"
#include "pimp_envelope.h"

typedef struct
{
	/* some current-states */
	const pimp_instrument *instrument;
	const pimp_sample     *sample;
	
//	const pimp_envelope   *vol_env;

	pimp_envelope_state vol_env;
20
	bool sustain;
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42

	s32 period;
	s32 final_period;
	s32 porta_target;
	u16 porta_speed;
	s8  volume_slide_speed;
	u8  note_delay;
	s8  volume;
	u8  pan;

	u8  note;
	u8  effect;
	u8  effect_param;
	u8  volume_command;
	
//	u32 vol_env_tick;
//	s8  vol_env_node;
	
	u8  note_retrig;
	u8  retrig_tick;
} pimp_channel_state;

Erik Faye-Lund's avatar
Erik Faye-Lund committed
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
typedef struct
{
	u32 tick_len;
	u32 curr_tick_len;
	u32 curr_row;
	u32 curr_order;
	u32 curr_bpm;
	u32 curr_tempo;
	u32 curr_tick;
	s32 global_volume; /* 24.8 fixed point */
	pimp_pattern *curr_pattern;
	pimp_channel_state channels[CHANNELS];
	
	const u8          *sample_bank;
	const pimp_module *mod;
	pimp_mixer        *mixer;
	
Erik Faye-Lund's avatar
Erik Faye-Lund committed
60
	pimp_callback callback;
Erik Faye-Lund's avatar
Erik Faye-Lund committed
61
62
63
} pimp_mod_context;

void __pimp_mod_context_init(pimp_mod_context *ctx, const pimp_module *mod, const u8 *sample_bank, pimp_mixer *mixer);
Erik Faye-Lund's avatar
Erik Faye-Lund committed
64
65
66
void __pimp_mod_context_set_pos(pimp_mod_context *ctx, int row, int order);
void __pimp_mod_context_set_bpm(pimp_mod_context *ctx, int bpm);
void __pimp_mod_context_set_tempo(pimp_mod_context *ctx, int tempo);
Erik Faye-Lund's avatar
Erik Faye-Lund committed
67
68

#endif /* PIMP_MOD_CONTEXT_H */