[SVN] r4082 - in trunk/SDL: src/haptic/nds src/joystick/nds src/video/nds test/nds-test-progs/sprite2 test/nds-test-progs/sprite2/source

svn-owner at libsdl.org svn-owner at libsdl.org
Fri Sep 5 21:31:35 PDT 2008


Author: lifning
Date: 2008-09-05 21:31:34 -0700 (Fri, 05 Sep 2008)
New Revision: 4082

Added:
   trunk/SDL/test/nds-test-progs/sprite2/icon.bmp
Modified:
   trunk/SDL/src/haptic/nds/SDL_syshaptic.c
   trunk/SDL/src/joystick/nds/SDL_sysjoystick.c
   trunk/SDL/src/video/nds/SDL_ndsevents.c
   trunk/SDL/test/nds-test-progs/sprite2/source/testsprite2.c
Log:
Fixes to the NDS sprite2 test.  Illustrates partially working texture-as-sprite functionality.

Modified: trunk/SDL/src/haptic/nds/SDL_syshaptic.c
===================================================================
--- trunk/SDL/src/haptic/nds/SDL_syshaptic.c	2008-09-06 00:10:16 UTC (rev 4081)
+++ trunk/SDL/src/haptic/nds/SDL_syshaptic.c	2008-09-06 04:31:34 UTC (rev 4082)
@@ -43,36 +43,57 @@
 } NDS_HapticData;
 
 
