example.cpp 1.13 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
#include "gbfs.h"
17

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


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

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

Erik Faye-Lund's avatar
Erik Faye-Lund committed
38
39
	BG_COLORS[0] = RGB5(0, 0, 0);
	BG_COLORS[241] = RGB5(31, 31, 31);
40
	REG_DISPCNT = MODE_0 | BG0_ON;
Erik Faye-Lund's avatar
Erik Faye-Lund committed
41
	
42
43
44
45
46
47
	GBFS_FILE const* gbfs_file = find_first_gbfs_file((void*)0x08000000);
	
	const void *mod = gbfs_get_obj(gbfs_file, "rhino.mod.bin", 0);
	const void *sb  = gbfs_get_obj(gbfs_file, "sample_bank.bin", 0);
	iprintf("\n\n %i %i\n", mod, sb);
	pimp_init(mod, sb);
Erik Faye-Lund's avatar
Erik Faye-Lund committed
48

Erik Faye-Lund's avatar
Erik Faye-Lund committed
49
50
	SetInterrupt(IE_VBL, vblank);
	EnableInterrupt(IE_VBL);
Jørn Nystad's avatar
Jørn Nystad committed
51

52
53
54
55
	while (1)
	{
		VBlankIntrWait();
	}
Jørn Nystad's avatar
Jørn Nystad committed
56

57
58
	pimp_close();
}