Esempio n. 1
0
static struct pimp_module *load_module(const char *filename, struct pimp_sample_bank *sample_bank)
{
	struct pimp_module *mod;
	
	/* open file */
	FILE *fp = fopen(filename, "rb");
	if (!fp)
	{
		perror(filename);
		exit(EXIT_FAILURE);
	}
	
	/* try to load */
	mod = load_module_xm(fp, sample_bank);
	if (NULL == mod) mod = load_module_mod(fp, sample_bank);
		
	/* report error if any */
	if (NULL == mod)
	{
		if (errno) fprintf(stderr, "%s: Failed to load module, %s\n", filename, strerror(errno));
		else       fprintf(stderr, "%s: Failed to load module\n", filename);
		exit(EXIT_FAILURE);
	}
	
	/* close file */
	fclose(fp);
	fp = NULL;
	
	/* get back on track */
	return mod;
}
Esempio n. 2
0
int main()
{
//	REG_WAITCNT = 0x46d6; // lets set some cool waitstates...
	REG_WAITCNT = 0x46da; // lets set some cool waitstates...
	
	irqInit();
	irqEnable(IRQ_VBLANK);
	consoleInit(0, 4, 0, NULL, 0, 15);

	BG_COLORS[0] = RGB5(0, 0, 0);
	BG_COLORS[241] = RGB5(31, 31, 31);
	REG_DISPCNT = MODE_0 | BG0_ON;

	gbfs_init(1);
	
	pimp_sample_bank sb;
	FILE *fp = fopen("dxn-oopk.xm", "rb");
	if (!fp)
	{
		fprintf(stderr, "file not found\n");
		return 1;
	}
	pimp_module *mod = load_module_xm(fp, &sb);
	fclose(fp);
	fp = NULL;
	
	if (NULL == mod)
	{
		fprintf(stderr, "failed to load module\n");
		return 1;
	}

	pimp_gba_init(mod, sb.data);
	pimp_gba_set_callback(callback);

	irqSet(IRQ_TIMER3, timer3);
	irqEnable(IRQ_TIMER3);
	REG_TM3CNT_L = 0;
	REG_TM3CNT_H = TIMER_START | TIMER_IRQ | 2;
	
	irqSet(IRQ_VBLANK, vblank);
	irqEnable(IRQ_VBLANK);
	
	while (1)
	{
		VBlankIntrWait();
		scanKeys();
		int keys = keysDown();
		if (keys & KEY_UP)    pimp_gba_set_pos(0, pimp_gba_get_order() - 1);
		if (keys & KEY_DOWN)  pimp_gba_set_pos(0, pimp_gba_get_order() + 1);
		if (keys & KEY_RIGHT) pimp_gba_set_pos(pimp_gba_get_row() + 8, pimp_gba_get_order());
		if (keys & KEY_LEFT)  pimp_gba_set_pos(pimp_gba_get_row() - 8, pimp_gba_get_order());
		iprintf("%d %d\n", pimp_gba_get_order(), pimp_gba_get_row());
	}
	
	pimp_gba_close();
	return 0;
}