(Final)NitroSpritesLib

Learn to use DS Game Maker by Example!

Re: NitroSpritesLib

Postby YoshiInAVoid » January 18th, 2012, 5:19 pm

Glad you agree! This lib is ever so slowly growing into something that might eventually become independant and not require PAlib! You should check out the PAlib source code and try porting some more parts of it, but make it cleaner and have everything NitroFS based :)
YoshiInAVoid
 
Posts: 1960
Joined: December 30th, 2010, 11:53 am
Location: England

Re: NitroSpritesLib

Postby Foxi4 » January 19th, 2012, 6:32 pm

Doubt it. Why reintent the wheel when there is nightfox readily available? This lib is just for the dying DSGM, it's meant to prolong its rotting process ever so slightly. That kind of functionality should have been available out of the box, resource streaming was available since EFS, and even earlier if you consider FAT as an option too.
Current Projects:

FalloutDS: Postponed until proper libraries are created, 10%
Foxi_Lib: A completely revised version of NitroSprites[FINAL], NitroBackgrounds and NitroText[FINAL], 40%
Foxi4
 
Posts: 1114
Joined: December 31st, 2010, 3:25 am

Re: NitroSpritesLib

Postby YoshiInAVoid » January 19th, 2012, 8:36 pm

Never heard of Nightfox, where can I find it?
YoshiInAVoid
 
Posts: 1960
Joined: December 30th, 2010, 11:53 am
Location: England

Re: NitroSpritesLib

Postby Foxi4 » January 19th, 2012, 8:40 pm

http://www.nightfoxandco.com/index.php/ ... n/?lang=en

Nightfox is one of the people behind the original PAlib as far as I remember - this lib is a written from scratch graphics library with an extremely similar syntax, 3D functionality, streaming of content built-in... it's "better" in every aspect.

Porting PAlib applications to it is also relatively easy as it is constructed similarily.
Current Projects:

FalloutDS: Postponed until proper libraries are created, 10%
Foxi_Lib: A completely revised version of NitroSprites[FINAL], NitroBackgrounds and NitroText[FINAL], 40%
Foxi4
 
Posts: 1114
Joined: December 31st, 2010, 3:25 am

Re: NitroSpritesLib

Postby YoshiInAVoid » January 19th, 2012, 10:18 pm

Thanks! I'll definatly check that out!
YoshiInAVoid
 
Posts: 1960
Joined: December 30th, 2010, 11:53 am
Location: England

Re: (Final)NitroSpritesLib

Postby Buck_7 » January 29th, 2012, 12:33 am

Nothing happens when I try to load. Does this only work on a real DS?
Upcoming games I'm working on:
  • Minecraft2DS
  • Bow Man DS
  • Bird poo!
------------------------------------------------------------------------
COOL LOOK 3D portal port for DS! http://drunkencoders.com/2013/01/dstal-advance/
needMusic?needHelp?Ask.
User avatar
Buck_7
 
Posts: 964
Joined: February 19th, 2011, 1:44 am

Re: (Final)NitroSpritesLib

Postby YoshiInAVoid » January 29th, 2012, 11:04 am

Works fine in no$gba and any emu with the argv protocall (nitroFS support). Try using this version of the lib (supports sprites at negative positions and has a basic create sprite function):

Code: Select all
//NitroSpritesLib by Foxi4 & YoshiInAVoid

unsigned char* SpriteCustom[128] _GFX_ALIGN;
unsigned short PaletteCustom[256] _GFX_ALIGN;
FILE* File;
u32 Size;
u16 Gfx[128];
u8 SpritesCreated=0;

