example.cpp 1.33 KB
Newer Older
1
2
3
4
5
#include <gba_console.h>
#include <gba_video.h>
#include <gba_interrupt.h>
#include <gba_systemcalls.h>

Erik Faye-Lund's avatar
Erik Faye-Lund committed
6
7
8
9
#ifndef REG_WAITCNT
#define REG_WAITCNT (*(vu16*)(REG_BASE + 0x0204))
#endif

10
11
12
#include <stdio.h>
#include <assert.h>

13
14
#include "../include/pimpmobile.h"
#include "../src/mixer.h"
15
#include "../src/config.h"
16

Erik Faye-Lund's avatar
Erik Faye-Lund committed
17
18
extern const u8  sample[];
extern const u8  sample_end[];
19

Erik Faye-Lund's avatar
Erik Faye-Lund committed
20
21
22
extern const u8  module[];


23
24
25
26
27
28
29
30
31
32
33
void vblank()
{
	pimp_vblank();
	while (REG_VCOUNT != 0);
	pimp_frame();
}

int main()
{
//	REG_WAITCNT = 0x46d6; // lets set some cool waitstates...
	REG_WAITCNT = 0x46da; // lets set some cool waitstates...
Jørn Nystad's avatar
Jørn Nystad committed
34

35
36
37
	InitInterrupt();
	EnableInterrupt(IE_VBL);
	consoleInit(0, 4, 0, NULL, 0, 15);
Jørn Nystad's avatar
Jørn Nystad committed
38

Erik Faye-Lund's avatar
Erik Faye-Lund committed
39
40
	BG_COLORS[0] = RGB5(0, 0, 0);
	BG_COLORS[241] = RGB5(31, 31, 31);
41
	REG_DISPCNT = MODE_0 | BG0_ON;
Erik Faye-Lund's avatar
Erik Faye-Lund committed
42
43
	
	pimp_init((void*)&module[0], 0);
44

45
46
47
	mixer::sample_t mixer_sample;
	mixer_sample.data = sample;
	mixer_sample.len = &sample_end[0] - &sample[0];
Erik Faye-Lund's avatar
Erik Faye-Lund committed
48

49
	mixer_sample.loop_type = mixer::LOOP_TYPE_FORWARD;
50
51
	mixer_sample.loop_start = 0;
	mixer_sample.loop_end = (&sample_end[0] - &sample[0]);
Jørn Nystad's avatar
Jørn Nystad committed
52

53
	mixer::channels[0].sample_cursor = 0;
54
55
	mixer::channels[0].sample_cursor_delta = 1 << 12;
	mixer::channels[0].volume = 255;
56
	mixer::channels[0].sample = &mixer_sample;
Erik Faye-Lund's avatar
Erik Faye-Lund committed
57

Erik Faye-Lund's avatar
Erik Faye-Lund committed
58
59
	SetInterrupt(IE_VBL, vblank);
	EnableInterrupt(IE_VBL);
Jørn Nystad's avatar
Jørn Nystad committed
60

61
62
63
64
	while (1)
	{
		VBlankIntrWait();
	}
Jørn Nystad's avatar
Jørn Nystad committed
65

66
67
	pimp_close();
}