example.cpp 949 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
18
extern const u8  sample_bank[];
extern const u8  sample_bank_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, sample_bank);
Erik Faye-Lund's avatar
Erik Faye-Lund committed
44

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

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

53
54
	pimp_close();
}