mirror of
https://github.com/yann64/haikuports.git
synced 2026-04-09 05:10:05 +02:00
super_transball, enable x86_64 (#4074)
This commit is contained in:
committed by
Jérôme Duval
parent
40625570b9
commit
628a745159
@@ -1,4 +1,4 @@
|
||||
From d5e22939a27c71bc0e55a56623b7ea83dceca155 Mon Sep 17 00:00:00 2001
|
||||
From dbfe34cd7668db08ae002cb895ee2e26ac7813bf Mon Sep 17 00:00:00 2001
|
||||
From: Adrien Destugues <pulkomandy@pulkomandy.tk>
|
||||
Date: Sun, 19 Jan 2014 17:50:47 +0100
|
||||
Subject: Split writable files to writable directory
|
||||
@@ -25,139 +25,139 @@ index 08a898f..779f7bd 100644
|
||||
|
||||
clean:
|
||||
diff --git a/sources/configuration.cpp b/sources/configuration.cpp
|
||||
index b39fdc2..8ef89f9 100644
|
||||
index cb19a04..a84410b 100644
|
||||
--- a/sources/configuration.cpp
|
||||
+++ b/sources/configuration.cpp
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "stdio.h"
|
||||
#include "stdio.h"
|
||||
+#include <unistd.h>
|
||||
|
||||
#include "SDL.h"
|
||||
|
||||
|
||||
#include "SDL.h"
|
||||
|
||||
@@ -9,13 +10,17 @@ extern SDLKey PAUSE_KEY;
|
||||
extern bool fullscreen;
|
||||
extern int PIXEL_SIZE;
|
||||
|
||||
extern bool fullscreen;
|
||||
extern int PIXEL_SIZE;
|
||||
|
||||
+extern char *datadir;
|
||||
+extern char *confdir;
|
||||
|
||||
bool load_configuration(void)
|
||||
{
|
||||
int a,b,c,d,e,f,g;
|
||||
FILE *fp;
|
||||
|
||||
|
||||
bool load_configuration(void)
|
||||
{
|
||||
int a,b,c,d,e,f,g;
|
||||
FILE *fp;
|
||||
|
||||
+ chdir(confdir);
|
||||
fp=fopen("transball.cfg","r");
|
||||
fp=fopen("transball.cfg","r");
|
||||
+ chdir(datadir);
|
||||
|
||||
if (fp==0) return false;
|
||||
|
||||
|
||||
if (fp==0) return false;
|
||||
|
||||
@@ -46,7 +51,9 @@ void save_configuration(void)
|
||||
{
|
||||
FILE *fp;
|
||||
|
||||
{
|
||||
FILE *fp;
|
||||
|
||||
+ chdir(confdir);
|
||||
fp=fopen("transball.cfg","w");
|
||||
fp=fopen("transball.cfg","w");
|
||||
+ chdir(datadir);
|
||||
|
||||
if (fp==0) return;
|
||||
|
||||
|
||||
if (fp==0) return;
|
||||
|
||||
diff --git a/sources/encoder.cpp b/sources/encoder.cpp
|
||||
index f2d4945..9780520 100644
|
||||
index 1ed931f..02e1d80 100644
|
||||
--- a/sources/encoder.cpp
|
||||
+++ b/sources/encoder.cpp
|
||||
@@ -1,4 +1,8 @@
|
||||
#include "stdio.h"
|
||||
#include "stdio.h"
|
||||
+#include "unistd.h"
|
||||
+
|
||||
+extern char *confdir;
|
||||
+extern char *datadir;
|
||||
|
||||
void encode(char *in,char *out)
|
||||
{
|
||||
|
||||
void encode(char *in,char *out)
|
||||
{
|
||||
@@ -9,8 +13,11 @@ void encode(char *in,char *out)
|
||||
FILE *fpin;
|
||||
FILE *fpout;
|
||||
|
||||
FILE *fpin;
|
||||
FILE *fpout;
|
||||
|
||||
+ chdir(datadir);
|
||||
fpin=fopen(in,"rb");
|
||||
fpin=fopen(in,"rb");
|
||||
+ chdir(confdir);
|
||||
fpout=fopen(out,"wb");
|
||||
fpout=fopen(out,"wb");
|
||||
+ chdir(datadir);
|
||||
if (fpin==0 || fpout==0) return;
|
||||
|
||||
do{
|
||||
if (fpin==0 || fpout==0) return;
|
||||
|
||||
do{
|
||||
@@ -40,8 +47,11 @@ void decode(char *in,char *out)
|
||||
FILE *fpin;
|
||||
FILE *fpout;
|
||||
|
||||
FILE *fpin;
|
||||
FILE *fpout;
|
||||
|
||||
+ chdir(datadir);
|
||||
fpin=fopen(in,"rb");
|
||||
fpin=fopen(in,"rb");
|
||||
+ chdir(confdir);
|
||||
fpout=fopen(out,"wb");
|
||||
fpout=fopen(out,"wb");
|
||||
+ chdir(datadir);
|
||||
if (fpin==0 || fpout==0) return;
|
||||
|
||||
do{
|
||||
if (fpin==0 || fpout==0) return;
|
||||
|
||||
do{
|
||||
diff --git a/sources/game.cpp b/sources/game.cpp
|
||||
index 6429e2d..901e3ee 100644
|
||||
index 7547faf..73a9af1 100644
|
||||
--- a/sources/game.cpp
|
||||
+++ b/sources/game.cpp
|
||||
@@ -8,6 +8,7 @@
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
+#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "SDL/SDL.h"
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "SDL/SDL.h"
|
||||
@@ -84,6 +85,9 @@ extern TRANSBALL *game;
|
||||
/* Frames per second counter: */
|
||||
extern int frames_per_sec;
|
||||
|
||||
/* Frames per second counter: */
|
||||
extern int frames_per_sec;
|
||||
|
||||
+extern char *datadir;
|
||||
+extern char *confdir;
|
||||
+
|
||||
FILE *replayfile;
|
||||
int replaynum;
|
||||
int replay_source=0;
|
||||
FILE *replayfile;
|
||||
int replaynum;
|
||||
int replay_source=0;
|
||||
@@ -92,7 +96,7 @@ int replay_source=0;
|
||||
SDLKey THRUST_KEY=SDLK_q,ANTITHRUST_KEY=SDLK_a,LEFT_KEY=SDLK_o,RIGHT_KEY=SDLK_p;
|
||||
SDLKey FIRE_KEY=SDLK_SPACE,ATRACTOR_KEY=SDLK_RETURN;
|
||||
SDLKey PAUSE_KEY=SDLK_F1;
|
||||
-bool pause=false;
|
||||
SDLKey THRUST_KEY=SDLK_q,ANTITHRUST_KEY=SDLK_a,LEFT_KEY=SDLK_o,RIGHT_KEY=SDLK_p;
|
||||
SDLKey FIRE_KEY=SDLK_SPACE,ATRACTOR_KEY=SDLK_RETURN;
|
||||
SDLKey PAUSE_KEY=SDLK_F1;
|
||||
-bool pause=false;
|
||||
+bool paused=false;
|
||||
|
||||
unsigned char old_keyboard[SDLK_LAST];
|
||||
SDL_Surface *image=0,*image2=0; /* For the tittle screen, etc. */
|
||||
|
||||
unsigned char old_keyboard[SDLK_LAST];
|
||||
SDL_Surface *image=0,*image2=0; /* For the tittle screen, etc. */
|
||||
@@ -133,8 +137,10 @@ bool gamecycle(SDL_Surface *screen,int sx,int sy)
|
||||
strcpy(tmp,"maps/");
|
||||
strcat(tmp,levelpack);
|
||||
|
||||
strcpy(tmp,"maps/");
|
||||
strcat(tmp,levelpack);
|
||||
|
||||
+ chdir(datadir);
|
||||
decode(tmp,"decoding.tmp");
|
||||
|
||||
decode(tmp,"decoding.tmp");
|
||||
|
||||
+ chdir(confdir);
|
||||
fp=fopen("decoding.tmp","r+");
|
||||
if (fp!=0) {
|
||||
fscanf(fp,"%i",&NLEVELS);
|
||||
fp=fopen("decoding.tmp","r+");
|
||||
if (fp!=0) {
|
||||
fscanf(fp,"%i",&NLEVELS);
|
||||
@@ -167,6 +173,8 @@ bool gamecycle(SDL_Surface *screen,int sx,int sy)
|
||||
|
||||
if (NLEVELS==-1) return false;
|
||||
|
||||
|
||||
if (NLEVELS==-1) return false;
|
||||
|
||||
+ chdir(datadir);
|
||||
+
|
||||
switch(STATE) {
|
||||
case 0: if (!state_logo_cycle(screen,sx,sy,keyboard)) return false;
|
||||
break;
|
||||
switch(STATE) {
|
||||
case 0: if (!state_logo_cycle(screen,sx,sy,keyboard)) return false;
|
||||
break;
|
||||
diff --git a/sources/main.cpp b/sources/main.cpp
|
||||
index 285740a..b633601 100644
|
||||
index 6aac085..21e886e 100644
|
||||
--- a/sources/main.cpp
|
||||
+++ b/sources/main.cpp
|
||||
@@ -12,6 +12,14 @@
|
||||
#include "SDL_mixer.h"
|
||||
#include "sge.h"
|
||||
|
||||
#include "SDL_mixer.h"
|
||||
#include "sge.h"
|
||||
|
||||
+#include <libgen.h>
|
||||
+#include <string.h>
|
||||
+#include <unistd.h>
|
||||
@@ -166,22 +166,22 @@ index 285740a..b633601 100644
|
||||
+#include <storage/FindDirectory.h>
|
||||
+#include <storage/Path.h>
|
||||
+
|
||||
#include "fonts.h"
|
||||
#include "list.h"
|
||||
|
||||
#include "fonts.h"
|
||||
#include "list.h"
|
||||
|
||||
@@ -42,6 +50,8 @@ int frames_per_sec=0;
|
||||
int frames_per_sec_tmp=0;
|
||||
int init_time=0;
|
||||
|
||||
int frames_per_sec_tmp=0;
|
||||
int init_time=0;
|
||||
|
||||
+char *datadir;
|
||||
+char *confdir;
|
||||
|
||||
/* Surfaces: */
|
||||
SDL_Surface *screen_sfc=0,*buffer_screen_sfc=0;
|
||||
|
||||
/* Surfaces: */
|
||||
SDL_Surface *screen_sfc=0,*buffer_screen_sfc=0;
|
||||
@@ -126,6 +136,33 @@ int main(int argc, char** argv)
|
||||
setupTickCount();
|
||||
#endif
|
||||
|
||||
setupTickCount();
|
||||
#endif
|
||||
|
||||
+ mode_t mode;
|
||||
+ FILE *cfg;
|
||||
+
|
||||
@@ -209,36 +209,36 @@ index 285740a..b633601 100644
|
||||
+
|
||||
+ chdir(datadir);
|
||||
+
|
||||
int time,act_time;
|
||||
SDL_Event event;
|
||||
bool quit = false;
|
||||
int time,act_time;
|
||||
SDL_Event event;
|
||||
bool quit = false;
|
||||
diff --git a/sources/maps.cpp b/sources/maps.cpp
|
||||
index 56df6f7..f1506c7 100644
|
||||
index 4c6a278..c6cba5a 100644
|
||||
--- a/sources/maps.cpp
|
||||
+++ b/sources/maps.cpp
|
||||
@@ -1,4 +1,5 @@
|
||||
#include <stdio.h>
|
||||
#include <stdio.h>
|
||||
+#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include "SDL/SDL.h"
|
||||
#include "SDL_mixer.h"
|
||||
#include <stdlib.h>
|
||||
#include "SDL/SDL.h"
|
||||
#include "SDL_mixer.h"
|
||||
@@ -13,6 +14,8 @@
|
||||
#define EMPTY_ROWS 8
|
||||
#define FACTOR 512
|
||||
|
||||
#define EMPTY_ROWS 8
|
||||
#define FACTOR 512
|
||||
|
||||
+extern char *datadir;
|
||||
+extern char *confdir;
|
||||
|
||||
TRANSBALL_MAP::TRANSBALL_MAP(char *file)
|
||||
{
|
||||
|
||||
TRANSBALL_MAP::TRANSBALL_MAP(char *file)
|
||||
{
|
||||
@@ -25,6 +28,7 @@ TRANSBALL_MAP::TRANSBALL_MAP(char *file)
|
||||
S_enemyhit=0;
|
||||
S_switch=0;
|
||||
|
||||
S_enemyhit=0;
|
||||
S_switch=0;
|
||||
|
||||
+ chdir(datadir);
|
||||
fp=fopen(file,"r");
|
||||
if (fp==0) {
|
||||
sx=0;
|
||||
fp=fopen(file,"r");
|
||||
if (fp==0) {
|
||||
sx=0;
|
||||
diff --git a/sources/replays.cpp b/sources/replays.cpp
|
||||
index 1d4e885..5d95fc5 100644
|
||||
--- a/sources/replays.cpp
|
||||
@@ -643,10 +643,10 @@ index da45793..20c5017 100644
|
||||
extern SDL_Surface *image,*image2;
|
||||
extern char edit_text[80];
|
||||
--
|
||||
1.8.3.4
|
||||
2.21.0
|
||||
|
||||
|
||||
From b382be38bd296d72071c135e9fddd6872040c532 Mon Sep 17 00:00:00 2001
|
||||
From 8efc8de6652741210ff99f73a5994f7fb878e4b4 Mon Sep 17 00:00:00 2001
|
||||
From: Adrien Destugues <pulkomandy@pulkomandy.tk>
|
||||
Date: Sun, 19 Jan 2014 18:56:20 +0100
|
||||
Subject: Avoid waste of CPU.
|
||||
@@ -654,18 +654,494 @@ Subject: Avoid waste of CPU.
|
||||
We can sleep longer than 1ms without slowing down the game.
|
||||
|
||||
diff --git a/sources/main.cpp b/sources/main.cpp
|
||||
index b633601..5445993 100644
|
||||
index 21e886e..9c6d300 100644
|
||||
--- a/sources/main.cpp
|
||||
+++ b/sources/main.cpp
|
||||
@@ -284,7 +284,7 @@ int main(int argc, char** argv)
|
||||
} /* if */
|
||||
SDL_Flip(screen_sfc);
|
||||
}
|
||||
- SDL_Delay(1);
|
||||
} /* if */
|
||||
SDL_Flip(screen_sfc);
|
||||
}
|
||||
- SDL_Delay(1);
|
||||
+ SDL_Delay(REDRAWING_PERIOD);
|
||||
}
|
||||
|
||||
fonts_termination();
|
||||
}
|
||||
|
||||
fonts_termination();
|
||||
--
|
||||
1.8.3.4
|
||||
2.21.0
|
||||
|
||||
|
||||
From db582420926db90bbc0892c10a5dfb6fa5ef9877 Mon Sep 17 00:00:00 2001
|
||||
From: begasus <begasus@gmail.com>
|
||||
Date: Mon, 29 Jul 2019 20:32:19 +0200
|
||||
Subject: Fix build with gcc8
|
||||
|
||||
|
||||
diff --git a/sources/auxiliar.cpp b/sources/auxiliar.cpp
|
||||
index 4a27ad7..ae3b73f 100644
|
||||
--- a/sources/auxiliar.cpp
|
||||
+++ b/sources/auxiliar.cpp
|
||||
@@ -1,229 +1,234 @@
|
||||
-
|
||||
-#ifdef _WIN32
|
||||
-#else
|
||||
-#include <stddef.h>
|
||||
-#include <sys/types.h>
|
||||
-#include <dirent.h>
|
||||
-#include "ctype.h"
|
||||
-#endif
|
||||
-
|
||||
-#include <stdio.h>
|
||||
-#include <stdlib.h>
|
||||
-#include <string.h>
|
||||
-#include "SDL/SDL.h"
|
||||
-#include "SDL_image.h"
|
||||
-
|
||||
-#include "auxiliar.h"
|
||||
-
|
||||
-
|
||||
-#ifndef _WIN32
|
||||
-char *strupr(char *ptr)
|
||||
-{
|
||||
- if (ptr!=0) {
|
||||
- char *p=new char[strlen(ptr)+1];
|
||||
-
|
||||
- while(*p!=0) {
|
||||
- *p=toupper(*p);
|
||||
- p++;
|
||||
- } /* while */
|
||||
- } /* if */
|
||||
-
|
||||
- return ptr;
|
||||
-}
|
||||
-
|
||||
+
|
||||
|
||||
+#ifdef _WIN32
|
||||
|
||||
+#else
|
||||
|
||||
+#include <stddef.h>
|
||||
|
||||
+#include <sys/types.h>
|
||||
|
||||
+#include <dirent.h>
|
||||
|
||||
+#include "ctype.h"
|
||||
|
||||
+#endif
|
||||
|
||||
+
|
||||
|
||||
+#include <stdio.h>
|
||||
|
||||
+#include <stdlib.h>
|
||||
|
||||
+#include <string.h>
|
||||
|
||||
+#include "SDL/SDL.h"
|
||||
|
||||
+#include "SDL_image.h"
|
||||
|
||||
+
|
||||
|
||||
+#ifdef __HAIKU__
|
||||
+typedef int boolean;
|
||||
+#define HAVE_BOOLEAN
|
||||
#endif
|
||||
|
||||
-
|
||||
-SDL_Surface *load_maskedimage(char *imagefile,char *maskfile,char *path)
|
||||
-{
|
||||
- char name[256];
|
||||
-
|
||||
- SDL_Surface *res;
|
||||
- SDL_Surface *tmp;
|
||||
- SDL_Surface *mask;
|
||||
-
|
||||
- sprintf(name,"%s%s",path,imagefile);
|
||||
- tmp=IMG_Load(name);
|
||||
- sprintf(name,"%s%s",path,imagefile);
|
||||
- mask=IMG_Load(name);
|
||||
-
|
||||
- if (tmp==0 ||
|
||||
- mask==0) return false;
|
||||
-
|
||||
- res=SDL_DisplayFormatAlpha(tmp);
|
||||
-
|
||||
- /* Aplicar la máscara: */
|
||||
- {
|
||||
- int x,y;
|
||||
- Uint8 r,g,b,a;
|
||||
- Uint32 v;
|
||||
-
|
||||
- for(y=0;y<mask->h;y++) {
|
||||
- for(x=0;x<mask->w;x++) {
|
||||
- v=getpixel(res,x,y);
|
||||
- SDL_GetRGBA(v,res->format,&r,&g,&b,&a);
|
||||
- v=getpixel(mask,x,y);
|
||||
- if (v!=0) a=255;
|
||||
- else a=0;
|
||||
- v=SDL_MapRGBA(res->format,r,g,b,a);
|
||||
- putpixel(res,x,y,v);
|
||||
- } /* for */
|
||||
- } /* for */
|
||||
- }
|
||||
-
|
||||
- SDL_FreeSurface(tmp);
|
||||
- SDL_FreeSurface(mask);
|
||||
-
|
||||
- return res;
|
||||
-} /* load_maskedimage */
|
||||
-
|
||||
-
|
||||
-void putpixel(SDL_Surface *surface, int x, int y, Uint32 pixel)
|
||||
-{
|
||||
- SDL_Rect clip;
|
||||
- int bpp = surface->format->BytesPerPixel;
|
||||
-
|
||||
- SDL_GetClipRect(surface,&clip);
|
||||
-
|
||||
- if (x<clip.x || x>=clip.x+clip.w ||
|
||||
- y<clip.y || y>=clip.y+clip.h) return;
|
||||
-
|
||||
- if (x<0 || x>=surface->w ||
|
||||
- y<0 || y>=surface->h) return;
|
||||
-
|
||||
- Uint8 *p = (Uint8 *)surface->pixels + y * surface->pitch + x * bpp;
|
||||
-
|
||||
- switch(bpp) {
|
||||
- case 1:
|
||||
- *p = pixel;
|
||||
- break;
|
||||
-
|
||||
- case 2:
|
||||
- *(Uint16 *)p = pixel;
|
||||
- break;
|
||||
-
|
||||
- case 3:
|
||||
- if(SDL_BYTEORDER == SDL_BIG_ENDIAN) {
|
||||
- p[0] = (pixel >> 16) & 0xff;
|
||||
- p[1] = (pixel >> 8) & 0xff;
|
||||
- p[2] = pixel & 0xff;
|
||||
- } else {
|
||||
- p[0] = pixel & 0xff;
|
||||
- p[1] = (pixel >> 8) & 0xff;
|
||||
- p[2] = (pixel >> 16) & 0xff;
|
||||
- }
|
||||
- break;
|
||||
-
|
||||
- case 4:
|
||||
- *(Uint32 *)p = pixel;
|
||||
- break;
|
||||
- }
|
||||
-}
|
||||
-
|
||||
-
|
||||
-Uint32 getpixel(SDL_Surface *surface, int x, int y)
|
||||
-{
|
||||
- int bpp = surface->format->BytesPerPixel;
|
||||
-
|
||||
- if (x<0 || x>=surface->w ||
|
||||
- y<0 || y>=surface->h) return 0;
|
||||
-
|
||||
- Uint8 *p = (Uint8 *)surface->pixels + y * surface->pitch + x * bpp;
|
||||
-
|
||||
- switch(bpp) {
|
||||
- case 1:
|
||||
- return *p;
|
||||
-
|
||||
- case 2:
|
||||
- return *(Uint16 *)p;
|
||||
-
|
||||
- case 3:
|
||||
- if(SDL_BYTEORDER == SDL_BIG_ENDIAN)
|
||||
- return p[0] << 16 | p[1] << 8 | p[2];
|
||||
- else
|
||||
- return p[0] | p[1] << 8 | p[2] << 16;
|
||||
-
|
||||
- case 4:
|
||||
- return *(Uint32 *)p;
|
||||
-
|
||||
- default:
|
||||
- return 0;
|
||||
- }
|
||||
-}
|
||||
-
|
||||
-
|
||||
-void surface_fader(SDL_Surface *surface,float r_factor,float g_factor,float b_factor,float a_factor,SDL_Rect *r)
|
||||
-{
|
||||
- SDL_Rect r2;
|
||||
- int i,x,y,offs;
|
||||
- Uint8 rtable[256],gtable[256],btable[256],atable[256];
|
||||
- Uint8 *pixels;
|
||||
- SDL_Surface *tmp;
|
||||
-
|
||||
- if (r==0) {
|
||||
- r2.x=0;
|
||||
- r2.y=0;
|
||||
- r2.w=surface->w;
|
||||
- r2.h=surface->h;
|
||||
- r=&r2;
|
||||
- } /* if */
|
||||
-
|
||||
- if (surface->format->BytesPerPixel!=4 ||
|
||||
- (r_factor==1.0 &&
|
||||
- g_factor==1.0 &&
|
||||
- b_factor==1.0 &&
|
||||
- a_factor==1.0)) return;
|
||||
-
|
||||
- for(i=0;i<256;i++) {
|
||||
- rtable[i]=(Uint8)(i*r_factor);
|
||||
- gtable[i]=(Uint8)(i*g_factor);
|
||||
- btable[i]=(Uint8)(i*b_factor);
|
||||
- atable[i]=(Uint8)(i*a_factor);
|
||||
- } /* for */
|
||||
-
|
||||
- if ((surface->flags&SDL_HWSURFACE)!=0) {
|
||||
- /* HARDWARE SURFACE!!!: */
|
||||
- tmp=SDL_CreateRGBSurface(SDL_SWSURFACE,surface->w,surface->h,32,0,0,0,0);
|
||||
- SDL_BlitSurface(surface,0,tmp,0);
|
||||
- SDL_LockSurface(tmp);
|
||||
- pixels = (Uint8 *)(tmp->pixels);
|
||||
- } else {
|
||||
- SDL_LockSurface(surface);
|
||||
- pixels = (Uint8 *)(surface->pixels);
|
||||
- } /* if */
|
||||
-
|
||||
- for(y=r->y;y<r->y+r->h && y<surface->h;y++) {
|
||||
- for(x=r->x,offs=y*surface->pitch+r->x*4;x<r->x+r->w && x<surface->w;x++,offs+=4) {
|
||||
- pixels[offs+ROFFSET]=rtable[pixels[offs+ROFFSET]];
|
||||
- pixels[offs+GOFFSET]=gtable[pixels[offs+GOFFSET]];
|
||||
- pixels[offs+BOFFSET]=btable[pixels[offs+BOFFSET]];
|
||||
- pixels[offs+AOFFSET]=atable[pixels[offs+AOFFSET]];
|
||||
- } /* for */
|
||||
- } /* for */
|
||||
-
|
||||
- if ((surface->flags&SDL_HWSURFACE)!=0) {
|
||||
- /* HARDWARE SURFACE!!!: */
|
||||
- SDL_UnlockSurface(tmp);
|
||||
- SDL_BlitSurface(tmp,0,surface,0);
|
||||
- SDL_FreeSurface(tmp);
|
||||
- } else {
|
||||
- SDL_UnlockSurface(surface);
|
||||
- } /* if */
|
||||
-
|
||||
-
|
||||
-} /* surface_fader */
|
||||
-
|
||||
-void rectangle(SDL_Surface *surface, int x, int y, int w, int h, Uint32 pixel)
|
||||
-{
|
||||
- int i;
|
||||
-
|
||||
- for(i=0;i<w;i++) {
|
||||
- putpixel(surface,x+i,y,pixel);
|
||||
- putpixel(surface,x+i,y+h,pixel);
|
||||
- } /* for */
|
||||
- for(i=0;i<=h;i++) {
|
||||
- putpixel(surface,x,y+i,pixel);
|
||||
- putpixel(surface,x+w,y+i,pixel);
|
||||
- } /* for */
|
||||
-} /* rectangle */
|
||||
-
|
||||
+#include "auxiliar.h"
|
||||
|
||||
+
|
||||
|
||||
+
|
||||
|
||||
+#ifndef _WIN32
|
||||
|
||||
+char *strupr(char *ptr)
|
||||
|
||||
+{
|
||||
|
||||
+ if (ptr!=0) {
|
||||
|
||||
+ char *p=new char[strlen(ptr)+1];
|
||||
|
||||
+
|
||||
|
||||
+ while(*p!=0) {
|
||||
|
||||
+ *p=toupper(*p);
|
||||
|
||||
+ p++;
|
||||
|
||||
+ } /* while */
|
||||
|
||||
+ } /* if */
|
||||
|
||||
+
|
||||
|
||||
+ return ptr;
|
||||
|
||||
+}
|
||||
|
||||
+
|
||||
|
||||
+#endif
|
||||
|
||||
+
|
||||
|
||||
+
|
||||
|
||||
+SDL_Surface *load_maskedimage(char *imagefile,char *maskfile,char *path)
|
||||
|
||||
+{
|
||||
|
||||
+ char name[256];
|
||||
|
||||
+
|
||||
|
||||
+ SDL_Surface *res;
|
||||
|
||||
+ SDL_Surface *tmp;
|
||||
|
||||
+ SDL_Surface *mask;
|
||||
|
||||
+
|
||||
|
||||
+ sprintf(name,"%s%s",path,imagefile);
|
||||
|
||||
+ tmp=IMG_Load(name);
|
||||
|
||||
+ sprintf(name,"%s%s",path,imagefile);
|
||||
|
||||
+ mask=IMG_Load(name);
|
||||
|
||||
+
|
||||
|
||||
+ if (tmp==0 ||
|
||||
|
||||
+ mask==0) return (boolean)false;
|
||||
|
||||
+
|
||||
|
||||
+ res=SDL_DisplayFormatAlpha(tmp);
|
||||
|
||||
+
|
||||
|
||||
+ /* Aplicar la máscara: */
|
||||
|
||||
+ {
|
||||
|
||||
+ int x,y;
|
||||
|
||||
+ Uint8 r,g,b,a;
|
||||
|
||||
+ Uint32 v;
|
||||
|
||||
+
|
||||
|
||||
+ for(y=0;y<mask->h;y++) {
|
||||
|
||||
+ for(x=0;x<mask->w;x++) {
|
||||
|
||||
+ v=getpixel(res,x,y);
|
||||
|
||||
+ SDL_GetRGBA(v,res->format,&r,&g,&b,&a);
|
||||
|
||||
+ v=getpixel(mask,x,y);
|
||||
|
||||
+ if (v!=0) a=255;
|
||||
|
||||
+ else a=0;
|
||||
|
||||
+ v=SDL_MapRGBA(res->format,r,g,b,a);
|
||||
|
||||
+ putpixel(res,x,y,v);
|
||||
|
||||
+ } /* for */
|
||||
|
||||
+ } /* for */
|
||||
|
||||
+ }
|
||||
|
||||
+
|
||||
|
||||
+ SDL_FreeSurface(tmp);
|
||||
|
||||
+ SDL_FreeSurface(mask);
|
||||
|
||||
+
|
||||
|
||||
+ return res;
|
||||
|
||||
+} /* load_maskedimage */
|
||||
|
||||
+
|
||||
|
||||
+
|
||||
|
||||
+void putpixel(SDL_Surface *surface, int x, int y, Uint32 pixel)
|
||||
|
||||
+{
|
||||
|
||||
+ SDL_Rect clip;
|
||||
|
||||
+ int bpp = surface->format->BytesPerPixel;
|
||||
|
||||
+
|
||||
|
||||
+ SDL_GetClipRect(surface,&clip);
|
||||
|
||||
+
|
||||
|
||||
+ if (x<clip.x || x>=clip.x+clip.w ||
|
||||
|
||||
+ y<clip.y || y>=clip.y+clip.h) return;
|
||||
|
||||
+
|
||||
|
||||
+ if (x<0 || x>=surface->w ||
|
||||
|
||||
+ y<0 || y>=surface->h) return;
|
||||
|
||||
+
|
||||
|
||||
+ Uint8 *p = (Uint8 *)surface->pixels + y * surface->pitch + x * bpp;
|
||||
|
||||
+
|
||||
|
||||
+ switch(bpp) {
|
||||
|
||||
+ case 1:
|
||||
|
||||
+ *p = pixel;
|
||||
|
||||
+ break;
|
||||
|
||||
+
|
||||
|
||||
+ case 2:
|
||||
|
||||
+ *(Uint16 *)p = pixel;
|
||||
|
||||
+ break;
|
||||
|
||||
+
|
||||
|
||||
+ case 3:
|
||||
|
||||
+ if(SDL_BYTEORDER == SDL_BIG_ENDIAN) {
|
||||
|
||||
+ p[0] = (pixel >> 16) & 0xff;
|
||||
|
||||
+ p[1] = (pixel >> 8) & 0xff;
|
||||
|
||||
+ p[2] = pixel & 0xff;
|
||||
|
||||
+ } else {
|
||||
|
||||
+ p[0] = pixel & 0xff;
|
||||
|
||||
+ p[1] = (pixel >> 8) & 0xff;
|
||||
|
||||
+ p[2] = (pixel >> 16) & 0xff;
|
||||
|
||||
+ }
|
||||
|
||||
+ break;
|
||||
|
||||
+
|
||||
|
||||
|
||||
@@ -8,13 +8,13 @@ will try to make your journey difficult as well..."
|
||||
HOMEPAGE="http://www2.braingames.getput.com/stransball2/default.asp"
|
||||
COPYRIGHT="2003-2005 Brain Games"
|
||||
LICENSE="GNU GPL v2"
|
||||
REVISION="4"
|
||||
REVISION="5"
|
||||
SOURCE_URI="http://www2.braingames.getput.com/stransball2/downloads/stransball2-v15-windows.zip"
|
||||
CHECKSUM_SHA256="644cf89c8b7084abe0451ff433db25b41e43da77d5d92edad8253baf48b018db"
|
||||
SOURCE_DIR="stransball2"
|
||||
PATCHES="super_transball-$portVersion.patchset"
|
||||
|
||||
ARCHITECTURES="x86_gcc2 ?x86 ?x86_64"
|
||||
ARCHITECTURES="x86_gcc2 ?x86 x86_64"
|
||||
|
||||
PROVIDES="
|
||||
super_transball = $portVersion
|
||||
|
||||
Reference in New Issue
Block a user