int main(int argc, char ** argv) { PA_Init(); PA_InitVBL(); PA_Init3D(); // Regular init for the 3D sprite system PA_Reset3DSprites(); PA_InitText(0, 1); PA_OutputSimpleText(0, 4, 1, "Create texture from FAT"); fatInitDefault(); // Init for libfat. Automatically sets up DLDI and everything else you need for basic FAT access. PA_FatInitAllBuffers(); // Initialize all the memory buffers used by the FAT loading system PA_FatSetBasePath("/DemoFiles/data"); // Set a base path from the card root to load your asset files from // Within this base asset folder: // all background binaries should be in /bg/ // sprite and sprite palette binaries in /sprites/ // and RAW format sound files in /sfx/ // Load a sprite image from FAT to VRAM. It works just like PA_3DCreateTex! u16 gfx = PA_FatEasy3DCreateTex("pokekun", // Name of a texture binary created with PAGfx (without "_Texture.bin") 32, // Texture width 64, // Texture height TEX_256COL); // 256 color texture (see TEX_16COL, TEX_4COL, etc.) // Create a palette for the 3D sprites that will be created later. It works just like PA_Load3DSpritePal! PA_FatEasyLoad3DSpritePal(0, // Sprite palette number "pokekun"); // Name of a palette binary in EFS created by PAGfx (without the "_Pal.bin") PA_OutputSimpleText(0, 1, 22, "Press A to create a 3D sprite!"); u16 nsprites0 = 0; // Number of 3D sprites created while(1) { if (Pad.Newpress.A && nsprites0 < 1024) // You can have 1024 3D sprites!!! { // Since the sprite is already in VRAM you can just use the normal PA_3DCreateSpriteFromTex function PA_3DCreateSpriteFromTex(nsprites0, // Next sprite to load... gfx, // texture in VRAM to use, no image copying ! 32, 64, 0, PA_RandMax(240), PA_RandMax(160)); // The rest is like normal 3D sprites ++nsprites0; // Next time, load the next sprite number } PA_WaitForVBL(); PA_3DProcess(); } return 0; }
// Function: main() int main(int argc, char ** argv) { PA_Init(); // Initializes PA_Lib PA_InitVBL(); // Initializes a standard VBL PA_Init3D(); // Uses Bg0, Init 3D... PA_Reset3DSprites(); // Init or Reset 3D Sprites // Initialise the text system on the top screen PA_InitText(1, 1); // Initialise the text system on the top screen PA_OutputSimpleText(1, 0, 8, "Move 3DSprite to change priority"); // First, create the gfx with the corresponding images and sizes. Images converted as 256colors textures in PAGfx gfx[0] = PA_3DCreateTex((void*)mollusk_Texture, // Texture 64, 64, // Width, Height TEX_256COL ); // Texture Format // Load the Palettes ! PA_Load3DSpritePal(0, // Slot (void*)mollusk_Pal); // Palette // Create a few sprites PA_3DCreateSpriteFromTex(0, gfx[0], 64, 64, 0, 128, 96); u8 i; for(i = 0; i < 24; i++){ PA_3DCreateSpriteFromTex(i+1, gfx[0], 64, 64, 0, 32, i*8); PA_3DSetSpritePrio(i+1, 1024 + i*8); // Priority... (default is 1024) } while(1) { if(Stylus.Held) { PA_3DSetSpriteXY(0, Stylus.X, Stylus.Y); PA_3DSetSpritePrio(0, 1024 + Stylus.Y); // Priority depending on Y position... } PA_WaitForVBL(); PA_3DProcess(); // Update sprites } return 0; } // End of main()
// Main function int main(void) { // PAlib init PA_Init(); PA_InitVBL(); PA_Init3D(); PA_Reset3DSprites(); PA_InitText(1, 0); PA_Load3DSpritePal(0, (void*)som_Pal); // Palette.... s32 x = 128; s32 y = 96; PA_3DCreateSprite(0,(void*)som_Texture, 32, 32, TEX_256COL, 0, x, y); // Sprite while(1) { // Animation code... if(Pad.Newpress.Up) PA_3DStartSpriteAnim(0, 0, 3, 6); if(Pad.Newpress.Down) PA_3DStartSpriteAnim(0, 8, 11, 6); if(Pad.Newpress.Right) { PA_3DStartSpriteAnim(0, 4, 7, 6); PA_3DSetSpriteHflip(0, 0); } if(Pad.Newpress.Left) { PA_3DStartSpriteAnim(0, 4, 7, 6); PA_3DSetSpriteHflip(0, 1); } if(!((Pad.Held.Left)||(Pad.Held.Up)||(Pad.Held.Down)||(Pad.Held.Right))) PA_3DSpriteAnimPause(0, 1); // Moving Code y += Pad.Held.Down - Pad.Held.Up; x += Pad.Held.Right - Pad.Held.Left; PA_3DSetSpriteXY(0, x, y); PA_WaitForVBL(); PA_3DProcess(); // Update 3D... } return 0; }
// Function: main() int main(int argc, char ** argv) { PA_Init(); // Initializes PA_Lib PA_InitVBL(); // Initializes a standard VBL PA_Init3D(); // Uses Bg0 PA_Reset3DSprites(); // Initialise the text system on the top screen PA_InitText(0, 1); PA_InitText(1, 1); // Initialise the text system on the top screen PA_OutputSimpleText(1, 0, 6, "Move the Sprite with the stylus"); // First, create the gfx with the corresponding images and sizes. Images converted as 16bit sprites in PAGfx gfx[0] = PA_3DCreateTex((void*)mollusk_Texture, 64, 64, TEX_16BITS); // Create 4 sprites for the different flips...... PA_3DCreateSpriteFromTex(0, gfx[0], 64, 64, 0, 80, 48); // X, Y SPRITE CENTER ! PA_3DCreateSpriteFromTex(1, gfx[0], 64, 64, 0, 80+96, 48); // X, Y SPRITE CENTER ! PA_3DCreateSpriteFromTex(2, gfx[0], 64, 64, 0, 80, 80+64); // X, Y SPRITE CENTER ! PA_3DCreateSpriteFromTex(3, gfx[0], 64, 64, 0, 80+96, 80+64); // X, Y SPRITE CENTER ! // Set the flips PA_3DSetSpriteHflip(0, 0); PA_3DSetSpriteVflip(0, 0); PA_3DSetSpriteHflip(1, 1); PA_3DSetSpriteVflip(1, 0); PA_3DSetSpriteHflip(2, 0); PA_3DSetSpriteVflip(2, 1); PA_3DSetSpriteHflip(3, 1); PA_3DSetSpriteVflip(3, 1); while(1) { PA_WaitForVBL(); PA_3DProcess(); // Update sprites } return 0; } // End of main()
void Stone::draw(int x, int y, char c) { u16 sgfx; PA_Load3DSpritePal(1, (void*)stone_Pal); // Palette switch (c) { case BLACK: sgfx = PA_3DCreateTex((void*)blackstone_Texture, 16, 16, TEX_256COL); PA_3DCreateSpriteFromTex(x+18*y, sgfx, 16, 16, 1, x*10+71, y*10+7); PA_PlaySimpleSound(sound_stone); break; case WHITE: sgfx = PA_3DCreateTex((void*)whitestone_Texture, 16, 16, TEX_256COL); PA_3DCreateSpriteFromTex(x+18*y, sgfx, 16, 16, 1, x*10+71, y*10+7); PA_PlaySimpleSound(sound_stone); break; case FRONTIER: case EMPTY: PA_3DDeleteSprite(x+18*y); break; default: break; } // PA_3DSetSpriteWidth(x+18*y,8); // PA_3DSetSpriteHeight(x+18*y,8); PA_3DSetSpriteFrame(x+18*y, 0); //PA_3DSetSpriteAlpha(x+18*y, 15); //PA_3DSetSpritePolyID(x+18*y, 0); PA_3DProcess(); // Update sprites PA_WaitForVBL(); }
// Main function int main(void) { // PAlib init PA_Init(); PA_InitVBL(); PA_Init3D(); // Uses Bg0, Init 3D... PA_Reset3DSprites(); // Init or Reset 3D Sprites PA_InitText(1, 0); PA_OutputText(1, 0, 10, "Press Pad to change frame"); // Load the sprite palette, PA_Load3DSpritePal(0, // Palette number (void*)frames_Pal); // Palette name gfx[0] = PA_3DCreateTex((void*)frames_Texture, 32, 32, TEX_256COL); PA_3DCreateSpriteFromTex(0, gfx[0], 32, 32, 0, 128, 96); while(1) { if (Pad.Held.Up) PA_3DSetSpriteFrame(0, 0); // screen, sprite, frame if (Pad.Held.Down) PA_3DSetSpriteFrame(0, 2); // screen, sprite, frame if (Pad.Held.Left) PA_3DSetSpriteFrame(0, 3); // screen, sprite, frame if (Pad.Held.Right) PA_3DSetSpriteFrame(0, 1); // screen, sprite, frame PA_WaitForVBL(); PA_3DProcess(); } return 0; }
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(); } }
Board::Board(int m):root_story(-1, -1, 0) { #ifdef CKM_STORED // pIgs = NULL; #endif size = 19; // UI = new FlBoard(); // time_color = UI->black_time->text_background(); //time_color2 = UI->black_time->text_color(); //UI->b = this; set_size(size); cur_player = BLACK; for (int i=0; i<19; i++) for (int j=0; j<19; j++) { b[i][j] = EMPTY; root_story.b[i][j] = EMPTY; } s = &root_story; pos = 0; root_story.score[0] = score[0] = 0; root_story.score[1] = score[1] = 0.5; mode = 0; set_mode(m); // owner = 0; //< pointer on the possibly associated IGS game memset(inib, EMPTY, 19*19); memset(dead, EMPTY, 19*19); memset(territory, EMPTY, 19*19); memset(b, EMPTY, 19*19); // memset(old_c, 0, sizeof(old_c)); //time color next = first; first = this; if (!stn) { stn = new Stone(); stn->set_size(20); // stn->init_image(); } // UI->black_box->image(stn->img[0]); // UI->white_box->image(stn->img[1]); // UI->black_name->hide(); // UI->white_name->hide(); // UI->black_time->hide(); //UI->white_time->hide(); // UI->moves_browser->board = this; // UI->observer_browser->callback(observer_cb, this); // UI->moves_browser->type(Fl_Browser::VERTICAL | Fl_Browser::MULTI_BROWSER); strcpy(blackname, ""); strcpy(blackrank, ""); strcpy(whitename, ""); strcpy(whiterank, ""); filename = 0; title = 0; PA_ResetBgSys(); PA_ResetSpriteSys(); PA_Init3D(); PA_Reset3DSprites(); PA_LoadTiledBg(0, 3, board19); PA_LoadTiledBg(1, 1, bgscoreigs); PA_Init16cBg(1, 0); PA_16cText(1, 120, 10, 255, 192, "chris28ttttt [17k]", 1, 2, 100); // PA_LoadSpritePal(0, 1, (void*)pass_Pal); PA_3DProcess(); // Update sprites PA_WaitForVBL(); if (!ptn) { ptn = new Pointer(); } u16 gfx[6]; gfx[PASSBUTTON] = PA_3DCreateTex((void*)pass_Texture, 64, 32, TEX_256COL); PA_3DCreateSpriteFromTex(PASSBUTTON, gfx[PASSBUTTON], 64, 32, 2, 33, 164); PA_3DProcess(); // Update sprites PA_WaitForVBL(); // while (COND_PLAY_MOVE) { while(!(mode&BOARD_OBSERVE)) { ptn->move(); //add_move(ptn->xpointer, ptn->ypointer); if (mode&BOARD_SCORING) { // if (s->nbvariants) return 1; if (mode&BOARD_PLAYING) { if (!dead[ptn->xpointer][ptn->ypointer]) { char c = 'a'+ptn->xpointer; if (c>='i') c++; char s[10]; // sprintf(s, "%c%d", c, this->size-my); // owner->igs->send(s); } } else { if (0)//(mk == 1) event button remove(ptn->xpointer,ptn->ypointer, cur_board->b[ptn->xpointer][ptn->ypointer], !dead[ptn->xpointer][ptn->ypointer]); else { if (b[ptn->xpointer][ptn->ypointer] == EMPTY) dead[ptn->xpointer][ptn->ypointer] = dead[ptn->xpointer][ptn->ypointer] == 2? 0:2; } // cur_board->dead[mx][my] = !cur_board->dead[mx][my]; // refresh(); // redraw(); update_territory(); } } else if (b[ptn->xpointer][ptn->ypointer] == EMPTY) { if (mode&BOARD_PLAYING) { //IGS char s[10]; char c = 'a'+ptn->xpointer; if (c>='i') c++; //sprintf(s, "%c%d", c, this->size-my); //owner->igs->send(s); } else { // edit mode add_move(ptn->xpointer, ptn->ypointer); // refresh(); update_pos(); } } // sprintf(debug,"player : %d",cur_player); // PA_16cText(1, 10, 30, 255, 192, debug, 1, 2, 100); // refresh(); // update_pos(); } // PA_CreateSprite(0, 1, (void*)pass_Sprite, OBJ_SIZE_64X32, 1, 1, 1, 60); }
void Board::set_mode(int m) { u16 gfx[6]; PA_Load3DSpritePal(2, (void*)buttons_Pal); // Palette mode |= m; if (mode&BOARD_OBSERVE) { // UI->load->hide(); // UI->edit->show(); // UI->scoring->hide(); } else { // UI->load->show(); // UI->edit->hide(); // UI->scoring->show(); gfx[PASSBUTTON] = PA_3DCreateTex((void*)pass_Texture, 64, 32, TEX_256COL); PA_3DCreateSpriteFromTex(PASSBUTTON, gfx[PASSBUTTON], 64, 32, 2, 32, 164); PA_3DProcess(); // Update sprites PA_WaitForVBL(); } if (mode&BOARD_PLAYING) { // UI->komi->show(); // UI->handicap->show(); // UI->pass->show(); gfx[PASSBUTTON] = PA_3DCreateTex((void*)pass_Texture, 64, 32, TEX_256COL); PA_3DCreateSpriteFromTex(PASSBUTTON, gfx[PASSBUTTON], 64, 32, 2, 32, 164); PA_3DProcess(); // Update sprites PA_WaitForVBL(); // UI->adjourn->show(); // UI->undo->show(); // UI->close->hide(); // UI->resign->show(); if (mode&BOARD_SCORING) { // UI->resign->label("Done"); update_territory(); } else { // UI->resign->label("Resign"); // UI->resign->redraw(); } } else { // UI->komi->hide(); // UI->handicap->hide(); // UI->pass->hide(); // UI->adjourn->hide(); // UI->undo->hide(); // UI->close->show(); // UI->resign->hide(); } #ifdef CKM_STORED if (mode&BOARD_LOOKING) { // UI->scoring->hide(); // UI->edit->hide(); // UI->load->hide(); // UI->save->hide(); } #endif if (mode&BOARD_SCORING) { // UI->status->value(mode&BOARD_PLAYING? // "Mark dead stones then click Done." : // "Mark dead stones with left click, drop frontiers with right click."); } else if (!(mode&BOARD_PLAYING)) { // UI->status->value("Edit mode."); } }