Pachi: fixed background not showing on older devices

This commit is contained in:
pelya
2010-11-01 14:34:17 +02:00
parent 36c84cb7ff
commit 32643889bb
5 changed files with 46 additions and 25 deletions

View File

@@ -19,8 +19,8 @@ RedefinedKeys="SPACE RETURN"
AppTouchscreenKeyboardKeysAmount=1
AppTouchscreenKeyboardKeysAmountAutoFire=0
MultiABI=n
AppVersionCode=101
AppVersionName="1.01"
AppVersionCode=102
AppVersionName="1.02 - fixed level background not shown"
CompiledLibraries="sdl_mixer"
CustomBuildScript=n
AppCflags='-O2 -finline-functions'

View File

@@ -19,7 +19,7 @@
void load_gamedata()
{
background=LoadT8(DATADIR"/Tgfx/gamepanel.T8");
backs=LoadT8(DATADIR"/Tgfx/backgrounds.T8");
backs=LoadT8(DATADIR"/Tgfx/backgrounds.T8", false);
player=LoadT8(DATADIR"/Tgfx/pachi.T8");
monsters=LoadT8(DATADIR"/Tgfx/monsters.T8");
tiles=LoadT8(DATADIR"/Tgfx/tiles.T8");
@@ -69,6 +69,10 @@ void unload_gamedata()
SDL_FreeSurface(menufont);
SDL_FreeSurface(left);
SDL_FreeSurface(right);
if( currentBack )
SDL_FreeSurface(currentBack);
currentBack = NULL;
Mix_FreeChunk(exitlevel);
Mix_FreeChunk(jump);
@@ -242,6 +246,34 @@ void load_room()
}
fclose(bck);
if( currentBack )
SDL_FreeSurface(currentBack);
currentBack = SDL_CreateRGBSurface(SDL_HWSURFACE, R_back_x*R_maxbacks_h, R_back_y*R_maxbacks_v, screen->format->BitsPerPixel,
screen->format->Rmask, screen->format->Gmask, screen->format->Bmask, screen->format->Amask);
SDL_Rect backs_dst;
backs_dst.w = R_back_x;
backs_dst.h = R_back_y;
SDL_Rect backs_src;
backs_src.w = R_back_x;
backs_src.h = R_back_y;
for(x=0;x < R_maxbacks_h;x++)
{
for(y=0;y < R_maxbacks_v;y++)
{
backs_dst.x = (x*R_back_x);
backs_dst.y = (y*R_back_y);
backs_src.y = (int(R_backdata[x][y]/6) * R_back_y);
backs_src.x = (R_backdata[x][y] - (int(R_backdata[x][y]/6) * 6))*R_back_x;
SDL_BlitSurface(backs,&backs_src,currentBack,&backs_dst);
}
}
FILE *lvl = fopen(DATADIR"/data/rooms_v2.dat","rb");
filepos = (200 + ((R_current-1) * (R_maxtiles_h*R_maxtiles_v))+R_current); // filepos es el puntero del archivo, lo utilizamos para leer la habitacion donde estemos
fseek(lvl,filepos,SEEK_SET);

View File

@@ -69,7 +69,7 @@ void LoadT(SDL_Surface **Tsurface, char *str)
fclose(Tsrc);
}
SDL_Surface * LoadT8(char *str)
SDL_Surface * LoadT8(char *str, bool HW=true)
{
SDL_Surface *Tsurface;
FILE *Tsrc;
@@ -110,7 +110,10 @@ SDL_Surface * LoadT8(char *str)
}
if(SDL_MUSTLOCK(temp))
SDL_UnlockSurface(temp);
Tsurface = SDL_DisplayFormat(temp);
if( HW )
Tsurface = SDL_DisplayFormat(temp);
else
Tsurface = SDL_ConvertSurface(temp, screen->format, SDL_SWSURFACE);
SDL_FreeSurface(temp);
fclose(Tsrc);
return(Tsurface);

View File

@@ -164,26 +164,11 @@ void print_room()
SDL_FillRect(screen,&gamearea,0);
SDL_Rect backs_dst;
SDL_Rect backs_src;
SDL_Rect backs_dstbak;
backs_src.w = R_back_x;
backs_src.h = R_back_y;
backs_dst.w = R_back_x;
backs_dst.h = R_back_y;
for(x=0;x < R_maxbacks_h;x++)
{
for(y=0;y < R_maxbacks_v;y++)
{
backs_dst.x = R_gamearea_x + (x*R_back_x);
backs_dst.y = R_gamearea_y + (y*R_back_y);
backs_dstbak.x = x*R_back_x;
backs_dstbak.y = y*R_back_y;
backs_src.y = (int(R_backdata[x][y]/6) * R_back_y);
backs_src.x = (R_backdata[x][y] - (int(R_backdata[x][y]/6) * 6))*R_back_x;
SDL_BlitSurface(backs,&backs_src,screen,&backs_dst);
}
}
backs_dst.w = R_back_x*R_maxbacks_h;
backs_dst.h = R_back_y*R_maxbacks_v;
backs_dst.x = R_gamearea_x;
backs_dst.y = R_gamearea_y;
SDL_BlitSurface(currentBack,NULL,screen,&backs_dst);
SDL_Rect tiles_dst;
SDL_Rect tiles_dstbak;

View File

@@ -10,6 +10,7 @@ SDL_Surface *menufont1;
SDL_Surface *screen;
SDL_Surface *background;
SDL_Surface *backs;
SDL_Surface *currentBack = NULL;
SDL_Surface *tiles;
SDL_Surface *screenbak;