pimp_module.h 1.83 KB
Newer Older
1
2
3
4
5
/* pimp_module.h -- module data structure and getter functions
 * Copyright (C) 2005-2006 Jrn Nystad and Erik Faye-Lund
 * For conditions of distribution and use, see copyright notice in LICENSE.TXT
 */

6
7
8
9
10
#ifndef PIMP_MODULE_H
#define PIMP_MODULE_H

#include "pimp_instrument.h"

11
12
13
14
15
16
17
18
19
20
21
22
23
24
typedef struct
{
	u32 data_ptr;
	u16 row_count;
} pimp_pattern;

/* packed, because it's all bytes. no member-alignment or anything needed */
typedef struct __attribute__((packed))
{
	u8 pan;
	u8 volume;
	u8 mute;
} pimp_channel;

25
26
27
28
29
30
31
typedef struct
{
	char name[32];
	
	u32 flags;
	u32 reserved; /* for future flags */
	
32
	/* these are offsets relative to the begining of the pimp_module_t-structure */
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
	u32 order_ptr;
	u32 pattern_ptr;
	u32 channel_ptr;
	u32 instrument_ptr;
	
	u16 period_low_clamp;
	u16 period_high_clamp;
	u16 order_count;
	
	u8  order_repeat;
	u8  volume;
	u8  tempo;
	u8  bpm;
	
	u8  instrument_count;
	u8  pattern_count;
	u8  channel_count;
} pimp_module;

52
53
54
55
56
57
58
59
60
61
#include "pimp_debug.h"
#include "pimp_internal.h"

/* pattern entry */
STATIC INLINE pimp_pattern_entry *get_pattern_data(pimp_pattern *pat)
{
	ASSERT(pat != NULL);
	return (pimp_pattern_entry*)get_ptr(&pat->data_ptr);
}

Erik Faye-Lund's avatar
Erik Faye-Lund committed
62
STATIC INLINE int __pimp_module_get_order(const pimp_module *mod, int i)
63
64
65
66
67
{
	ASSERT(mod != NULL);
	return ((char*)get_ptr(&mod->order_ptr))[i];
}

Erik Faye-Lund's avatar
Erik Faye-Lund committed
68
STATIC INLINE pimp_pattern *__pimp_module_get_pattern(const pimp_module *mod, int i)
69
70
71
72
73
{
	ASSERT(mod != NULL);
	return &((pimp_pattern*)get_ptr(&mod->pattern_ptr))[i];
}

Erik Faye-Lund's avatar
Erik Faye-Lund committed
74
STATIC INLINE pimp_channel *__pimp_module_get_channel(const pimp_module *mod, int i)
75
76
{
	ASSERT(mod != NULL);
Erik Faye-Lund's avatar
Erik Faye-Lund committed
77
	return &((pimp_channel*)get_ptr(&mod->channel_ptr))[i];
78
79
}

Erik Faye-Lund's avatar
Erik Faye-Lund committed
80
STATIC INLINE pimp_instrument *__pimp_module_get_instrument(const pimp_module *mod, int i)
81
82
83
84
85
{
	ASSERT(mod != NULL);
	return &((pimp_instrument*)get_ptr(&mod->instrument_ptr))[i];
}

86
#endif /* PIMP_MODULE_H */