Pachi: fixed menu text not shown on G1

This commit is contained in:
pelya
2010-11-02 16:07:39 +02:00
parent 123f2c14df
commit 7c2479baa9
6 changed files with 74 additions and 14 deletions

View File

@@ -23,7 +23,7 @@ AppVersionCode=103
AppVersionName="1.03 - fixed monsters not shown on HTC G1"
CompiledLibraries="sdl_mixer"
CustomBuildScript=n
AppCflags='-O2 -finline-functions'
AppCflags='-O2 -finline-functions -Wno-write-strings'
AppLdflags=''
AppSubdirsBuild=''
AppUseCrystaXToolchain=n

View File

@@ -31,9 +31,9 @@
#include"proto.h"
#include"credits.h"
#include"gfx.h"
#include"text.h"
#include"init.h"
#include"gfx.h"
#include"input.h"
#include"file.h"
#include"output.h"

View File

@@ -26,7 +26,7 @@ void load_gamedata()
bright=LoadT8(DATADIR"/Tgfx/bright.T8");
left=LoadT8(DATADIR"/Tgfx/left.T8");
right=LoadT8(DATADIR"/Tgfx/right.T8");
menufont=LoadT8(DATADIR"/fonts/font32v.T8", false);
load_font( menufont, DATADIR"/fonts/font32v.T8" );
LoadT(&scorefont,DATADIR"/fonts/font16b.T");
LoadT(&scorefont1,DATADIR"/fonts/font16a.T");
LoadT(&scorefont2,DATADIR"/fonts/font16c.T");
@@ -34,7 +34,6 @@ void load_gamedata()
temp = SDL_CreateRGBSurface(SDL_SWSURFACE,736,448,16,0,0,0,0); //esto es para reestablecer la pantalla
screenbak = SDL_DisplayFormat(temp);
SDL_FreeSurface(temp);
SDL_SetColorKey(menufont, SDL_SRCCOLORKEY, SDL_MapRGB(menufont->format,0,255,0));
SDL_SetColorKey(player, SDL_SRCCOLORKEY, SDL_MapRGB(player->format,0,0,0)); // el negro es transparente
SDL_SetColorKey(tiles, SDL_SRCCOLORKEY, SDL_MapRGB(tiles->format,0,255,0));
SDL_SetColorKey(bright, SDL_SRCCOLORKEY, SDL_MapRGB(bright->format,0,255,0));
@@ -65,7 +64,7 @@ void unload_gamedata()
SDL_FreeSurface(scorefont);
SDL_FreeSurface(scorefont1);
SDL_FreeSurface(scorefont2);
SDL_FreeSurface(menufont);
unload_font(menufont);
SDL_FreeSurface(left);
SDL_FreeSurface(right);
@@ -202,11 +201,9 @@ void unload_helpgfx()
void load_menudata()
{
menufont=LoadT8(DATADIR"/fonts/font32v.T8", false);
menufont1=LoadT8(DATADIR"/fonts/font32r.T8", false);
load_font(menufont, DATADIR"/fonts/font32v.T8");
load_font(menufont1, DATADIR"/fonts/font32r.T8");
background=LoadT8(DATADIR"/Tgfx/intro.T8");
SDL_SetColorKey(menufont, SDL_SRCCOLORKEY, SDL_MapRGB(menufont->format,0,255,0));
SDL_SetColorKey(menufont1, SDL_SRCCOLORKEY, SDL_MapRGB(menufont1->format,0,255,0));
option=Mix_LoadWAV(DATADIR"/sounds/option.wav");
coderight=Mix_LoadWAV(DATADIR"/sounds/exit.wav");
@@ -215,8 +212,8 @@ void load_menudata()
}
void unload_menudata()
{
SDL_FreeSurface(menufont);
SDL_FreeSurface(menufont1);
unload_font(menufont);
unload_font(menufont1);
SDL_FreeSurface(background);
Mix_FreeChunk(option);
Mix_FreeChunk(coderight);

View File

@@ -71,7 +71,7 @@ void do_code()
void do_menu()
{
SDL_Delay(1);
font = menufont;
SDL_Surface ** font = menufont;
int menustartpos=156;

View File

@@ -1,10 +1,11 @@
// --- Fonts
enum { FONT_CHUNKS = 2};
SDL_Surface *font;
SDL_Surface *scorefont;
SDL_Surface *scorefont1;
SDL_Surface *scorefont2;
SDL_Surface *menufont;
SDL_Surface *menufont1;
SDL_Surface *menufont[FONT_CHUNKS];
SDL_Surface *menufont1[FONT_CHUNKS];
// --- Screen
SDL_Surface *screen;

View File

@@ -1,3 +1,36 @@
void print_text(SDL_Surface **font, SDL_Surface *surface, int font_w, int font_h, int text_x, int text_y, char *str, ...) //Rutina para imprimir texto estatico en la pantalla
{
SDL_Rect srctxt; // la posicion donde se encuentra el caracter en el bitmap
SDL_Rect dsttxt; // la posicion donde se imprimira el texto
char texto [100];
va_list ap;
va_start(ap, str);
vsprintf(texto, str, ap);
va_end(ap);
srctxt.w = font_w;
srctxt.h = font_h;
srctxt.y = 0;
int linecounter = 0 ; // este contador se utiliza para saber en que linea imprimimos el texto
int charpos = 0;
for(int charcounter = 0; charcounter <= (strlen(texto));charcounter++)
{
int curchar=texto[charcounter];
if(curchar == 94)
{
linecounter++;
charpos = -1;
}
srctxt.x = (curchar >= 64 ? curchar - 62 : curchar - 32) * font_w;
dsttxt.x = (text_x + (charpos * font_w));
dsttxt.y = (text_y + (linecounter * font_h));
charpos++;
SDL_BlitSurface (font[ (curchar >= 64 ? 1 : 0) ],&srctxt,surface,&dsttxt);
}
}
void print_text(SDL_Surface *font, SDL_Surface *surface, int font_w, int font_h, int text_x, int text_y, char *str, ...) //Rutina para imprimir texto estatico en la pantalla
{
SDL_Rect srctxt; // la posicion donde se encuentra el caracter en el bitmap
@@ -30,3 +63,32 @@ void print_text(SDL_Surface *font, SDL_Surface *surface, int font_w, int font_h,
SDL_BlitSurface (font,&srctxt,surface,&dsttxt);
}
}
void load_font(SDL_Surface **font, char * file)
{
SDL_Surface * temp = LoadT8(file, false);
font[0] = SDL_CreateRGBSurface(SDL_HWSURFACE, temp->w/2, temp->h, screen->format->BitsPerPixel,
screen->format->Rmask, screen->format->Gmask, screen->format->Bmask, screen->format->Amask);
font[1] = SDL_CreateRGBSurface(SDL_HWSURFACE, temp->w/2, temp->h, screen->format->BitsPerPixel,
screen->format->Rmask, screen->format->Gmask, screen->format->Bmask, screen->format->Amask);
SDL_Rect r;
r.w = temp->w/2;
r.h = temp->h;
r.x = 0;
r.y = 0;
SDL_BlitSurface(temp, &r, font[0], NULL);
SDL_SetColorKey(font[0], SDL_SRCCOLORKEY, SDL_MapRGB(font[0]->format,0,255,0));
r.x = temp->w/2;
SDL_BlitSurface(temp, &r, font[1], NULL);
SDL_SetColorKey(font[1], SDL_SRCCOLORKEY, SDL_MapRGB(font[0]->format,0,255,0));
};
void unload_font(SDL_Surface **font)
{
if( font[0] )
SDL_FreeSurface(font[0]);
font[0] = NULL;
if( font[1] )
SDL_FreeSurface(font[1]);
font[1] = NULL;
}