pimp_mod_context.h 1.83 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
#include "pimp_instrument.h"
#include "pimp_envelope.h"

typedef struct
{
	/* some current-states */
	const pimp_instrument *instrument;
	const pimp_sample     *sample;
	
	pimp_envelope_state vol_env;
18
	bool sustain;
19
20
21
22

	s32 period;
	s32 final_period;
	s32 porta_target;
Erik Faye-Lund's avatar
Erik Faye-Lund committed
23
	s32 fadeout;
24
25
26
27
28
	u16 porta_speed;
	s8  volume_slide_speed;
	u8  note_delay;
	s8  volume;
	u8  pan;
Erik Faye-Lund's avatar
Erik Faye-Lund committed
29
	
30
31
32
33
34
35
36
37
38
	u8  note;
	u8  effect;
	u8  effect_param;
	u8  volume_command;
	
	u8  note_retrig;
	u8  retrig_tick;
} pimp_channel_state;

Erik Faye-Lund's avatar
Erik Faye-Lund committed
39
40
41
42
typedef struct
{
	u32 tick_len;
	u32 curr_tick_len;
Erik Faye-Lund's avatar
Erik Faye-Lund committed
43

Erik Faye-Lund's avatar
Erik Faye-Lund committed
44
45
	u32 curr_row;
	u32 curr_order;
Erik Faye-Lund's avatar
Erik Faye-Lund committed
46
47
48
49
50
	
	/* used to delay row / order getters. usefull for demo-synching */
	u32 report_row;
	u32 report_order;
	
Erik Faye-Lund's avatar
Erik Faye-Lund committed
51
52
53
54
55
56
57
58
59
60
61
	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
62
	pimp_callback callback;
Erik Faye-Lund's avatar
Erik Faye-Lund committed
63
64
65
} 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
66
67
68
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
69

Erik Faye-Lund's avatar
Erik Faye-Lund committed
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
static inline int __pimp_mod_context_get_row(pimp_mod_context *ctx)
{
	return ctx->report_row;
}

static inline int __pimp_mod_context_get_order(pimp_mod_context *ctx)
{
	return ctx->report_order;
}

static inline int __pimp_mod_context_get_bpm(pimp_mod_context *ctx)
{
	return ctx->curr_bpm;
}

static inline int __pimp_mod_context_get_tempo(pimp_mod_context *ctx)
{
	return ctx->curr_tempo;
}


Erik Faye-Lund's avatar
Erik Faye-Lund committed
91
#endif /* PIMP_MOD_CONTEXT_H */