void FAT_LoadSprite(u8 ID, char* SpriteName){
   File = fopen (SpriteName, "rb");
   fseek (File, 0 , SEEK_END);
   Size = ftell (File);
   rewind (File);
   SpriteCustom[ID] = malloc(Size);
   fread (SpriteCustom[ID], 1, Size, File);
   fclose (File);   
}
void FAT_LoadPal(u8 ID, bool Screen, char* PalName){
   File = fopen (PalName, "rb");
   fread (PaletteCustom, 1, sizeof(PaletteCustom), File);
   fclose (File);
   PA_LoadSpritePal(Screen, ID, PaletteCustom);
}
void FAT_CreateSprite(bool Screen, u8 ID, u8 Palette, u8 Shape, u8 Size, s16 X, s16 Y){
   if(SpriteCustom[ID]!=NULL){
      Gfx[ID] = PA_CreateGfx(Screen, SpriteCustom[ID], Shape, Size, 1);
      PA_CreateSpriteFromGfx(Screen, ID, Gfx[ID], Shape, Size, 1, Palette, X, Y);
      SpritesCreated++;
   }
}
void FAT_CreateSpriteFromGFX(bool Screen, u8 ID, u8 GfxID, u8 Palette, u8 Shape, u8 Size, s16 X, s16 Y){
   if(SpritesCreated>0){
      PA_CreateSpriteFromGfx(Screen, ID, Gfx[GfxID], Shape, Size, 1, Palette, X, Y);
      SpritesCreated++;
   }
}
void FAT_DeleteSprite(u8 Screen, u8 SpriteNum) {
   PA_DeleteSprite(Screen, SpriteNum);
   PA_DeleteGfx(Screen, SpriteNum);
   SpritesCreated--;
}
void FAT_DeleteAllSprites(u8 Screen) {
   u8 FreeLoop = 0;
   for (FreeLoop = 0; FreeLoop <= 128; FreeLoop++) {
      FAT_DeleteSprite(Screen, FreeLoop);
     SpritesCreated=0;
   }
}
void FAT_UnloadSprite(u8 ID){
   free(SpriteCustom[ID]);
   SpriteCustom[ID]=NULL;
}

char _Sprite[50];
char _Pal[50];
void FAT_BasicCreateSprite(u8 Screen, u8 SpriteNum, u8 PaletteNum, char FileName[39], u8 Shape, u8 Size, s16 X, s16 Y) {
   strcpy(_Sprite, FileName);
   strcat(_Sprite, "_Sprite.bin");
   strcpy(_Pal, FileName);
   strcat(_Pal, "_Pal.bin");
   FAT_LoadPal(PaletteNum, Screen, _Pal);
   FAT_UnloadSprite(SpriteNum);
   while(SpriteCustom[SpriteNum] != NULL) { // I LOVE the word NULL!
      PA_WaitForVBL();
   }
   FAT_LoadSprite(SpriteNum, _Sprite);
   FAT_CreateSprite(Screen, SpriteNum, PaletteNum, Shape, Size, X, Y);
}


Include the files "YourSprite_Sprite.bin" and "YourSprite_Pal.bin" in NitroFS (Game Settings I think) and then use the PAlib action in a Create Event and put this code:

Code: Select all
FAT_BasicCreateSprite(0, 3, 3, "YourSprite", OBJ_SIZE_32X32, 100, 100)


It will load "YourSprite" on the bottom screen as a 32X32 image as sprite number 3 with paletter number 3 at co-ordinates (100, 100).

Hope this helps!
YoshiInAVoid
 
Posts: 1960
Joined: December 30th, 2010, 11:53 am
Location: England

Re: (Final)NitroSpritesLib

Postby Buck_7 » January 29th, 2012, 8:29 pm

I can't find any "YourSprite_Pal.bin" or "YourSprite_Sprite.bin" (I know what you mean by yoursprite)
I only find "YourSprite_Sprite.bin". As fas as I know, only backgrounds have a Pal.
Upcoming games I'm working on:
  • Minecraft2DS
  • Bow Man DS
  • Bird poo!
------------------------------------------------------------------------
COOL LOOK 3D portal port for DS! http://drunkencoders.com/2013/01/dstal-advance/
needMusic?needHelp?Ask.
User avatar
Buck_7
 
Posts: 964
Joined: February 19th, 2011, 1:44 am

Re: (Final)NitroSpritesLib

Postby YoshiInAVoid » January 29th, 2012, 9:07 pm

Sprites have both "SpriteName_Sprite.bin" and "SpriteName_Pal.bin"
YoshiInAVoid
 
Posts: 1960
Joined: December 30th, 2010, 11:53 am
Location: England

Re: (Final)NitroSpritesLib

Postby Buck_7 » January 29th, 2012, 9:10 pm

Oh. But why can't I find them?...

My method is to complie the sprites using DSGM 5, then going into the C:/ drive to find my temp folder, and then copying what I can find. Except I didn't find what I was Looking for.....yet?
Upcoming games I'm working on:
  • Minecraft2DS
  • Bow Man DS
  • Bird poo!
------------------------------------------------------------------------
COOL LOOK 3D portal port for DS! http://drunkencoders.com/2013/01/dstal-advance/
needMusic?needHelp?Ask.
User avatar
Buck_7
 
Posts: 964
Joined: February 19th, 2011, 1:44 am

Re: (Final)NitroSpritesLib

Postby YoshiInAVoid » January 29th, 2012, 9:33 pm

C:\DSGameMakerTemp3847563487456\gfx\bin

Is where you'll find them.

Or here:

C:\DSGameMakerTemp3847563487456\build

