#19392 - CyberSlag5k - Mon Apr 19, 2004 2:27 am
I've posted this on the gamedev.net forums, and, getting no response, have posted them here. I hope that's ok.
Anyway, I am doing my first sprite-animation work for the gba. The sprites show up, but they are severely miscolored (all but one, usually). So, following gbajunkie's tutorial #4, I have combined my four sprites into a single image and then passed that image into OBJPaletteMem:
for(int i = 0; i < 256; i++)
OBJPaletteMem[ i ] = palettePalette[ i ];
My combined sprite picture (which is what palettePalette is derivced from) looks like this:
<img src="http://homepages.udayton.edu/~pateramj/palette.gif">
Each one of those faces is a different sprite. Is this not the proper way to do that? It's not exactly working. In fact, the colors are now even farther off than they were previously.
#19393 - Miked0801 - Mon Apr 19, 2004 2:36 am
A bit more source may help us decypher what is going on...
#19396 - zazery - Mon Apr 19, 2004 3:25 am
I used pcx2sprite.exe what I did to keep my same colours was to load the same pallete for each file in Photoshop. Basically in your case I would have 4 layers, same pallete for the entire project, then save 4 different images. It worked for me I didn't have a problem with it. (my sprites for my game)
If you could provide the following it might help:
-Generated Pallete code for one of your sprites
-Screenshot of your VBA Pallete viewer and Photoshop Pallete depending on if you use Photoshop.
-Complete code to how you set up your sprites (just that part, not input routines etc.)
-Screenshot of what's happening.
Or
Post everything your using in a zip file including images and source, possibly a binary as well.
Best of luck solving your problem, I know palletes can get frusterating when starting out.
#19407 - yaustar - Mon Apr 19, 2004 6:19 am
What are the faces suppose to look like.
pcx2sprites isnt the best tool to do multi tiles... use gif2sprites instead, you can input as many images as you want and it does a combined palette for you.
_________________
[Blog] [Portfolio]
#19423 - CyberSlag5k - Mon Apr 19, 2004 7:56 pm
Thanks to all who replied. Here are the requested details of what I'm trying to do:
I have 4 sprites, soldier1.pcx soldier2.pcx soldier3.pcx and soldier4.pcx. They are all 64x64 frames and each one is just a soldier's head, each with his visor in 1 of 4 states of closing (1 is all the way open, 4 is closed). I have converted them all to .h files using pcx2sprite. I also have one large pcx file that is made up of all 4 sprites placed next to each other. It is named palette.pcx and can be seen here:
http://homepages.udayton.edu/~pateramj/palette.gif
Now, I have run sprite2pcx on this as well but have discarded the data portion of it and saved only its color palette. I have done this to create a color palette that includes all of the colors my sprites are made up of.
The relevant code is here:
#include"gba.h"
#include"keypad.h"
#include"palette.h"
#include"FF.h"
#include"soldier1.h"
#include"soldier2.h"
#include"soldier3.h"
#include"soldier4.h"
#include "dispcnt.h"
#include"sprite.h"
//#include<winmm>
using namespace std;
typedef struct
{
int posX, posY;
u16 spriteFrame[4];
int activeFrame;
u16 OAMSpriteNum;
}Sprite;
Sprite soldier;
u16* videoBuffeer = ((u16*)0x6000000);
u16* paletteMem = ((u16*)0x5000000);
u16* OAM = ((u16*)0x7000000);
OAMEntry sprites[128];
pRotData rotData = (pRotData)sprites;
void copyOAM()
{
u16* temp;
temp = (u16*)sprites;
for(u16 i = 0; i < 512; i++)
OAM[i] = temp[i];
}
void initializeSprites()
{
for(u16 i = 0; i < 128; i++)
{
sprites[i].attribute0 = 160;
sprites[i].attribute1 = 240;
}
}
void VSync()
{
while((volatile u16)REG_VCOUNT != 160)
{
}
}
void plotPixel(int x, int y, unsigned short int c)
{
videoBuffeer[(y) * 120 + (x)] = (c);
}
void setMode(u16 mode)
{
REG_DISPCNT = mode;
}
void getInput()
{
if(!(*KEYS & KEY_LEFT))
{
soldier.activeFrame = 0;
sprites[soldier.OAMSpriteNum].attribute2 = soldier.spriteFrame[soldier.activeFrame];
}
if(!(*KEYS & KEY_DOWN))
{
soldier.activeFrame = 1;
sprites[soldier.OAMSpriteNum].attribute2 = soldier.spriteFrame[soldier.activeFrame];
}
if(!(*KEYS & KEY_RIGHT))
{
soldier.activeFrame = 2;
sprites[soldier.OAMSpriteNum].attribute2 = soldier.spriteFrame[soldier.activeFrame];
}
if(!(*KEYS & KEY_UP))
{
soldier.activeFrame = 3;
sprites[soldier.OAMSpriteNum].attribute2 = soldier.spriteFrame[soldier.activeFrame];
}
}
int main()
{
soldier.posX = 20;
soldier.posY = 40;
setMode(MODE_1 | OBJ_ENABLE | OBJ_MAP_1D);
for(int i = 0; i < 256; i++)
{
OBJPaletteMem[i] = palettePalette[i];
}
initializeSprites();
sprites[0].attribute0 = COLOR_256 | SQUARE | soldier.posY;
sprites[0].attribute1 = SIZE_64 | soldier.posX;
sprites[0].attribute2 = 0;
for(int i = 0; i < 2048; i++)
{
OAMData[i] = soldier1Data[i];
}
for(int i = 0; i < 2048; i++)
{
OAMData[i + 2048] = soldier2Data[i];
}
for(int i = 0; i < 2048; i++)
{
OAMData[i + 4096] = soldier3Data[i];
}
for(int i = 0; i < 2048; i++)
{
OAMData[i + 6144] = soldier4Data[i];
}
soldier.OAMSpriteNum = 0;
soldier.activeFrame = 0;
soldier.spriteFrame[0] = 0;
soldier.spriteFrame[1] = 128;
soldier.spriteFrame[2] = 256;
soldier.spriteFrame[3] = 384;
while(1)
{
getInput();
VSync();
copyOAM();
}
return 0;
}
When I run the program, the various sprites show up, but their colors are skewed, leading me to believe the color palette is wrong. Usually one of the 4 sprites has correct color and the others are just plan weird. I'm thinking my palette is screwy.
If further details are needed, I would be happy to supply them.
In the mean time, I'm going to play with this rather intriguing pcx2gif program.
Thank you for all your help everyone.
#19433 - CyberSlag5k - Tue Apr 20, 2004 1:18 am
UPDATE: gifs2sprites rocks. all problems solved. thanks for everyone'sh elp
#19435 - yaustar - Tue Apr 20, 2004 2:19 am
Use code tags next time will ya? :)
We had the same problem with pcx2sprites so we found gif2sprites
take a look at gfx2sprites as it is more verstile when you get some time :)
_________________
[Blog] [Portfolio]
#19438 - CyberSlag5k - Tue Apr 20, 2004 2:30 am
yaustar wrote: |
Use code tags next time will ya? :)
We had the same problem with pcx2sprites so we found gif2sprites
take a look at gfx2sprites as it is more verstile when you get some time :) |
Yeah, sorry about that.
Checking on gfx2sprites now. Thanks!
#19439 - CyberSlag5k - Tue Apr 20, 2004 2:34 am
Hmm...can't seem to find gfx2sprites in the tools section or on google. Gotta link?
#19444 - yaustar - Tue Apr 20, 2004 4:08 am
Gfx2gba not gfx2sprites, my bad... I keep getting it wrong...... :(
_________________
[Blog] [Portfolio]