// Function: main() int main(int argc, char ** argv) { PA_Init(); // Initializes PA_Lib PA_InitVBL(); // Initializes a standard VBL // Let's not load any backgrounds :p PA_SetBgPalCol(0, 0, PA_RGB(31, 31, 31)); // Set the bottom screen color to white PA_SetBgPalCol(1, 0, PA_RGB(0, 0, 0)); // set the top screen color to black // This will initialise a 16 bit background on each screen. This must be loaded before any other background. // If you need to load this after a backgrounds, you'll have to use PA_ResetBgSys, PA_Init8bit, then reload // your backgrounds... PA_Init16bitBg(0, 3); PA_Init16bitBg(1, 3); // Infinite loop to keep the program running while (1) { // Simple draw function, draws on the screen... PA_16bitDraw(0, // Screen PA_RGB(31, 0, 0)); // Color : full red... // (The first shooting line on emu is a bug from the emu, I don't have it on DS) PA_Put16bitPixel(1, Stylus.X, Stylus.Y, PA_RGB(0, 31, 0)); // Draws a pixel on the top screen, corresponding to the stylus's position PA_WaitForVBL(); } return 0; } // End of main()
// Function: main() int main(int argc, char ** argv) { u8 i; PA_Init(); // Initializes PA_Lib PA_InitVBL(); // Initializes a standard VBL // Load 8bit palettes for sprites... PA_LoadSpritePal(0,0,(void*)ds_Pal); PA_LoadSpritePal(0,1,(void*)giz_Pal); PA_LoadSpritePal(0,2,(void*)gp_Pal); PA_LoadSpritePal(0,3,(void*)psp_Pal); // Create sprites PA_CreateSprite(0,0,(void*)ds_Sprite,OBJ_SIZE_64X64,1,0,PA_Rand()%192,PA_Rand()%128); PA_CreateSprite(0,1,(void*)giz_Sprite,OBJ_SIZE_64X64,1,1,PA_Rand()%192,PA_Rand()%128); PA_CreateSprite(0,2,(void*)gp_Sprite,OBJ_SIZE_64X64,1,2,PA_Rand()%192,PA_Rand()%128); PA_CreateSprite(0,3,(void*)psp_Sprite,OBJ_SIZE_64X64,1,3,PA_Rand()%192,PA_Rand()%128); //Set the main palette BG_PALETTE[0] = PA_RGB(27,27,27); // Infinite loop to keep the program running while (1) { PA_WaitForVBL(); for(i=0;i<4;i++) PA_MoveSprite(i); } return 0; } // End of main()
// Function: main() int main(int argc, char ** argv){ PA_Init(); // PA Init... PA_InitVBL(); // VBL Init... // Init the sound system AS_Init(AS_MODE_SURROUND | AS_MODE_16CH); AS_SetDefaultSettings(AS_PCM_8BIT, 11025, AS_SURROUND); PA_SetBgColor(0, PA_RGB(31, 31, 31)); // White background color // First, convert the gif to a sprite format... u8 *spritegfx = PA_GifToTiles((void*)Mollusk, // Gif file spritepal); // our palette // Next, load the sprite... PA_CreateSprite(0, 0, spritegfx, OBJ_SIZE_64X64, 1, 0, 64, 64); // Just like plain sprites ! PA_LoadSpritePal(0, 0, spritepal); // Just like plain palettes ! // spritegfx can be used over and over again to load other sprites... // If you do not need it anymore, use free(spritegfx); to free the memory it uses ! s32 spritex = -64; // Sprite position s32 pan = 0; // Audio panning PA_SetSpriteHflip(0, 0, 1); // Turn sprite around... again... while(1) { int channel0 = PA_PlaySimpleSound(Zoom); // Play sound... for (spritex = -64; spritex < 256; spritex +=2){ pan = spritex/2; if (pan < 0) pan = 0; if (pan > 127) pan = 127; // Limit range... PA_SetSpriteX(0, 0, spritex); PA_SetSoundChannelPan(channel0, pan); PA_WaitForVBL(); } PA_SetSpriteHflip(0, 0, 0); // Turn sprite around... int channel1 = PA_PlaySimpleSound(Zoom); for (spritex = 256; spritex > -65; spritex -=2){ pan = spritex/2; if (pan < 0) pan = 0; if (pan > 127) pan = 127; // Limit range... PA_SetSpriteX(0, 0, spritex); PA_SetSoundChannelPan(channel1, pan); PA_WaitForVBL(); } PA_SetSpriteHflip(0, 0, 1); // Turn sprite around... again... } return 0; } // End of main()
void ds_global_breakpoint(char *where, int X) { char error[255]; char memused[100]; sprintf(memused,"U: %d / F: %d ", getMemUsed(), getMemFree()); sprintf(error,"<Breakpoint> \n %s \n %s",where,memused); // Prepare JSOB //PA_Reset3DSprites2Banks(); //PA_3DProcess(); ds_global_fillScreen(0,ds_global_getScreen1(),PA_RGB(0,0,16)); ds_global_fillScreen(1,ds_global_getScreen0(),PA_RGB(0,0,16)); // Fill JSOB PA_SmartText16bBuf_DS(ds_global_getScreen(0), 80, 48, // base 255 - 32, 191, // max " -- Breakpoint!!!\n /\n MMMM\n MMMMMM\n MMMMMMM\n MDMM===M\n MDM=X=X\n MDM====M\n MDMM===M\n MNNM-MM\n MNM-M\n MM--M", PA_RGB(31,31,31), 1, 1, 255); // Features PA_CenterSmartText16bBuf_DS(ds_global_getScreen(1), 0, 0, // base 255, 64, // max "KSDS Breakpoint",PA_RGB(31,31,31), 3, 1); // Features PA_CenterSmartText16bBuf_DS(ds_global_getScreen(1), 0, 0, // base 255, 191, // max error,PA_RGB(31,31,31), 2, 1); // Features if (X) { PA_CenterSmartText16bBuf_DS(ds_global_getScreen(1), 0, 191 - 32, // base 255, 191, // max "Please press X...",PA_RGB(31,31,31), 1, 1); // Features } else { PA_CenterSmartText16bBuf_DS(ds_global_getScreen(1), 0, 191 - 32, // base 255, 191, // max "Please press Y...",PA_RGB(31,31,31), 1, 1); // Features } // Show JSOB ds_global_paintScreen(1,ds_global_getScreen1(),0,0); ds_global_paintScreen(0,ds_global_getScreen0(),0,0); // Wait... PA_DisableSpecialFx(0); PA_DisableSpecialFx(1); if (X) { while (!Pad.Newpress.X) { PA_WaitForVBL(); } } else { while (!Pad.Newpress.Y) { PA_WaitForVBL(); } } }
// Function: main() int main(int argc, char ** argv) { PA_Init(); // Initializes PA_Lib PA_InitVBL(); // Initializes a standard VBL //PA_LoadSplash(); // PA_Lib splash screen // Let's put some colors... in the background palettes PA_SetBgPalCol(0, 1, PA_RGB(31, 31, 31)); PA_SetBgPalCol(0, 2, PA_RGB(31, 0, 0)); PA_SetBgPalCol(0, 3, PA_RGB(0, 0, 31)); PA_SetBgPalCol(0, 4, PA_RGB(0, 31, 0)); // Let's not load any backgrounds :p // This will initialise an bit background on each screen. This must be loaded before any other background. // If you need to load this after a backgrounds, you'll have to use PA_ResetBgSys, PA_Init8bit, then reload // your backgrounds... PA_Init8bitBg(0, 3); PA_SmartText(0, 0, 80, 255, 100, "Hello World", 1, 4, 1, 100); // Let's have some rotated text :p // X and Y positions are taken as if the DS was turned PA_SmartText(0, 1, 1, 190, 20, "Hello World", 3, 3, 3, 100); // And a centered text, to check if it works PA_CenterSmartText(0, 0, 100, 255, 120, "Hello World", 2, 4, 1); // Same as Smart text, but no letter limit PA_InitText(1, 0); // Infinite loop to keep the program running s32 scrollx = 0; s32 scrolly = 0; s32 rotcenterx = 0; s32 rotcentery = 0; s16 angle = 0; s32 zoom = 256; PA_OutputSimpleText(1, 2, 2, "Zoom : Start/Select"); PA_OutputSimpleText(1, 2, 3, "ScrollX : Left/Right"); PA_OutputSimpleText(1, 2, 4, "Scrolly : Up/Down"); PA_OutputSimpleText(1, 2, 5, "RotCenterX : A/Y"); PA_OutputSimpleText(1, 2, 6, "RotCenterY : B/X"); PA_OutputSimpleText(1, 2, 7, "Angle : R/L"); while (1) { zoom += Pad.Held.Start - Pad.Held.Select; scrollx += Pad.Held.Right - Pad.Held.Left; scrolly += Pad.Held.Down - Pad.Held.Up; rotcenterx += Pad.Held.A - Pad.Held.Y; rotcentery += Pad.Held.B - Pad.Held.X; angle += Pad.Held.R - Pad.Held.L; PA_SetBgRot(0, 3, scrollx, scrolly, rotcenterx, rotcentery, angle, zoom); PA_WaitForVBL(); } return 0; } // End of main()
void ds_global_errorHalt(char *where) { char error[255]; char memused[100]; sprintf(memused,"U: %d / F: %d ", getMemUsed(), getMemFree()); // Write Error String switch (ds_global_error) { case DS_C_ERR_: sprintf(error,"[E00] Unknown Error \n %s \n %s",where,memused); break; case DS_C_ERR_NOTILESET: sprintf(error,"[E01] Tileset not found \n %s \n %s",where,memused); break; case DS_C_ERR_NOMAPBIN: sprintf(error,"[E02] File Map.bin not found \n %s \n %s",where,memused); break; case DS_C_ERR_NOMEMORY: sprintf(error,"[E03] Not enough memory \n %s \n %s",where,memused); break; case DS_C_ERR_NOMOREOBJECTS: sprintf(error,"[E04] This room has too many objects \n %s \n %s",where,memused); break; case DS_C_ERR_NOWORLDINI: sprintf(error,"[E05] No World.ini \n %s \n %s",where,memused); break; case DS_C_ERR_NOSAVEINI: sprintf(error,"[E06] No Savegame.ini \n %s \n %s",where,memused); break; case DS_C_ERR_ZIPFAST: sprintf(error,"[E07] Incompatible Map.bin (idx)\n %s \n %s",where,memused); break; case DS_C_ERR_NOHDD: sprintf(error,"[E08] Not enough disk space \n %s \n %s",where,memused); break; case DS_C_ERR_NOFOUND: sprintf(error,"[E09] Not Found \n %s \n %s",where,memused); break; case DS_C_ERR_BIGIMA: sprintf(error,"[E10] Image too big\nSorry, you can't play this story\n%s \n %s",where,memused); break; } // Prepare JSOD PA_Reset3DSprites2Banks(); PA_3DProcess(); ds_global_fillScreen(1,ds_global_getScreen1(),PA_RGB(16,0,0)); ds_global_fillScreen(0,ds_global_getScreen0(),PA_RGB(16,0,0)); // Fill JSOD PA_SmartText16bBuf_DS(ds_global_getScreen(1), 80, 48, // base 255 - 32, 191, // max " -- Ouch! Sorry!!!\n /\n MMMM\n MMMMMM\n MMMMMMM\n MDMM===M\n MDM=X=X\n MDM====M\n MDMM===M\n MNNM-MM\n MNM-M\n MM--M", PA_RGB(31,31,31), 1, 1, 255); // Features PA_CenterSmartText16bBuf_DS(ds_global_getScreen(0), 0, 0, // base 255, 64, // max "KSDS Internal Error",PA_RGB(31,31,31), 3, 1); // Features PA_CenterSmartText16bBuf_DS(ds_global_getScreen(0), 0, 0, // base 255, 191, // max error,PA_RGB(31,31,31), 2, 1); // Features PA_CenterSmartText16bBuf_DS(ds_global_getScreen(0), 0, 191 - 32, // base 255, 191, // max "Please reboot your DS",PA_RGB(31,31,31), 1, 1); // Features // Show JSOD ds_global_paintScreen(1,ds_global_getScreen1(),0,0); ds_global_paintScreen(0,ds_global_getScreen0(),0,0); // End... PA_DisableSpecialFx(0); PA_DisableSpecialFx(1); while(1) { PA_WaitForVBL(); } }