Graphics code optimizations, updated TODO to correspond all recent changes

git-svn-id: svn://svn.code.sf.net/p/sc2/code/trunk@169 8092fc87-c524-0410-9efc-e669fe64eaf9
This commit is contained in:
gewlitys
2002-10-28 02:00:12 +00:00
parent b5a577b156
commit 37aea8de90
6 changed files with 34 additions and 155 deletions
+7 -22
View File
@@ -7,16 +7,16 @@ into the cvs tree. Note that v1.0 will pretty much be a straight port,
with no gameplay-altering features added.
Serious bugs (crash the game, high priority):
- loading an old game crashes the game (at least on Linux).
- Communication screens nonrepeatably but inevitably hang the system. This
is probably a deadlock issue.
- Often more probable when heavy color table transformations are going on
- Script bugs where a voice is expected yet not specified appear to make
the game catatonic (e.g. ZoqFotPik's "Good bye Captain." "See ya.")
- When trying to skip past a a speech that's composed of multiple parts,
the game hangs. (NOTE: This isn't true for the Zoq-Fot-Pik, which is
unusual - EVERY line by the ZFP is like that.)
- Lockups during conversations (often when heavy color table transformatins
are going on.
- Load/save code doesn't work perfectly, hangs sometimes when after loading
trying to enter some star first time etc
Glitches (don't crash the game, medium priority):
- pressing arrow keys in the main menu moves the selection in the
@@ -25,31 +25,13 @@ Glitches (don't crash the game, medium priority):
Instead, they pay you a Credit.
- Autopilot indicator keeps blinking when entering combat, when autopilot
was on.
- savegames created in a game from debug and release compiles are not
interchangable
- momentary slowdown of scrolling in hyperspace about once per second
You can see this if you look very closely, or increase the resolution of
the frame counter to 10 times per second and start with -ttl.
- Outfit Starship's module graphics look reasonably in the lbm/ directory
but are hideously scrambled when you're trying to buy them.
- Shipyard is using the PC background but the 3DO layout.
- Shipyard's PC background is not animating.
- Palette is probably corrupted on some things
- Because not all 3DO colormap entries map correctly to png files
(those images originate from pc version? or converted badly? etc)
- Most can be fixed by changing colormap_index to -1 from
*.ani, *.sml, *.med, *.big files where corrupted image is listed, so
it only uses png file's palette and not 3DO one (prevents palette
effects from working, though)
- See doc/devel/aniformat
- Specific problems because of this:
- In quasispace, sis ship should be colored as green, not red
- When landing to planet surface, crossfaded image is wrong compared to
landing position (and so 'flashes' when crossfade ends)
- Flashing rects aren't perhaps always exactly the size of actual 3do version,
it should be checked (for example when selecting ship in fullgame battle)
- Melnorme (battle) graphics are corrupt.
- Shofixti doesn't work in melee.
- In melee, after battle, the game crashes.
The ship icon is used when already freed. This happens because the old
3DO code used to save the entire selection window as one image, while
@@ -72,13 +54,16 @@ Glitches (don't crash the game, medium priority):
on that platform.
- Volume levels aren't maybe exactly as they should
- Color table transformations are very slow.
- We should try to get rid of excessive creation of new threads
- Circles of influence aren't shown the first time (after load?) a player
examines the starmap.
- Selling bio data gives an incomplete message: 'The 1000' [nothing].
- When out of fuel: "Fill all my fuel tanks to maximum capacity" ->
"Your ship's capacity is insufficient to hold that much fuel"
- Melee zooming may bug a little, ship sometimes flashes as big and then
small again etc
small again (some 3DO owner should check does this happen in original)
- Earth color can vary between different runs, it should be always blue
when not being near of it
Implementation bugs (low priority):
+1 -1
View File
@@ -1,6 +1,6 @@
For *.ani, *.sml, *.med, *.big files, each line is in following format:
filename transparent_color colormap_index clip_x clip_y clip_w clip_h hotspot_x hotspot_y
filename transparent_color colormap_index hotspot_x hotspot_y
Filename is string, all others are ints, -1 means value not used.
This information is parsed in libs/graphics/sdl/3do_getbody.c
+1 -1
View File
@@ -45,7 +45,7 @@ enum
int TFB_InitGraphics (int driver, int flags, int width, int height, int bpp);
void TFB_UninitGraphics ();
void TFB_UninitGraphics (void);
void TFB_ProcessEvents (void);
// 3DO Graphics Stuff
+7 -12
View File
@@ -52,8 +52,8 @@ blt (PRECT pClipRect, PRIMITIVEPTR PrimPtr)
GetFrameHotX (_CurFramePtr);
DrawCommand.y = pClipRect->corner.y -
GetFrameHotY (_CurFramePtr);
DrawCommand.w = img->NormalImg->clip_rect.w;
DrawCommand.h = img->NormalImg->clip_rect.h;
DrawCommand.w = img->NormalImg->w;
DrawCommand.h = img->NormalImg->h;
if (gscale != 0 && gscale != 256)
{
@@ -88,7 +88,7 @@ blt (PRECT pClipRect, PRIMITIVEPTR PrimPtr)
if (new_surf)
{
if (new_surf->format->BytesPerPixel > 1)
if (!new_surf->format->palette)
{
img->ScaledImg = TFB_DisplayFormatAlpha (new_surf);
if (img->ScaledImg)
@@ -157,7 +157,7 @@ blt (PRECT pClipRect, PRIMITIVEPTR PrimPtr)
}
else
{
SDL_Rect SDL_SrcRect, SDL_DstRect;
SDL_Rect SDL_DstRect;
TFB_Image *dst_img;
dst_img = ((TFB_Image *) ((BYTE *) _CurFramePtr +
@@ -165,19 +165,14 @@ blt (PRECT pClipRect, PRIMITIVEPTR PrimPtr)
LockMutex (dst_img->mutex);
SDL_SrcRect.x = (short) img->NormalImg->clip_rect.x;
SDL_SrcRect.y = (short) img->NormalImg->clip_rect.y;
SDL_SrcRect.w = (short) img->NormalImg->clip_rect.w;
SDL_SrcRect.h = (short) img->NormalImg->clip_rect.h;
SDL_DstRect.x = (short) pClipRect->corner.x -
GetFrameHotX (_CurFramePtr) + SDL_SrcRect.x;
GetFrameHotX (_CurFramePtr);
SDL_DstRect.y = (short) pClipRect->corner.y -
GetFrameHotY (_CurFramePtr) + SDL_SrcRect.y;
GetFrameHotY (_CurFramePtr);
SDL_BlitSurface (
img->NormalImg,
&SDL_SrcRect,
NULL,
dst_img->NormalImg,
&SDL_DstRect
);
@@ -30,10 +30,6 @@ typedef struct anidata
{
int transparent_color;
int colormap_index;
int clip_x;
int clip_y;
int clip_w;
int clip_h;
int hotspot_x;
int hotspot_y;
} AniData;
@@ -55,42 +51,20 @@ process_image (FRAMEPTR FramePtr, SDL_Surface *img[], AniData *ani, int cel_ct)
if (ani[cel_ct].transparent_color != -1)
SDL_SetColorKey(img[cel_ct], SDL_SRCCOLORKEY, ani[cel_ct].transparent_color);
if (ani[cel_ct].clip_x != -1)
img[cel_ct]->clip_rect.x = ani[cel_ct].clip_x;
if (ani[cel_ct].clip_y != -1)
img[cel_ct]->clip_rect.y = ani[cel_ct].clip_y;
if (ani[cel_ct].clip_w != -1)
img[cel_ct]->clip_rect.w = ani[cel_ct].clip_w;
if (ani[cel_ct].clip_h != -1)
img[cel_ct]->clip_rect.h = ani[cel_ct].clip_h;
if (ani[cel_ct].hotspot_x != -1)
hx = ani[cel_ct].hotspot_x;
if (ani[cel_ct].hotspot_y != -1)
hy = ani[cel_ct].hotspot_y;
}
hx -= img[cel_ct]->clip_rect.x;
hy -= img[cel_ct]->clip_rect.y;
FramePtr->DataOffs = (BYTE *)TFB_LoadImage (img[cel_ct]) - (BYTE *)FramePtr;
tfbimg = (TFB_Image *)((BYTE *)FramePtr + FramePtr->DataOffs);
tfbimg->colormap_index = ani[cel_ct].colormap_index;
img[cel_ct] = tfbimg->NormalImg;
hx += img[cel_ct]->clip_rect.x;
hy += img[cel_ct]->clip_rect.y;
SetFrameHotSpot (FramePtr, MAKE_HOT_SPOT (hx, hy));
SetFrameBounds (FramePtr, img[cel_ct]->clip_rect.w, img[cel_ct]->clip_rect.h);
#if 0
fprintf (stderr, "\thot[%d, %d], rect[%d, %d, %d, %d]\n",
hx, hy,
img[cel_ct]->clip_rect.x, img[cel_ct]->clip_rect.y,
img[cel_ct]->clip_rect.w, img[cel_ct]->clip_rect.h);
#endif
SetFrameBounds (FramePtr, img[cel_ct]->w, img[cel_ct]->h);
}
static void
@@ -150,17 +124,11 @@ process_font (FRAMEPTR FramePtr, SDL_Surface *img[], int cel_ct)
img[cel_ct] = new_surf;
hx -= img[cel_ct]->clip_rect.x;
hy -= img[cel_ct]->clip_rect.y;
FramePtr->DataOffs = (BYTE *)TFB_LoadImage (img[cel_ct]) - (BYTE *)FramePtr;
img[cel_ct] = ((TFB_Image *)((BYTE *)FramePtr + FramePtr->DataOffs))->NormalImg;
hx += img[cel_ct]->clip_rect.x;
hy += img[cel_ct]->clip_rect.y;
SetFrameHotSpot (FramePtr, MAKE_HOT_SPOT (hx, hy));
SetFrameBounds (FramePtr, img[cel_ct]->clip_rect.w, img[cel_ct]->clip_rect.h);
SetFrameBounds (FramePtr, img[cel_ct]->w, img[cel_ct]->h);
}
MEM_HANDLE
@@ -209,11 +177,6 @@ _GetCelData (FILE *fp, DWORD length)
&ani[cel_ct].transparent_color, &ani[cel_ct].colormap_index,
&ani[cel_ct].hotspot_x, &ani[cel_ct].hotspot_y);
ani[cel_ct].clip_x = -1;
ani[cel_ct].clip_y = -1;
ani[cel_ct].clip_w = -1;
ani[cel_ct].clip_h = -1;
if ((img[cel_ct] = IMG_Load (filename)) && img[cel_ct]->w > 0 &&
img[cel_ct]->h > 0 && img[cel_ct]->format->BitsPerPixel >= 8)
{
@@ -385,14 +348,14 @@ _GetFontData (FILE *fp, DWORD length)
int tune_amount = 0;
if (img[0]->clip_rect.h == 8)
if (img[0]->h == 8)
tune_amount = -1;
else if (img[0]->clip_rect.h == 9)
else if (img[0]->h == 9)
tune_amount = -2;
else if (img[0]->clip_rect.h > 9)
else if (img[0]->h > 9)
tune_amount = -3;
SetFrameHotSpot (FramePtr, MAKE_HOT_SPOT (0, img[0]->clip_rect.h + tune_amount));
SetFrameHotSpot (FramePtr, MAKE_HOT_SPOT (0, img[0]->h + tune_amount));
}
if (GetFrameHeight (FramePtr) > FontPtr->Leading)
+12 -76
View File
@@ -140,89 +140,29 @@ TFB_LoadImage (SDL_Surface *img)
TFB_Image *myImage;
myImage = (TFB_Image*) HMalloc (sizeof (TFB_Image));
myImage->mutex = CreateMutex();
myImage->mutex = CreateMutex ();
myImage->ScaledImg = NULL;
myImage->Palette = NULL;
myImage->colormap_index = -1;
if (img->format->BytesPerPixel == 1)
if (img->format->palette)
{
int x,y;
Uint8 *src_p,*dst_p;
SDL_Surface *full_surf;
SDL_Rect SDL_DstRect;
full_surf = SDL_CreateRGBSurface (SDL_SWSURFACE, img->clip_rect.w, img->clip_rect.h,
8, 0, 0, 0, 0);
SDL_DstRect.x = SDL_DstRect.y = 0;
SDL_LockSurface(img);
SDL_LockSurface(full_surf);
src_p = (Uint8*)img->pixels;
dst_p = (Uint8*)full_surf->pixels;
for (y = img->clip_rect.y; y < img->clip_rect.y + img->clip_rect.h; ++y)
{
for (x = img->clip_rect.x; x < img->clip_rect.x + img->clip_rect.w; ++x)
{
dst_p[(y - img->clip_rect.y) * full_surf->pitch + (x - img->clip_rect.x)]=
src_p[y * img->pitch + x];
}
}
full_surf->clip_rect.x = full_surf->clip_rect.y = 0;
full_surf->clip_rect.w = img->clip_rect.w;
full_surf->clip_rect.h = img->clip_rect.h;
int i;
myImage->Palette = (SDL_Color*) HMalloc (sizeof (SDL_Color) * 256);
for (x = 0; x < 256; ++x)
for (i = 0; i < 256; ++i)
{
myImage->Palette[x].r = img->format->palette->colors[x].r;
myImage->Palette[x].g = img->format->palette->colors[x].g;
myImage->Palette[x].b = img->format->palette->colors[x].b;
myImage->Palette[i].r = img->format->palette->colors[i].r;
myImage->Palette[i].g = img->format->palette->colors[i].g;
myImage->Palette[i].b = img->format->palette->colors[i].b;
}
SDL_SetColors (full_surf, myImage->Palette, 0, 256);
if (img->flags & SDL_SRCCOLORKEY)
{
SDL_SetColorKey (full_surf, SDL_SRCCOLORKEY, img->format->colorkey);
}
SDL_UnlockSurface(full_surf);
SDL_UnlockSurface(img);
SDL_FreeSurface (img);
img = full_surf;
myImage->NormalImg = img;
}
else if (img->format->BytesPerPixel == 2 || img->format->BytesPerPixel == 3) {
SDL_Surface *full_surf;
SDL_Rect SDL_DstRect;
full_surf = SDL_CreateRGBSurface (SDL_SWSURFACE, img->clip_rect.w, img->clip_rect.h,
32, 0x000000FF, 0x0000FF00, 0x00FF0000, 0xFF000000);
SDL_DstRect.x = SDL_DstRect.y = 0;
SDL_BlitSurface (img, &img->clip_rect, full_surf, &SDL_DstRect);
full_surf->clip_rect.x = full_surf->clip_rect.y = 0;
full_surf->clip_rect.w = img->clip_rect.w;
full_surf->clip_rect.h = img->clip_rect.h;
SDL_FreeSurface (img);
img = full_surf;
}
if (img->format->BytesPerPixel > 1)
else
{
myImage->Palette = NULL;
myImage->NormalImg = TFB_DisplayFormatAlpha (img);
if (myImage->NormalImg)
{
SDL_FreeSurface(img);
SDL_FreeSurface (img);
}
else
{
@@ -230,10 +170,6 @@ TFB_LoadImage (SDL_Surface *img)
myImage->NormalImg = img;
}
}
else
{
myImage->NormalImg = img;
}
return(myImage);
}
@@ -689,7 +625,7 @@ TFB_FlushGraphics () // Only call from main thread!!
else
surf = DC_image->NormalImg;
if (surf->format->BytesPerPixel == 1)
if (surf->format->palette)
{
if (DC.UsePalette)
{