gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

DS development > 3D and WiFi not happy together

#140570 - Schmedly - Mon Sep 17, 2007 6:50 pm

Okay, I'm still fairly new to the DS homebrew scene, but up to now I've had good luck. I have ported a skeleton of my 3D game which works fine on it's own, and I've also had no problems working with the small WiFi example. But, after using the WiFi template and adding my 3D source to the arm9 project, I no longer get any updates on the top screen (the 3D portion). The bottom screen still shows all my debug info and the frame counter, just no 3D on the top screen.

NetworkInit() contains the same code as the WiFi sample (works fine and connects to AP) but does not call irqInit().

RenderInit() just does a bit of graphics setup.

RenderScene() does all the major drawing, and works perfectly in a project without the WiFi code.

Code:
int main()
{   
   videoSetMode(MODE_0_3D);
   videoSetModeSub(MODE_0_2D | DISPLAY_BG0_ACTIVE);
   vramSetMainBanks(VRAM_A_TEXTURE_SLOT0, VRAM_B_LCD, VRAM_C_LCD, VRAM_D_LCD);
   vramSetBankC(VRAM_C_SUB_BG);
   
   SUB_BG0_CR = BG_MAP_BASE(31);
   BG_PALETTE_SUB[255] = RGB15(31,31,31);

   consoleInitDefault((u16*)SCREEN_BASE_BLOCK_SUB(31), (u16*)CHAR_BASE_BLOCK_SUB(0), 16);

   iprintf("DemoApp\n");

   irqInit();
   irqSet(IRQ_VBLANK, Vblank);
   irqEnable(IRQ_VBLANK);

   NetworkInit();

   RenderInit();

   while (!quit)
   {
      scanKeys();
      keys = keysHeld();

      if((keys & KEY_START)) quit = true;

      if((keys & KEY_UP)) camera.Translate( Math::Vec3( 0.0f, 0.0f, -0.1f) );
      if((keys & KEY_DOWN)) camera.Translate( Math::Vec3( 0.0f, 0.0f, 0.1f) );
      if((keys & KEY_LEFT)) camera.MoveRight( -0.1f );
      if((keys & KEY_RIGHT)) camera.MoveRight( 0.1f );

      keys = keysDown();
      if((keys & KEY_SELECT))
      {
         mode++;
         if( mode > 1 )
            mode = 0;
      }

      if((keys & KEY_X))
      {
         int numAP = Wifi_GetNumAP();

         if( numAP > 0 )
         {
            iprintf("\x1b[10;0HAccess Points\n");
            for( int i = 0; i < numAP; ++i )
            {
               Wifi_AccessPoint myAP;
               Wifi_GetAPData(i, &myAP);
               iprintf("%d:%s\n", i, myAP.ssid);
            }
         }
      }

      touchXY=touchReadXY();

      Math::Vec3 camX( camera.frame.m[0], camera.frame.m[1], camera.frame.m[2] );
      Math::Vec3 camY( camera.frame.m[4], camera.frame.m[5], camera.frame.m[6] );
      Math::Vec3 camZ( camera.frame.m[8], camera.frame.m[9], camera.frame.m[10] );
      Math::Vec3 camT( camera.frame.m[12], camera.frame.m[13], camera.frame.m[14] );

      Math::Vec3 lookAt = camT - camZ;

//      printf("\x1b[2;0HCamT:  %1.4f %1.4f %1.4f", camT.x, camT.y, camT.z);
//      printf("\x1b[3;0HCamZ:  %1.4f %1.4f %1.4f", camZ.x, camZ.y, camZ.z);
//      printf("\x1b[4;0HLook: %1.4f %1.4f %1.4f", lookAt.x, lookAt.y, lookAt.z);

      iprintf("\x1b[16;0HFrame = %d",frame);
      iprintf("\x1b[17;0HTouch x = %04X, %04X\n", touchXY.x, touchXY.px);
      iprintf("Touch y = %04X, %04X\n", touchXY.y, touchXY.py);   

      RenderScene();

      swiWaitForVBlank();
   }
   
   return 0;
}
[/code]

#140577 - josath - Mon Sep 17, 2007 9:23 pm

Are you sure the wifi is causing the problem? does your 3d code work if you comment out the wifi commands?

#140593 - Schmedly - Mon Sep 17, 2007 11:59 pm

If I comment out the WiFi calls it still doesn't produce any 3D. However, the 3D code works perfectly in a project that doesn't use any arm7 code. That's the main difference.