File: main.cpp

package info (click to toggle)
desmume 0.9.13-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 52,116 kB
  • sloc: cpp: 263,638; ansic: 193,550; asm: 3,077; makefile: 1,324; python: 177; sh: 112; javascript: 89; xml: 72; objc: 7
file content (104 lines) | stat: -rw-r--r-- 2,696 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
/* 	Matrix Stack test

	Copyright 2010 DeSmuME team

    This file is part of DeSmuME

    DeSmuME is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    DeSmuME is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with DeSmuME; if not, write to the Free Software
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
*/
#include <nds.h>
#include <stdio.h>

GL_MATRIX_MODE_ENUM modes[4] = {GL_PROJECTION, GL_POSITION, GL_MODELVIEW, GL_TEXTURE};
char	*modesTXT[4] = {"PROJECTION", "POSITION", "MODELVIEW", "TEXTURE"};

PrintConsole *scr = consoleDemoInit();

s32 POPstep = 0;
u32 mode = 0;
u32 POPs = 0, PUSHes = 0;
//---------------------------------------------------------------------------------
int main(void) {
//---------------------------------------------------------------------------------
	int keys;
	videoSetModeSub(MODE_0_2D);
	videoSetMode(MODE_0_3D);
	
	vramSetBankA(VRAM_A_MAIN_BG);
	vramSetBankC(VRAM_C_SUB_BG);

	consoleInit(scr, 3, BgType_Text4bpp, BgSize_T_256x256, 31, 0, false, true);
	
	glInit();
	glMatrixMode(GL_PROJECTION);
	glFlush(0);
	
	POPstep=0;
	mode = 0;
	POPs = 0;
	PUSHes = 0;

	while(1) {
		scanKeys();
		keys = keysDown();
		if(keys & KEY_A) 
		{
			glPushMatrix();
			PUSHes++;
		}
		if(keys & KEY_B) 
		{
			glPopMatrix(POPstep);
			POPs++;
		}
		if(keys & KEY_X)
		{
			mode++;
			if (mode > 3) mode = 0;
			glMatrixMode(modes[mode]);
		}
		
		if(keys & KEY_UP)
		{
			if (POPstep < 31) POPstep += 1;
		}
		if(keys & KEY_DOWN)
		{
			if (POPstep > -30) POPstep -= 1;
		}
			
		consoleClear();
		iprintf("Matrix mode = %i:%s\n", mode, modesTXT[mode]);
		iprintf("\n");
		iprintf("GFX STATUS  = 0x%08X\n", GFX_STATUS);
		iprintf("\t - Pos&Vec level  = %i\n", (GFX_STATUS>>8)&0x1F);
		iprintf("\t - Proj.   level  = %i\n", (GFX_STATUS>>13)&0x01);
		iprintf("\t - Error %s\n", (GFX_STATUS>>15)&0x01?"YES":"no");
		iprintf("\n");
		iprintf("POP step    = %i\n", POPstep);
		iprintf("POP count    = %i\n", POPs);
		iprintf("PUSH count   = %i\n", PUSHes);
		
		iprintf("\n");
		iprintf("A\t - PUSH\n");
		iprintf("B\t - POP\n");
		iprintf("UP\t- POP increment step\n");
		iprintf("DOWN - POP decrement step\n");
		iprintf("X\t - Change mode\n");
		swiWaitForVBlank();
	}

	return 0;
}