example.cpp 912 Bytes
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

17
extern const u8  sample_bank[];
Erik Faye-Lund's avatar
Erik Faye-Lund committed
18
19
20
extern const u8  module[];


21
22
23
24
25
26
27
28
29
30
31
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
32

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

Erik Faye-Lund's avatar
Erik Faye-Lund committed
37
38
	BG_COLORS[0] = RGB5(0, 0, 0);
	BG_COLORS[241] = RGB5(31, 31, 31);
39
	REG_DISPCNT = MODE_0 | BG0_ON;
Erik Faye-Lund's avatar
Erik Faye-Lund committed
40
	
41
	pimp_init(module, sample_bank);
Erik Faye-Lund's avatar
Erik Faye-Lund committed
42

Erik Faye-Lund's avatar
Erik Faye-Lund committed
43
44
	SetInterrupt(IE_VBL, vblank);
	EnableInterrupt(IE_VBL);
Jørn Nystad's avatar
Jørn Nystad committed
45

46
47
48
49
	while (1)
	{
		VBlankIntrWait();
	}
Jørn Nystad's avatar
Jørn Nystad committed
50

51
52
	pimp_close();
}