More work
This commit is contained in:
parent
470519c92e
commit
5751fea35f
@ -3,8 +3,14 @@
|
||||
#include "powder.h"
|
||||
#include "graphics.h"
|
||||
#include "font.h"
|
||||
#include "utils.h"
|
||||
#include <math.h>
|
||||
#include <SDL/SDL.h>
|
||||
|
||||
unsigned cmode = 3;
|
||||
SDL_Surface *sdl_scrn;
|
||||
int sdl_scale = 1;
|
||||
|
||||
pixel *rescale_img(pixel *src, int sw, int sh, int *qw, int *qh, int f)
|
||||
{
|
||||
int i,j,x,y,w,h,r,g,b,c;
|
||||
|
@ -36,9 +36,9 @@ typedef unsigned int pixel;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
unsigned cmode = 3;
|
||||
SDL_Surface *sdl_scrn;
|
||||
int sdl_scale = 1;
|
||||
extern unsigned cmode;
|
||||
extern SDL_Surface *sdl_scrn;
|
||||
extern int sdl_scale;
|
||||
|
||||
pixel *rescale_img(pixel *src, int sw, int sh, int *qw, int *qh, int f);
|
||||
|
||||
|
@ -7,13 +7,16 @@ struct menu_section
|
||||
const char *name;
|
||||
int itemcount;
|
||||
};
|
||||
typedef struct menu_section menu_section;
|
||||
|
||||
struct menu_wall
|
||||
{
|
||||
pixel colour;
|
||||
const char *descs;
|
||||
};
|
||||
typedef struct menu_wall menu_wall;
|
||||
|
||||
const struct menu_wall mwalls[] =
|
||||
static menu_wall mwalls[] =
|
||||
{
|
||||
{PIXPACK(0xC0C0C0), "Wall. Indestructible. Blocks everything. Conductive."},
|
||||
{PIXPACK(0x808080), "E-Wall. Becomes transparent when electricity is connected."},
|
||||
@ -47,7 +50,7 @@ const struct menu_wall mwalls[] =
|
||||
#define SC_NUCLEAR 7
|
||||
#define SC_TOTAL 9
|
||||
|
||||
struct menu_section msections[] =
|
||||
static menu_section msections[] =
|
||||
{
|
||||
{"\xC1", "Walls", 0},
|
||||
{"\xC2", "Electronics", 0},
|
||||
|
43
powder.c
43
powder.c
@ -37,6 +37,7 @@
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
#include "utils.h"
|
||||
#include "font.h"
|
||||
#include "defines.h"
|
||||
#include "powder.h"
|
||||
@ -281,32 +282,6 @@ void *update_air_th(void *arg)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#ifdef WIN32
|
||||
_inline unsigned clamp_flt(float f, float min, float max)
|
||||
#else
|
||||
inline unsigned clamp_flt(float f, float min, float max)
|
||||
#endif
|
||||
{
|
||||
if(f<min)
|
||||
return 0;
|
||||
if(f>max)
|
||||
return 255;
|
||||
return (int)(255.0f*(f-min)/(max-min));
|
||||
}
|
||||
|
||||
#ifdef WIN32
|
||||
_inline float restrict_flt(float f, float min, float max)
|
||||
#else
|
||||
inline float restrict_flt(float f, float min, float max)
|
||||
#endif
|
||||
{
|
||||
if(f<min)
|
||||
return min;
|
||||
if(f>max)
|
||||
return max;
|
||||
return f;
|
||||
}
|
||||
|
||||
/***********************************************************
|
||||
* PARTICLE SIMULATOR *
|
||||
***********************************************************/
|
||||
@ -650,22 +625,6 @@ inline void delete_part(int x, int y)
|
||||
pmap[y][x] = 0; // just in case
|
||||
}
|
||||
|
||||
//Signum function
|
||||
#ifdef WIN32
|
||||
_inline int sign(float i)
|
||||
#else
|
||||
inline int sign(float i)
|
||||
#endif
|
||||
{
|
||||
if (i<0)
|
||||
return -1;
|
||||
if (i>0)
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int drawtext(pixel *vid, int x, int y, char *s, int r, int g, int b, int a);
|
||||
|
||||
#ifdef WIN32
|
||||
_inline int is_wire(int x, int y)
|
||||
#else
|
||||
|
13
powder.h
13
powder.h
@ -122,7 +122,7 @@ static unsigned char TYPE_GAS = 0x08; //8
|
||||
static unsigned char PROP_CONDUCTS = 0x10; //16
|
||||
#define FLAG_STAGNANT 1
|
||||
|
||||
typedef struct
|
||||
struct particle
|
||||
{
|
||||
int type;
|
||||
int life, ctype;
|
||||
@ -130,7 +130,8 @@ typedef struct
|
||||
float temp;
|
||||
float pavg[2];
|
||||
int flags;
|
||||
} particle;
|
||||
};
|
||||
typedef struct particle particle;
|
||||
|
||||
struct part_type
|
||||
{
|
||||
@ -156,6 +157,7 @@ struct part_type
|
||||
const char *descs;
|
||||
unsigned char properties;
|
||||
};
|
||||
typedef struct part_type part_type;
|
||||
|
||||
struct part_state
|
||||
{
|
||||
@ -169,8 +171,9 @@ struct part_state
|
||||
int burn;
|
||||
float btemp;
|
||||
};
|
||||
typedef struct part_state part_state;
|
||||
|
||||
const struct part_type ptypes[PT_NUM] =
|
||||
static part_type ptypes[PT_NUM] =
|
||||
{
|
||||
//Name Colour Advec Airdrag Airloss Loss Collid Grav Diffus Hotair Fal Burn Exp Mel Hrd M Section H Ins(real world, by triclops200) Description
|
||||
{"", PIXPACK(0x000000), 0.0f, 0.00f * CFDS, 1.00f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 1, 1, SC_SPECIAL, R_TEMP+0.0f, 251, "Erases particles."},
|
||||
@ -242,7 +245,7 @@ const struct part_type ptypes[PT_NUM] =
|
||||
//Name Colour Advec Airdrag Airloss Loss Collid Grav Diffus Hotair Fal Burn Exp Mel Hrd M Section H Ins(real world, by triclops200) Description
|
||||
};
|
||||
|
||||
const struct part_state pstates[PT_NUM] =
|
||||
static part_state pstates[PT_NUM] =
|
||||
{
|
||||
// Name Solid Frzp Liquid Mpnt Gas Bpoint
|
||||
/* NONE */ {ST_NONE, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f},
|
||||
@ -312,7 +315,7 @@ const struct part_state pstates[PT_NUM] =
|
||||
/* YEST */ {ST_SOLID, PT_NONE, 0.0f, PT_DYST, 60.0f, PT_NONE, 0.0f, PT_NONE, 0.0f},
|
||||
/* YEST */ {ST_SOLID, PT_NONE, 0.0f, PT_DUST, 200.0f, PT_NONE, 0.0f, PT_NONE, 0.0f},
|
||||
};
|
||||
static const unsigned char can_move[PT_NUM][PT_NUM] =
|
||||
static unsigned char can_move[PT_NUM][PT_NUM] =
|
||||
{
|
||||
/* A B */
|
||||
/* A 0 1 | B ligher than A */
|
||||
|
41
utils.c
Normal file
41
utils.c
Normal file
@ -0,0 +1,41 @@
|
||||
#include "utils.h"
|
||||
|
||||
//Signum function
|
||||
#ifdef WIN32
|
||||
_inline int sign(float i)
|
||||
#else
|
||||
inline int sign(float i)
|
||||
#endif
|
||||
{
|
||||
if (i<0)
|
||||
return -1;
|
||||
if (i>0)
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef WIN32
|
||||
_inline unsigned clamp_flt(float f, float min, float max)
|
||||
#else
|
||||
inline unsigned clamp_flt(float f, float min, float max)
|
||||
#endif
|
||||
{
|
||||
if(f<min)
|
||||
return 0;
|
||||
if(f>max)
|
||||
return 255;
|
||||
return (int)(255.0f*(f-min)/(max-min));
|
||||
}
|
||||
|
||||
#ifdef WIN32
|
||||
_inline float restrict_flt(float f, float min, float max)
|
||||
#else
|
||||
inline float restrict_flt(float f, float min, float max)
|
||||
#endif
|
||||
{
|
||||
if(f<min)
|
||||
return min;
|
||||
if(f>max)
|
||||
return max;
|
||||
return f;
|
||||
}
|
23
utils.h
Normal file
23
utils.h
Normal file
@ -0,0 +1,23 @@
|
||||
#ifndef UTILS_H
|
||||
#define UTILS_H
|
||||
|
||||
//Signum function
|
||||
#ifdef WIN32
|
||||
_inline int sign(float i);
|
||||
#else
|
||||
inline int sign(float i);
|
||||
#endif
|
||||
|
||||
#ifdef WIN32
|
||||
_inline unsigned clamp_flt(float f, float min, float max);
|
||||
#else
|
||||
inline unsigned clamp_flt(float f, float min, float max);
|
||||
#endif
|
||||
|
||||
#ifdef WIN32
|
||||
_inline float restrict_flt(float f, float min, float max);
|
||||
#else
|
||||
inline float restrict_flt(float f, float min, float max);
|
||||
#endif
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue
Block a user