Better indentation so I can see something.

This commit is contained in:
evilynux 2007-01-08 21:12:48 +00:00
parent b79a3f067b
commit 9c85d0f3d0
1 changed files with 83 additions and 87 deletions

View File

@ -14,125 +14,121 @@ volatile BOOL execute = FALSE;
SDL_Surface * surface; SDL_Surface * surface;
SoundInterface_struct *SNDCoreList[] = { SoundInterface_struct *SNDCoreList[] = {
&SNDDummy, &SNDDummy,
&SNDFile, &SNDFile,
&SNDSDL, &SNDSDL,
NULL NULL
}; };
int Draw() { int Draw() {
SDL_Surface *rawImage; SDL_Surface *rawImage;
rawImage = SDL_CreateRGBSurfaceFrom((void*)&GPU_screen, 256, 384, 16, 512, 0x001F, 0x03E0, 0x7C00, 0); rawImage = SDL_CreateRGBSurfaceFrom((void*)&GPU_screen, 256, 384, 16, 512, 0x001F, 0x03E0, 0x7C00, 0);
if(rawImage == NULL) return 1; if(rawImage == NULL) return 1;
SDL_BlitSurface(rawImage, 0, surface, 0); SDL_BlitSurface(rawImage, 0, surface, 0);
SDL_UpdateRect(surface, 0, 0, 0, 0); SDL_UpdateRect(surface, 0, 0, 0, 0);
SDL_FreeSurface(rawImage); SDL_FreeSurface(rawImage);
return 1; return 1;
} }
int main(int argc, char ** argv) { int main(int argc, char ** argv) {
BOOL click; BOOL click;
unsigned short keypad; unsigned short keypad;
SDL_Event event; SDL_Event event;
int end = 0; int end = 0;
#ifdef DEBUG #ifdef DEBUG
LogStart(); LogStart();
#endif #endif
NDS_Init(); NDS_Init();
SPU_ChangeSoundCore(SNDCORE_SDL, 735 * 4); SPU_ChangeSoundCore(SNDCORE_SDL, 735 * 4);
if (argc < 2) { if (argc < 2) {
fprintf(stderr, "usage: %s filename\n", argv[0]); fprintf(stderr, "usage: %s filename\n", argv[0]);
return 1; return 1;
} }
if (NDS_LoadROM(argv[1], MC_TYPE_AUTODETECT, 1) < 0) { if (NDS_LoadROM(argv[1], MC_TYPE_AUTODETECT, 1) < 0) {
fprintf(stderr, "error while loading %s\n", argv[1]); fprintf(stderr, "error while loading %s\n", argv[1]);
return 2; return 2;
} }
/* // This has to get fixed yet /* // This has to get fixed yet
strcpy(szRomPath, dirname(argv[1])); strcpy(szRomPath, dirname(argv[1]));
cflash_close(); cflash_close();
cflash_init(); cflash_init();
*/ */
execute = TRUE; execute = TRUE;
SDL_Init(SDL_INIT_VIDEO); SDL_Init(SDL_INIT_VIDEO);
SDL_WM_SetCaption("Desmume SDL", NULL); SDL_WM_SetCaption("Desmume SDL", NULL);
surface = SDL_SetVideoMode(256, 384, 32, SDL_SWSURFACE); surface = SDL_SetVideoMode(256, 384, 32, SDL_SWSURFACE);
while(!end) {
while(!end) {
keypad=0x0000;
keypad=0x0000; Uint8 *keys;
keys = SDL_GetKeyState(NULL);
if(keys[SDLK_UP]) keypad |= 0x40;
if(keys[SDLK_DOWN]) keypad |= 0x80;
if(keys[SDLK_RIGHT]) keypad |= 0x10;
if(keys[SDLK_LEFT]) keypad |= 0x20;
if(keys[SDLK_SPACE]) keypad |= 0x1;
if(keys['b']) keypad |= 0x2;
if(keys[SDLK_BACKSPACE]) keypad |= 0x4;
if(keys[SDLK_RETURN]) keypad |= 0x8;
if(keys['0']) keypad |= 0x200;
if(keys['.']) keypad |= 0x100;
Uint8 *keys; ((unsigned short *)ARM9Mem.ARM9_REG)[0x130>>1] = ~keypad;
keys = SDL_GetKeyState(NULL); ((unsigned short *)MMU.ARM7_REG)[0x130>>1] = ~keypad;
if(keys[SDLK_UP]) keypad |= 0x40;
if(keys[SDLK_DOWN]) keypad |= 0x80;
if(keys[SDLK_RIGHT]) keypad |= 0x10;
if(keys[SDLK_LEFT]) keypad |= 0x20;
if(keys[SDLK_SPACE]) keypad |= 0x1;
if(keys['b']) keypad |= 0x2;
if(keys[SDLK_BACKSPACE]) keypad |= 0x4;
if(keys[SDLK_RETURN]) keypad |= 0x8;
if(keys['0']) keypad |= 0x200;
if(keys['.']) keypad |= 0x100;
((unsigned short *)ARM9Mem.ARM9_REG)[0x130>>1] = ~keypad;
((unsigned short *)MMU.ARM7_REG)[0x130>>1] = ~keypad;
if (SDL_PollEvent(&event)) { if (SDL_PollEvent(&event)) {
switch(event.type) { switch(event.type) {
case SDL_QUIT: case SDL_QUIT:
end = 1; end = 1;
break; break;
case SDL_MOUSEBUTTONDOWN: // Un bouton fut appuyé case SDL_MOUSEBUTTONDOWN: // Un bouton fut appuyé
if(event.button.button==1) click=TRUE; if(event.button.button==1) click=TRUE;
case SDL_MOUSEMOTION: // La souris a été déplacée sur l?écran case SDL_MOUSEMOTION: // La souris a été déplacée sur l?écran
if(!click) break; if(!click) break;
if(event.button.y>=192) if(event.button.y>=192)
{ {
signed long x = event.button.x; signed long x = event.button.x;
signed long y = event.button.y - 192; signed long y = event.button.y - 192;
if(x<0) x = 0; else if(x>255) x = 255; if(x<0) x = 0; else if(x>255) x = 255;
if(y<0) y = 0; else if(y>192) y = 192; if(y<0) y = 0; else if(y>192) y = 192;
NDS_setTouchPos(x, y); NDS_setTouchPos(x, y);
} }
break; break;
case SDL_MOUSEBUTTONUP: // Le bouton de la souris a été relaché case SDL_MOUSEBUTTONUP: // Le bouton de la souris a été relaché
if(click)NDS_releasTouch(); if(click)NDS_releasTouch();
click=FALSE; click=FALSE;
break; break;
} }
} }
NDS_exec(1120380, FALSE); NDS_exec(1120380, FALSE);
SPU_Emulate(); SPU_Emulate();
Draw(); Draw();
} }
SDL_Quit(); SDL_Quit();
NDS_DeInit(); NDS_DeInit();
#ifdef DEBUG #ifdef DEBUG
LogStop(); LogStop();
#endif #endif
return 0; return 0;
} }