Or just forget DS Game Maker completely and use PAgfx, last time I checked there was a front-end program for n00bs like yourself.
YoshiInAVoid
 
Posts: 1960
Joined: December 30th, 2010, 11:53 am
Location: England

Re: (Final)NitroSpritesLib

Postby Buck_7 » January 29th, 2012, 9:50 pm

I found them when I compile a completly new project, but Maybe there was too much to go through on the project I'm working on. I know where to look, but I couldn't find them. I okay now.
Upcoming games I'm working on:
  • Minecraft2DS
  • Bow Man DS
  • Bird poo!
------------------------------------------------------------------------
COOL LOOK 3D portal port for DS! http://drunkencoders.com/2013/01/dstal-advance/
needMusic?needHelp?Ask.
User avatar
Buck_7
 
Posts: 964
Joined: February 19th, 2011, 1:44 am

Re: (Final)NitroSpritesLib

Postby Foxi4 » January 31st, 2012, 12:11 am

Yeppers, PAGfx is going to be of much more use then adding a DSGM sprite, compiling and copying it over. It's available online, just google it.

The advantage is that you can name palettes yourself and assign given sprites to given palettes, so that enemies can have one, backgrounds another etc.
Current Projects:

FalloutDS: Postponed until proper libraries are created, 10%
Foxi_Lib: A completely revised version of NitroSprites[FINAL], NitroBackgrounds and NitroText[FINAL], 40%
Foxi4
 
Posts: 1114
Joined: December 31st, 2010, 3:25 am

Re: (Final)NitroSpritesLib

Postby YoshiInAVoid » January 31st, 2012, 5:26 pm

If using NitroFS though, there isn't much point since the limit goes way up from 4Mb anyway.
YoshiInAVoid
 
Posts: 1960
Joined: December 30th, 2010, 11:53 am
Location: England

Re: (Final)NitroSpritesLib

Postby Foxi4 » February 1st, 2012, 7:17 pm

I beg to differ.

Let's imagine that you have 4 backgrounds on the top and 4 on the bottom, each with an individual palette.

That eats up 8 out of your 10 palettes. You have 2 palettes left for your objects.

If you don't "merge" palettes whenever you can, you'll end up with a very limited ammount of sprites simply because you won't have the access to the colours they use "stock" (2 palettes - 2x 256 colours ;) ).

When making spritesheets you have to think ahead and reserve 1 palette for your character, a few palettes for the backgrounds and know exactly on which level which enemies will spawn, so that you can merge their palettes into one. The less the better.

It's also pointless to lose a palette for, for example, a collision map which likely uses only 5 colours. You can jam that up with another background's palette, effectively decreasing the ammount of used up palettes.
Current Projects:

FalloutDS: Postponed until proper libraries are created, 10%
Foxi_Lib: A completely revised version of NitroSprites[FINAL], NitroBackgrounds and NitroText[FINAL], 40%
Foxi4
 
Posts: 1114
Joined: December 31st, 2010, 3:25 am

Re: (Final)NitroSpritesLib

Postby YoshiInAVoid » February 1st, 2012, 9:43 pm

Have you seen the format of a palette?

Palette.png


Less than 400 bytes are used for this palette; loading all of the images HTML code for this page uses more memory than that! And this page took you less than a second to load, click refresh and you'll see for yourself!

Having a few unnasassary palettes in your NitroFS folder at compile time will make uploading and downloading your nds file on the web almost unnoticeably slower.

In my opinion, who cares? It's only going to be an inconvinience to yourself having to remember which sprites require which palette. Rather than just giving each sprite the privilige of it's own palette.

Loading many backgrounds or sprites off one palette is pointless and a waste of time.
YoshiInAVoid
 
Posts: 1960
Joined: December 30th, 2010, 11:53 am
Location: England

Re: (Final)NitroSpritesLib

Postby Foxi4 » February 2nd, 2012, 12:30 am

That was not my point. My point was that PAlib has only 10 slots for simultainous use at a given time.

That means that you are effectively limited when it comes to colours, so you need to merge palettes. Not because they take space, but because it's a hardware limitation that you simply cannot jump over unless you actively "draw" on the screen in 16-bit mode.
Current Projects:

FalloutDS: Postponed until proper libraries are created, 10%
Foxi_Lib: A completely revised version of NitroSprites[FINAL], NitroBackgrounds and NitroText[FINAL], 40%
Foxi4
 
Posts: 1114
Joined: December 31st, 2010, 3:25 am

Previous

Return to Tutorials & Examples

Who is online

Users browsing this forum: No registered users and 1 guest