example.cpp 1.41 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(module, 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
52
//	mixer_sample.loop_type = mixer::LOOP_TYPE_NONE;
	mixer_sample.loop_start = 0xF220;
	mixer_sample.loop_end = mixer_sample.loop_start + 0xd76; // (&sample_end[0] - &sample[0]);
Jørn Nystad's avatar
Jørn Nystad committed
53

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

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

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

67
68
	pimp_close();
}