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

#include <stdio.h>
#include <assert.h>

9
10
#include "../include/pimpmobile.h"
#include "../src/mixer.h"
11
#include "../src/config.h"
12

Erik Faye-Lund's avatar
Erik Faye-Lund committed
13
14
extern const u8  sample[];
extern const u8  sample_end[];
15
16
17
18
19
20

void vblank()
{
	BG_COLORS[0] = RGB5(0, 0, 31);
	pimp_vblank();
	BG_COLORS[0] = RGB5(0, 0, 0);
Jørn Nystad's avatar
Jørn Nystad committed
21

22
	while (REG_VCOUNT != 0);
Erik Faye-Lund's avatar
Erik Faye-Lund committed
23
//	while (REG_VCOUNT != 100);
Jørn Nystad's avatar
Jørn Nystad committed
24

25
26
27
28
29
30
31
	BG_COLORS[0] = RGB5(0, 31, 0);
	pimp_frame();
	BG_COLORS[0] = RGB5(0, 0, 0);
}

const u8 samp_data[2] IWRAM_DATA = {0, 255};

Erik Faye-Lund's avatar
Erik Faye-Lund committed
32
#define REG_WAITCNT *(vu16*)(REG_BASE + 0x0204)
33
34
35
36
37

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
38

39
40
41
	InitInterrupt();
	EnableInterrupt(IE_VBL);
	consoleInit(0, 4, 0, NULL, 0, 15);
Jørn Nystad's avatar
Jørn Nystad committed
42

43
44
45
	BG_COLORS[0]=RGB5(0, 0, 0);
	BG_COLORS[241]=RGB5(31, 31, 31);
	REG_DISPCNT = MODE_0 | BG0_ON;
Jørn Nystad's avatar
Jørn Nystad committed
46

47
	pimp_init(0, 0);
48

49
50
51
	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
52
53
54
55

/*	mixer_sample.data = samp_data;
	mixer_sample.len = 2; */

56
	mixer_sample.loop_type = mixer::LOOP_TYPE_FORWARD;
57
58
	mixer_sample.loop_start = 0;
	mixer_sample.loop_end = (&sample_end[0] - &sample[0]);
Jørn Nystad's avatar
Jørn Nystad committed
59

60
	mixer::channels[0].sample_cursor = 0;
61
62
	mixer::channels[0].sample_cursor_delta = 1 << 12;
	mixer::channels[0].volume = 255;
63
	mixer::channels[0].sample = &mixer_sample;
64
65
	
	iprintf("%i\n", SOUND_BUFFER_SIZE);
Jørn Nystad's avatar
Jørn Nystad committed
66

Erik Faye-Lund's avatar
Erik Faye-Lund committed
67
68
69
70
71
72
73
74
/*
	mixer::channels[1].sample_cursor = 0;
	mixer::channels[1].sample_cursor_delta = 5 << 10;
	mixer::channels[1].volume = 64;
	mixer::channels[1].sample = &mixer_sample;
*/
	SetInterrupt(IE_VBL, vblank);
	EnableInterrupt(IE_VBL);
Jørn Nystad's avatar
Jørn Nystad committed
75

76
77
78
79
	while (1)
	{
		VBlankIntrWait();
	}
Jørn Nystad's avatar
Jørn Nystad committed
80

81
82
	pimp_close();
}