comparison test/nds-test-progs/general/source/main.c @ 2694:c1c7cb1b5a47 gsoc2008_nds

More sprite-work in the render driver, and some updates to the nds-test-progs.
author Darren Alton <dalton@stevens.edu>
date Sat, 16 Aug 2008 12:58:36 +0000
parents cd8978f47849
children 0b395a60deff
comparison
equal deleted inserted replaced
2693:bae97b6ac32b 2694:c1c7cb1b5a47
1 1
2 #include <SDL/SDL.h> 2 #include <SDL/SDL.h>
3 #if defined(NDS) || defined(__NDS__) || defined (__NDS) 3 #if defined(NDS) || defined(__NDS__) || defined (__NDS)
4 #include <nds.h> 4 #include <nds.h>
5 #include <fat.h>
5 #else 6 #else
6 #define swiWaitForVBlank() 7 #define swiWaitForVBlank()
7 #define consoleDemoInit() 8 #define consoleDemoInit()
9 #define fatInitDefault()
8 #define RGB15(r,g,b) SDL_MapRGB(screen->format,((r)<<3),((g)<<3),((b)<<3)) 10 #define RGB15(r,g,b) SDL_MapRGB(screen->format,((r)<<3),((g)<<3),((b)<<3))
9 #endif 11 #endif
10 12
11 void delay(int s) { 13 void splash(SDL_Surface *screen, int s) {
14 SDL_Surface *logo;
15 SDL_Rect area = {0,0,256,192};
16
17 logo = SDL_LoadBMP("sdl.bmp");
18 if(!logo) {
19 printf("Couldn't splash.\n");
20 return;
21 }
22 /*logo->flags &= ~SDL_PREALLOC;*/
23 SDL_BlitSurface(logo, NULL, screen, &area);
24 SDL_Flip(screen);
12 while(s-- > 0) { 25 while(s-- > 0) {
13 int i = 60; 26 int i = 60;
14 while(--i) swiWaitForVBlank(); 27 while(--i) swiWaitForVBlank();
15 } 28 }
16 } 29 }
20 SDL_Joystick *stick; 33 SDL_Joystick *stick;
21 SDL_Event event; 34 SDL_Event event;
22 SDL_Rect rect = {8,8,240,176}; 35 SDL_Rect rect = {8,8,240,176};
23 int i; 36 int i;
24 37
25 consoleDemoInit(); 38 consoleDemoInit(); puts("Hello world! Initializing FAT...");
39 fatInitDefault();
26 if(SDL_Init(SDL_INIT_VIDEO|SDL_INIT_JOYSTICK) < 0) { 40 if(SDL_Init(SDL_INIT_VIDEO|SDL_INIT_JOYSTICK) < 0) {
27 puts("# error initializing SDL"); 41 puts("# error initializing SDL");
28 puts(SDL_GetError()); 42 puts(SDL_GetError());
29 return 1; 43 return 1;
30 } 44 }
42 puts("# error opening joystick"); 56 puts("# error opening joystick");
43 puts(SDL_GetError()); 57 puts(SDL_GetError());
44 // return 3; 58 // return 3;
45 } 59 }
46 puts("* opened joystick"); 60 puts("* opened joystick");
61
62 /*splash(screen, 3);*/
63
47 SDL_FillRect(screen, &rect, RGB15(0,0,31)|0x8000); 64 SDL_FillRect(screen, &rect, RGB15(0,0,31)|0x8000);
48 SDL_Flip(screen); 65 SDL_Flip(screen);
49 66
50 while(1) 67 while(1)
51 while(SDL_PollEvent(&event)) 68 while(SDL_PollEvent(&event))
64 case 3: 81 case 3:
65 SDL_FillRect(screen, &rect, RGB15(0,0,0)|0x8000); 82 SDL_FillRect(screen, &rect, RGB15(0,0,0)|0x8000);
66 break; 83 break;
67 default: break; 84 default: break;
68 } 85 }
69 printf("joy_%d\n", event.jbutton.which); 86 printf("joy_%d, at %d\n", event.jbutton.which, SDL_GetTicks());
70 SDL_Flip(screen); 87 SDL_Flip(screen);
71 break; 88 break;
72 case SDL_QUIT: SDL_Quit(); return 0; 89 case SDL_QUIT: SDL_Quit(); return 0;
73 default: break; 90 default: break;
74 } 91 }