-
-void NDS_EZF_OpenNorWrite()
-{
-    GBA_BUS[0x0FF0000] = 0xD200;
-    GBA_BUS[0x0000000] = 0x1500;
-    GBA_BUS[0x0010000] = 0xD200;
-    GBA_BUS[0x0020000] = 0x1500;
-    GBA_BUS[0x0E20000] = 0x1500;
-    GBA_BUS[0x0FE0000] = 0x1500;
-}
-
-
-void NDS_EZF_CloseNorWrite()
-{
-    GBA_BUS[0x0FF0000] = 0xD200;
-    GBA_BUS[0x0000000] = 0x1500;
-    GBA_BUS[0x0010000] = 0xD200;
-    GBA_BUS[0x0020000] = 0x1500;
-    GBA_BUS[0x0E20000] = 0xD200;
-    GBA_BUS[0x0FE0000] = 0x1500;
+
+void
+NDS_EZF_OpenNorWrite() 
+{
+    
+GBA_BUS[0x0FF0000] = 0xD200;
+    
+GBA_BUS[0x0000000] = 0x1500;
+    
+GBA_BUS[0x0010000] = 0xD200;
+    
+GBA_BUS[0x0020000] = 0x1500;
+    
+GBA_BUS[0x0E20000] = 0x1500;
+    
+GBA_BUS[0x0FE0000] = 0x1500;
+
+} 
+
+
+void
+
+NDS_EZF_CloseNorWrite() 
+{
+    
+GBA_BUS[0x0FF0000] = 0xD200;
+    
+GBA_BUS[0x0000000] = 0x1500;
+    
+GBA_BUS[0x0010000] = 0xD200;
+    
+GBA_BUS[0x0020000] = 0x1500;
+    
+GBA_BUS[0x0E20000] = 0xD200;
+    
+GBA_BUS[0x0FE0000] = 0x1500;
+
 }
 
-void NDS_EZF_ChipReset()
-{
-    GBA_BUS[0x0000] = 0x00F0 ;
-    GBA_BUS[0x1000] = 0x00F0 ;
-}
-uint32 NDS_EZF_IsPresent()
-{
-    vuint16 id1,id2;
+void
+NDS_EZF_ChipReset()
+{
+    
+GBA_BUS[0x0000] = 0x00F0;
+    
+GBA_BUS[0x1000] = 0x00F0;
+} 
+uint32 NDS_EZF_IsPresent() 
+{
+    
+vuint16 id1, id2;
 
     NDS_EZF_OpenNorWrite();
 
@@ -82,40 +103,53 @@
     GBA_BUS[0x1555] = 0x00AA;
     GBA_BUS[0x12AA] = 0x0055;
     GBA_BUS[0x1555] = 0x0090;
-
-    id1 = GBA_BUS[0x0001];
-    id2 = GBA_BUS[0x1001];
-
-    if((id1!=0x227E)|| (id2!=0x227E)) {
-        NDS_EZF_CloseNorWrite();
-        return 0;
-    }
-
-    id1 = GBA_BUS[0x000E];
-    id2 = GBA_BUS[0x100E];
+    
+id1 = GBA_BUS[0x0001];
+    
+id2 = GBA_BUS[0x1001];
+    
+if ((id1 != 0x227E) || (id2 != 0x227E)) {
+        NDS_EZF_CloseNorWrite();
+        
+return 0;
+    }
+    
+
+id1 = GBA_BUS[0x000E];
+    
+id2 = GBA_BUS[0x100E];
 
     NDS_EZF_CloseNorWrite();
-
-    if(id1==0x2218 && id2==0x2218) {
-        return 1;
+    
+if (id1 == 0x2218 && id2 == 0x2218) {
+        
+return 1;
     }
-
-    return 0;
+    
+return 0;
+
 }
-
-void NDS_EZF_SetShake(u8 pos)
+
+void
+NDS_EZF_SetShake(u8 pos) 
 {
-    u16 data = ((pos%3)|0x00F0);
-
-    GBA_BUS[0x0FF0000] = 0xD200;
-    GBA_BUS[0x0000000] = 0x1500;
-    GBA_BUS[0x0010000] = 0xD200;
-    GBA_BUS[0x0020000] = 0x1500;
-    GBA_BUS[0x0F10000] = data;
-    GBA_BUS[0x0FE0000] = 0x1500;
+    u16 data = ((pos % 3) | 0x00F0);
+    
+GBA_BUS[0x0FF0000] = 0xD200;
+    
+GBA_BUS[0x0000000] = 0x1500;
+    
+GBA_BUS[0x0010000] = 0xD200;
+    
+GBA_BUS[0x0020000] = 0x1500;
+    
+GBA_BUS[0x0F10000] = data;
+    
+GBA_BUS[0x0FE0000] = 0x1500;
 
-    GBA_BUS[0] = 0x0000; /* write any value for vibration. */
-    GBA_BUS[0] = 0x0002;
+    GBA_BUS[0] = 0x0000;        /* write any value for vibration. */
+    GBA_BUS[0] = 0x0002;
+
 }
 
 static int
@@ -130,11 +164,11 @@
 SDL_SYS_HapticInit(void)
 {
     int ret = 0;
-    if(isRumbleInserted()) {
+    if (isRumbleInserted()) {
         /* official rumble pak is present. */
         ret = 1;
         printf("debug: haptic present: nintendo\n");
-    } else if(NDS_EZF_IsPresent()) {
+    } else if (NDS_EZF_IsPresent()) {
         /* ezflash 3-in-1 pak is present. */
         ret = 1;
         printf("debug: haptic present: ezf3in1\n");
@@ -150,11 +184,14 @@
 const char *
 SDL_SYS_HapticName(int index)
 {
-    if(nds_haptic) {
-        switch(nds_haptic->hwdata->type) {
-            case OFFICIAL: return "Nintendo DS Rumble Pak";
-            case EZF3IN1: return "EZFlash 3-in-1 Rumble";
-            default: return NULL;
+    if (nds_haptic) {
+        switch (nds_haptic->hwdata->type) {
+        case OFFICIAL:
+            return "Nintendo DS Rumble Pak";
+        case EZF3IN1:
+            return "EZFlash 3-in-1 Rumble";
+        default:
+            return NULL;
         }
     }
     return NULL;
@@ -164,12 +201,12 @@
 int
 SDL_SYS_HapticOpen(SDL_Haptic * haptic)
 {
-    if(!haptic) {
+    if (!haptic) {
         return -1;
     }
 
     haptic->hwdata = SDL_malloc(sizeof(NDS_HapticData));
-    if(!haptic->hwdata) {
+    if (!haptic->hwdata) {
         SDL_OutOfMemory();
         return -1;
     }
@@ -179,10 +216,10 @@
 
     /* determine what is here, if anything */
     haptic->hwdata->type = NONE;
-    if(isRumbleInserted()) {
+    if (isRumbleInserted()) {
         /* official rumble pak is present. */
         haptic->hwdata->type = OFFICIAL;
-    } else if(NDS_EZF_IsPresent()) {
+    } else if (NDS_EZF_IsPresent()) {
         /* ezflash 3-in-1 pak is present. */
         haptic->hwdata->type = EZF3IN1;
         NDS_EZF_ChipReset();
@@ -213,7 +250,7 @@
 int
 SDL_SYS_HapticOpenFromJoystick(SDL_Haptic * haptic, SDL_Joystick * joystick)
 {
-    /*SDL_SYS_LogicError();*/
+    /*SDL_SYS_LogicError(); */
     return -1;
 }
 

Modified: trunk/SDL/src/joystick/nds/SDL_sysjoystick.c
===================================================================
--- trunk/SDL/src/joystick/nds/SDL_sysjoystick.c	2008-09-06 00:10:16 UTC (rev 4081)
+++ trunk/SDL/src/joystick/nds/SDL_sysjoystick.c	2008-09-06 04:31:34 UTC (rev 4082)
@@ -44,8 +44,9 @@
 int
 SDL_SYS_JoystickInit(void)
 {
-    SDL_numjoysticks = 1;
-    return (1);
+    SDL_numjoysticks = 1;
+    
+return (1);
 }
 
 /* Function to get the device-dependent name of a joystick */
@@ -79,14 +80,14 @@
  * but instead should call SDL_PrivateJoystick*() to deliver events
  * and update joystick device state.
  */
-void
+    void
 SDL_SYS_JoystickUpdate(SDL_Joystick * joystick)
 {
     u32 keysd, keysu;
     int magnitude = 16384;
     
-    /*scanKeys(); - this is done in PumpEvents, because touch uses it too */
-    keysd = keysDown();
+        /*scanKeys(); - this is done in PumpEvents, because touch uses it too */ 
+        keysd = keysDown();
     keysu = keysUp();
 
     if ((keysd & KEY_UP)) {
@@ -101,76 +102,76 @@
     if ((keysd & KEY_RIGHT)) {
         SDL_PrivateJoystickAxis(joystick, 0, magnitude);
     }
-
-    if ((keysu & (KEY_UP | KEY_DOWN))) {
+    
+if ((keysu & (KEY_UP | KEY_DOWN))) {
         SDL_PrivateJoystickAxis(joystick, 1, 0);
     }
-
-    if ((keysu & (KEY_LEFT | KEY_RIGHT))) {
+    
+if ((keysu & (KEY_LEFT | KEY_RIGHT))) {
         SDL_PrivateJoystickAxis(joystick, 0, 0);
     }
     
-    if ((keysd & KEY_A)) {
+if ((keysd & KEY_A)) {
         SDL_PrivateJoystickButton(joystick, 0, SDL_PRESSED);
     }
     
-    if ((keysd & KEY_B)) {
+if ((keysd & KEY_B)) {
         SDL_PrivateJoystickButton(joystick, 1, SDL_PRESSED);
     }
     
-    if ((keysd & KEY_X)) {
+if ((keysd & KEY_X)) {
         SDL_PrivateJoystickButton(joystick, 2, SDL_PRESSED);
     }
     
-    if ((keysd & KEY_Y)) {
+if ((keysd & KEY_Y)) {
         SDL_PrivateJoystickButton(joystick, 3, SDL_PRESSED);
     }
     
-    if ((keysd & KEY_L)) {
+if ((keysd & KEY_L)) {
         SDL_PrivateJoystickButton(joystick, 4, SDL_PRESSED);
     }
     
-    if ((keysd & KEY_R)) {
+if ((keysd & KEY_R)) {
         SDL_PrivateJoystickButton(joystick, 5, SDL_PRESSED);
     }
     
-    if ((keysd & KEY_SELECT)) {
+if ((keysd & KEY_SELECT)) {
         SDL_PrivateJoystickButton(joystick, 6, SDL_PRESSED);
     }
     
-    if ((keysd & KEY_START)) {
+if ((keysd & KEY_START)) {
         SDL_PrivateJoystickButton(joystick, 7, SDL_PRESSED);
     }
     
-    if ((keysu & KEY_A)) {
+if ((keysu & KEY_A)) {
         SDL_PrivateJoystickButton(joystick, 0, SDL_RELEASED);
     }
     
-    if ((keysu & KEY_B)) {
+if ((keysu & KEY_B)) {
         SDL_PrivateJoystickButton(joystick, 1, SDL_RELEASED);
     }
     
-    if ((keysu & KEY_X)) {
+if ((keysu & KEY_X)) {
         SDL_PrivateJoystickButton(joystick, 2, SDL_RELEASED);
     }
     
-    if ((keysu & KEY_Y)) {
+if ((keysu & KEY_Y)) {
         SDL_PrivateJoystickButton(joystick, 3, SDL_RELEASED);
     }
     
-    if ((keysu & KEY_L)) {
+if ((keysu & KEY_L)) {
         SDL_PrivateJoystickButton(joystick, 4, SDL_RELEASED);
     }
     
-    if ((keysu & KEY_R)) {
+if ((keysu & KEY_R)) {
         SDL_PrivateJoystickButton(joystick, 5, SDL_RELEASED);
     }
     
-    if ((keysu & KEY_SELECT)) {
+if ((keysu & KEY_SELECT)) {
         SDL_PrivateJoystickButton(joystick, 6, SDL_RELEASED);
     }
     
-    if ((keysu & KEY_START)) {
+if ((keysu & KEY_START)) {
         SDL_PrivateJoystickButton(joystick, 7, SDL_RELEASED);
     }
 
@@ -189,4 +190,3 @@
 }
 
 #endif /* SDL_JOYSTICK_NDS */
-

Modified: trunk/SDL/src/video/nds/SDL_ndsevents.c
===================================================================
--- trunk/SDL/src/video/nds/SDL_ndsevents.c	2008-09-06 00:10:16 UTC (rev 4081)
+++ trunk/SDL/src/video/nds/SDL_ndsevents.c	2008-09-06 04:31:34 UTC (rev 4082)
@@ -47,8 +47,8 @@
     }
     if (keysHeld() & KEY_TOUCH) {
         touchPosition t = touchReadXY();
-        SDL_SendMouseMotion(0, 0, t.px, t.py, 1); /* last arg is pressure,
-                                                     hardcoded 1 for now */
+        SDL_SendMouseMotion(0, 0, t.px, t.py, 1);       /* last arg is pressure,
+                                                           hardcoded 1 for now */
     }
 }
 

Added: trunk/SDL/test/nds-test-progs/sprite2/icon.bmp
===================================================================
(Binary files differ)


Property changes on: trunk/SDL/test/nds-test-progs/sprite2/icon.bmp
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Modified: trunk/SDL/test/nds-test-progs/sprite2/source/testsprite2.c
===================================================================
--- trunk/SDL/test/nds-test-progs/sprite2/source/testsprite2.c	2008-09-06 00:10:16 UTC (rev 4081)
+++ trunk/SDL/test/nds-test-progs/sprite2/source/testsprite2.c	2008-09-06 04:31:34 UTC (rev 4082)
@@ -7,8 +7,6 @@
 #include <fat.h>
 #include "common.h"
 
-#include "icon_bmp_bin.h"
-
 #define NUM_SPRITES	10
 #define MAX_SPEED 	1
 
@@ -184,66 +182,7 @@
     if (!state) {
         return 1;
     }
-    for (i = 1; i < argc;) {
-        int consumed;
 
-        consumed = CommonArg(state, i);
-        if (consumed == 0) {
-            consumed = -1;
-            if (SDL_strcasecmp(argv[i], "--blend") == 0) {
-                if (argv[i + 1]) {
-                    if (SDL_strcasecmp(argv[i + 1], "none") == 0) {
-                        blendMode = SDL_TEXTUREBLENDMODE_NONE;
-                        consumed = 2;
-                    } else if (SDL_strcasecmp(argv[i + 1], "mask") == 0) {
-                        blendMode = SDL_TEXTUREBLENDMODE_MASK;
-                        consumed = 2;
-                    } else if (SDL_strcasecmp(argv[i + 1], "blend") == 0) {
-                        blendMode = SDL_TEXTUREBLENDMODE_BLEND;
-                        consumed = 2;
-                    } else if (SDL_strcasecmp(argv[i + 1], "add") == 0) {
-                        blendMode = SDL_TEXTUREBLENDMODE_ADD;
-                        consumed = 2;
-                    } else if (SDL_strcasecmp(argv[i + 1], "mod") == 0) {
-                        blendMode = SDL_TEXTUREBLENDMODE_MOD;
-                        consumed = 2;
-                    }
-                }
-            } else if (SDL_strcasecmp(argv[i], "--scale") == 0) {
-                if (argv[i + 1]) {
-                    if (SDL_strcasecmp(argv[i + 1], "none") == 0) {
-                        scaleMode = SDL_TEXTURESCALEMODE_NONE;
-                        consumed = 2;
-                    } else if (SDL_strcasecmp(argv[i + 1], "fast") == 0) {
-                        scaleMode = SDL_TEXTURESCALEMODE_FAST;
-                        consumed = 2;
-                    } else if (SDL_strcasecmp(argv[i + 1], "slow") == 0) {
-                        scaleMode = SDL_TEXTURESCALEMODE_SLOW;
-                        consumed = 2;
-                    } else if (SDL_strcasecmp(argv[i + 1], "best") == 0) {
-                        scaleMode = SDL_TEXTURESCALEMODE_BEST;
-                        consumed = 2;
-                    }
-                }
-            } else if (SDL_strcasecmp(argv[i], "--cyclecolor") == 0) {
-                cycle_color = SDL_TRUE;
-                consumed = 1;
-            } else if (SDL_strcasecmp(argv[i], "--cyclealpha") == 0) {
-                cycle_alpha = SDL_TRUE;
-                consumed = 1;
-            } else if (SDL_isdigit(*argv[i])) {
-                num_sprites = SDL_atoi(argv[i]);
-                consumed = 1;
-            }
-        }
-        if (consumed < 0) {
-            fprintf(stderr,
-                    "Usage: %s %s [--blend none|mask|blend|add|mod] [--scale none|fast|slow|best] [--cyclecolor] [--cyclealpha]\n",
-                    argv[0], CommonUsage(state));
-            quit(1);
-        }
-        i += consumed;
-    }
     if (!CommonInit(state)) {
         quit(2);
     }
@@ -259,8 +198,9 @@
         SDL_SelectRenderer(state->windows[i]);
         SDL_RenderFill(0xA0, 0xA0, 0xA0, 0xFF, NULL);
     }
-    if (LoadSprite2(icon_bmp_bin, icon_bmp_bin_size) < 0) {
-        printf("errored.\n");
+    if (LoadSprite("icon.bmp") < 0) {
+        printf("\nerrored.\n");
+        while (1);
         quit(2);
     }
 



More information about the SVN mailing list