Added Fire effect / Julia Fractal Explorer / Mandelbrot Zoomer
This commit is contained in:
parent
7c0e3f313b
commit
1a92b68644
17
Demo.layout
17
Demo.layout
|
@ -2,19 +2,22 @@
|
|||
<CodeBlocks_layout_file>
|
||||
<FileVersion major="1" minor="0" />
|
||||
<ActiveTarget name="Release" />
|
||||
<File name="assets-cg/fxconv-metadata.txt" open="1" top="0" tabpos="4" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<File name="src/main.c" open="1" top="1" tabpos="1" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="15955" topLine="632" />
|
||||
</Cursor>
|
||||
<Folding>
|
||||
<Collapse line="509" />
|
||||
</Folding>
|
||||
</File>
|
||||
<File name="assets-cg/fxconv-metadata.txt" open="1" top="0" tabpos="3" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="62" topLine="0" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="CMakeLists.txt" open="1" top="0" tabpos="3" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<File name="CMakeLists.txt" open="1" top="0" tabpos="2" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="489" topLine="0" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="src/main.c" open="1" top="1" tabpos="1" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="13187" topLine="538" />
|
||||
</Cursor>
|
||||
</File>
|
||||
</CodeBlocks_layout_file>
|
||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 897 B After Width: | Height: | Size: 19 KiB |
|
@ -0,0 +1,85 @@
|
|||
//---
|
||||
// fixed: 48:16 fixed-point arithmetic
|
||||
//---
|
||||
#pragma once
|
||||
#include <stdint.h>
|
||||
|
||||
typedef int64_t fixed_t;
|
||||
/* Standard arithmetic. */
|
||||
|
||||
static inline fixed_t fmul(fixed_t left, fixed_t right)
|
||||
{
|
||||
/* Generally optimized by the compiler to use dmuls.l and xtrct */
|
||||
int64_t p = (int64_t)left * (int64_t)right;
|
||||
return (int32_t)(p >> 16);
|
||||
}
|
||||
|
||||
static inline fixed_t fdiv(fixed_t left, fixed_t right)
|
||||
{
|
||||
/* Pretty slow */
|
||||
int64_t d = (int64_t)left << 16;
|
||||
return d / right;
|
||||
}
|
||||
|
||||
#define fix(x) ((int)((x) * 65536))
|
||||
|
||||
static inline fixed_t fixdouble(double constant)
|
||||
{
|
||||
return (fixed_t)(constant * 65536);
|
||||
}
|
||||
|
||||
static inline fixed_t fixfloat(float constant)
|
||||
{
|
||||
return (fixed_t)(constant * 65536);
|
||||
}
|
||||
|
||||
static inline fixed_t fdec(fixed_t f)
|
||||
{
|
||||
return f & 0xffff;
|
||||
}
|
||||
|
||||
static inline int ffloor(fixed_t f)
|
||||
{
|
||||
return f >> 16;
|
||||
}
|
||||
|
||||
static inline int fceil(fixed_t f)
|
||||
{
|
||||
return (f + 0xffff) >> 16;
|
||||
}
|
||||
|
||||
static inline int fround(fixed_t f)
|
||||
{
|
||||
return (f + 0x8000) >> 16;
|
||||
}
|
||||
|
||||
static inline float f2float(fixed_t f)
|
||||
{
|
||||
return (float)f / 65536;
|
||||
}
|
||||
|
||||
static inline double f2double(fixed_t f)
|
||||
{
|
||||
return (double)f / 65536;
|
||||
}
|
||||
|
||||
static inline double f2int(fixed_t f)
|
||||
{
|
||||
return (int)f / 65536;
|
||||
}
|
||||
|
||||
static inline fixed_t feasein(fixed_t x)
|
||||
{
|
||||
return fmul(x, x);
|
||||
}
|
||||
|
||||
static inline fixed_t fease(fixed_t x)
|
||||
{
|
||||
if(x <= fix(0.5)) {
|
||||
return 2 * fmul(x, x);
|
||||
}
|
||||
else {
|
||||
x = fix(1) - x;
|
||||
return fix(1) - 2 * fmul(x, x);
|
||||
}
|
||||
}
|
469
src/main.c
469
src/main.c
|
@ -7,11 +7,14 @@
|
|||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "fixed.h"
|
||||
|
||||
#define MAXHEIGHT 200
|
||||
|
||||
|
||||
bool stop = false;
|
||||
uint8_t moduleToRun = 1;
|
||||
uint8_t pagevisible=0;
|
||||
|
||||
|
||||
size_t image_size_profile(int profile, int width, int height)
|
||||
|
@ -585,23 +588,23 @@ extern font_t matrix;
|
|||
typedef struct
|
||||
{
|
||||
int x;
|
||||
int y;
|
||||
int speed;
|
||||
int len;
|
||||
char str[32];
|
||||
int y;
|
||||
int speed;
|
||||
int len;
|
||||
char str[32];
|
||||
} STRIP;
|
||||
|
||||
static STRIP strips[NUMBER_OF_STRIPS];
|
||||
|
||||
void init_strip(STRIP* strip )
|
||||
{
|
||||
strip->len = 5 + rand() % 28;
|
||||
strip->x = rand() % 45;
|
||||
strip->y = -1*strip->len*CHAR_HEIGHT;
|
||||
strip->speed = 1+rand() % 5;
|
||||
strip->len = 5 + rand() % 28;
|
||||
strip->x = rand() % 45;
|
||||
strip->y = -1*strip->len*CHAR_HEIGHT;
|
||||
strip->speed = 1+rand() % 5;
|
||||
|
||||
for( int j=0; j< strips->len; j++ )
|
||||
strip->str[j] = '!' + rand() % 96;
|
||||
for( int j=0; j< strips->len; j++ )
|
||||
strip->str[j] = '!' + rand() % 96;
|
||||
}
|
||||
|
||||
|
||||
|
@ -615,21 +618,18 @@ void init_module6()
|
|||
|
||||
void run_module6( void )
|
||||
{
|
||||
|
||||
for( int k=0; k< NUMBER_OF_STRIPS; k++)
|
||||
{
|
||||
strips[k].y += strips[k].speed;
|
||||
}
|
||||
|
||||
dfont(&matrix);
|
||||
|
||||
for( int k=0; k< NUMBER_OF_STRIPS; k++)
|
||||
{
|
||||
for( int j=0; j< strips[k].len; j++ )
|
||||
if (strips[k].y - j*CHAR_HEIGHT<=200-CHAR_HEIGHT)
|
||||
{
|
||||
if(j==0) dprint( strips[k].x*CHAR_WIDTH, strips[k].y - j*CHAR_HEIGHT, C_WHITE, "%c", strips[k].str[j] );
|
||||
else if(j==0) dprint( strips[k].x*CHAR_WIDTH, strips[k].y - j*CHAR_HEIGHT, C_RGB(150,255,150) , "%c", strips[k].str[j] );
|
||||
else if(j==0) dprint( strips[k].x*CHAR_WIDTH, strips[k].y - j*CHAR_HEIGHT, C_RGB(150,255,150), "%c", strips[k].str[j] );
|
||||
else if(j==0) dprint( strips[k].x*CHAR_WIDTH, strips[k].y - j*CHAR_HEIGHT, C_RGB(50,255,50), "%c", strips[k].str[j] );
|
||||
else dprint( strips[k].x*CHAR_WIDTH, strips[k].y - j*CHAR_HEIGHT, C_GREEN, "%c", strips[k].str[j] );
|
||||
}
|
||||
|
@ -638,11 +638,377 @@ void run_module6( void )
|
|||
init_strip( strips + k );
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/********************************\
|
||||
* FIRE EFFECT - MODULE 7 *
|
||||
* Specific data and structures *
|
||||
\********************************/
|
||||
|
||||
void init_module7()
|
||||
{
|
||||
for(int i=0; i<MAXHEIGHT; i++)
|
||||
for(int j=0; j<DWIDTH; j++)
|
||||
imagedata[i*DWIDTH+j]=1;
|
||||
|
||||
for(int i=0; i<32; ++i)
|
||||
{
|
||||
|
||||
// palette[i] = C_RGB( 0, 0, i<<1 );
|
||||
// palette[i+32] = C_RGB( i<<3, 0, 64-(i<<1) );
|
||||
// palette[i+64] = C_RGB( 255, i<<3, 0 );
|
||||
// palette[i+96] = C_RGB( 255, 255, i<<2 );
|
||||
// palette[i+128] = C_RGB( 255, 255, 64+(i<<2) );
|
||||
// palette[i+160] = C_RGB( 255, 255, 128+(i<<2) );
|
||||
// palette[i+192] = C_RGB( 255, 255, 192+i );
|
||||
// palette[i+224] = C_RGB( 255, 255, 224+i );
|
||||
|
||||
|
||||
palette[i] = C_RGB( 0, 0, 0 );
|
||||
palette[i+32] = C_RGB( i*8, 0, 0 );
|
||||
palette[i+64] = C_RGB( 255, i*8, 0 );
|
||||
palette[i+96] = C_RGB( 255, 255, i*2 );
|
||||
palette[i+128] = C_RGB( 255, 255, 64+i );
|
||||
palette[i+160] = C_RGB( 255, 255, 128+i );
|
||||
palette[i+192] = C_RGB( 255, 255, 192+i );
|
||||
palette[i+224] = C_RGB( 255, 255, 224+i );
|
||||
}
|
||||
|
||||
memcpy(screen->data, palette, palette_size);
|
||||
|
||||
}
|
||||
|
||||
void run_module7( void )
|
||||
{
|
||||
uint8_t* image = screen->data;
|
||||
uint16_t temp;
|
||||
uint8_t index;
|
||||
int i,j;
|
||||
|
||||
j = DWIDTH * (MAXHEIGHT- 1);
|
||||
for (i = 0; i < DWIDTH - 1; i++)
|
||||
{
|
||||
int random = 1 + rand()%16;
|
||||
if (random > 9)
|
||||
imagedata[j + i] = 255;
|
||||
else
|
||||
imagedata[j + i] = 0;
|
||||
}
|
||||
|
||||
for (index = 0; index < 60 ; ++index)
|
||||
{
|
||||
for (i = 0; i < DWIDTH - 1; ++i)
|
||||
{
|
||||
if (i == 0)
|
||||
{
|
||||
temp = imagedata[j];
|
||||
temp += imagedata[j + 1];
|
||||
temp += imagedata[j - DWIDTH];
|
||||
temp /=3;
|
||||
}
|
||||
else if (i == DWIDTH - 1)
|
||||
{
|
||||
temp = imagedata[j + i];
|
||||
temp += imagedata[j - DWIDTH + i];
|
||||
temp += imagedata[j + i - 1];
|
||||
temp /= 3;
|
||||
}
|
||||
else
|
||||
{
|
||||
temp = imagedata[j + i];
|
||||
temp += imagedata[j + i + 1];
|
||||
temp += imagedata[j + i - 1];
|
||||
temp += imagedata[j - DWIDTH + i];
|
||||
temp >>= 2;
|
||||
}
|
||||
if (temp > 1)
|
||||
temp -= 1;
|
||||
|
||||
imagedata[j - DWIDTH + i] = temp;
|
||||
}
|
||||
j -= DWIDTH;
|
||||
}
|
||||
|
||||
image += palette_size + (DWIDTH * MAXHEIGHT);
|
||||
|
||||
for (i = MAXHEIGHT - 3; i >= 100; --i)
|
||||
{
|
||||
for (j = DWIDTH - 1; j >= 0; --j)
|
||||
{
|
||||
*image= imagedata[i * DWIDTH + j];
|
||||
image--;
|
||||
}
|
||||
}
|
||||
|
||||
void* pos = screen->data;
|
||||
|
||||
pos+=palette_size;
|
||||
memcpy(pos, imagedata, DWIDTH*MAXHEIGHT);
|
||||
|
||||
dimage(0,0,screen);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/********************************\
|
||||
* JULIA FRACTAL SET - MODULE 8 *
|
||||
* Specific data and structures *
|
||||
\********************************/
|
||||
|
||||
int PIXELZOOM = 2;
|
||||
int SPEED_UP = 1;
|
||||
int SCR_WID_PIXEL;
|
||||
int SCR_HEI_PIXEL;
|
||||
int MAX_ITERATION;
|
||||
fixed_t cr, ci;
|
||||
fixed_t xmin, xmax, ymin, ymax;
|
||||
|
||||
float rit = -0.80f;
|
||||
float iit = -1.0f;
|
||||
float si = 1.0;
|
||||
float sr = 1.0;
|
||||
|
||||
|
||||
void init_module8()
|
||||
{
|
||||
PIXELZOOM = 2;
|
||||
SPEED_UP = 1;
|
||||
SCR_WID_PIXEL = DWIDTH/PIXELZOOM;
|
||||
SCR_HEI_PIXEL = MAXHEIGHT/PIXELZOOM;
|
||||
MAX_ITERATION = 256/SPEED_UP;
|
||||
}
|
||||
|
||||
void draw_Julia( float xmi, float ymi, float xma, float yma, float r, float i )
|
||||
{
|
||||
fixed_t zr, zi;
|
||||
int u;
|
||||
int maxiter = MAX_ITERATION;
|
||||
fixed_t tmp,zr2,zi2;
|
||||
fixed_t xinc, yinc, fi, fj;
|
||||
|
||||
cr=fix(r);
|
||||
ci=fix(i);
|
||||
|
||||
xmin = fix(xmi);
|
||||
xmax = fix(xma);
|
||||
ymin = fix(ymi);
|
||||
ymax = fix(yma);
|
||||
|
||||
xinc = fdiv(xmax-xmin,fix(SCR_WID_PIXEL));
|
||||
yinc = fdiv(ymax-ymin,fix(SCR_HEI_PIXEL));
|
||||
|
||||
|
||||
for(int j=0; j<=SCR_HEI_PIXEL/2; j++)
|
||||
{
|
||||
fj=fix(j);
|
||||
for(int i=0; i<=SCR_WID_PIXEL; i++)
|
||||
{
|
||||
fi=fix(i);
|
||||
zr=xmin+fmul(fi,xinc);
|
||||
zi=ymax-fmul(fj,yinc);
|
||||
zi2=fmul(zi,zi);
|
||||
zr2=fmul(zr,zr);
|
||||
u=0;
|
||||
|
||||
while(((zr2+zi2)<fix(4)) && (u<maxiter))
|
||||
{
|
||||
tmp = zr;
|
||||
zr2=fmul(zr,zr);
|
||||
zi2=fmul(zi,zi);
|
||||
|
||||
zr = zr2 - zi2 + cr;
|
||||
zi = fmul(fix(2), fmul(zi,tmp)) + ci;
|
||||
u++;
|
||||
}
|
||||
|
||||
if (u==maxiter)
|
||||
{
|
||||
drect(i*PIXELZOOM, j*PIXELZOOM, (i+1)*PIXELZOOM-1, (j+1)*PIXELZOOM-1, 0x0000 );
|
||||
drect( DWIDTH-i*PIXELZOOM, MAXHEIGHT-j*PIXELZOOM, DWIDTH-(i+1)*PIXELZOOM+1, MAXHEIGHT-(j+1)*PIXELZOOM+1, 0x0000 );
|
||||
}
|
||||
else
|
||||
{
|
||||
int sr=0;
|
||||
int sg=0;
|
||||
int sb=0;
|
||||
|
||||
if (u < MAX_ITERATION/4 /SPEED_UP)
|
||||
{
|
||||
sr=0;
|
||||
sg=u*4*SPEED_UP;
|
||||
sb=255;
|
||||
}
|
||||
else if (u < 2*MAX_ITERATION/4 /SPEED_UP)
|
||||
{
|
||||
sr=0;
|
||||
sg=255;
|
||||
sb=(255-(u-MAX_ITERATION/4 /SPEED_UP)*4*SPEED_UP);
|
||||
}
|
||||
else if (u < 3*MAX_ITERATION/4 /SPEED_UP)
|
||||
{
|
||||
sr=(u-2*MAX_ITERATION/4 /SPEED_UP)*4*SPEED_UP;
|
||||
sg=255;
|
||||
sb=0;
|
||||
}
|
||||
else if (u < MAX_ITERATION /SPEED_UP)
|
||||
{
|
||||
sr=255;
|
||||
sg=(256-(u-3*MAX_ITERATION/4 /SPEED_UP)*4*SPEED_UP);
|
||||
sb=0;
|
||||
}
|
||||
|
||||
drect(i*PIXELZOOM, j*PIXELZOOM, (i+1)*PIXELZOOM-1, (j+1)*PIXELZOOM-1, C_RGB(sr,sg,sb) );
|
||||
drect( DWIDTH-i*PIXELZOOM, MAXHEIGHT-j*PIXELZOOM, DWIDTH-(i+1)*PIXELZOOM+1, MAXHEIGHT-(j+1)*PIXELZOOM+1, C_RGB(sr,sg,sb) );
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void run_module8( void )
|
||||
{
|
||||
iit += 0.01*si;
|
||||
if (iit<-1.0 || iit>1.0) si*=-1.0f;
|
||||
|
||||
//rit += 0.01*sr;
|
||||
//if (rit<-0.8 || rit>0.8) sr*=-1.0f;
|
||||
|
||||
draw_Julia( -1.98f, -1.0f, 1.98f, 1.0f, rit, iit );
|
||||
}
|
||||
|
||||
|
||||
/********************************\
|
||||
* MANDELBROT SET - MODULE 9 *
|
||||
* Specific data and structures *
|
||||
\********************************/
|
||||
|
||||
float zoomfactor = 1.0f;
|
||||
float sens = 1.0f;
|
||||
|
||||
void init_module9()
|
||||
{
|
||||
|
||||
zoomfactor = 1.0f;
|
||||
sens = 1.0f;
|
||||
PIXELZOOM = 2;
|
||||
SPEED_UP = 3;
|
||||
SCR_WID_PIXEL = DWIDTH/PIXELZOOM;
|
||||
SCR_HEI_PIXEL = MAXHEIGHT/PIXELZOOM;
|
||||
MAX_ITERATION = 256/SPEED_UP;
|
||||
}
|
||||
|
||||
void draw_Mandelbrot( float xmi, float ymi, float xma, float yma)
|
||||
{
|
||||
int u;
|
||||
int maxiter = MAX_ITERATION;
|
||||
fixed_t tmp, xinc, yinc, fi, fj, x, y, x2, y2, x0, y0,w ;
|
||||
|
||||
xmin = fix(xmi);
|
||||
xmax = fix(xma);
|
||||
ymin = fix(ymi);
|
||||
ymax = fix(yma);
|
||||
|
||||
xinc = fdiv(xmax-xmin,fix(SCR_WID_PIXEL));
|
||||
yinc = fdiv(ymax-ymin,fix(SCR_HEI_PIXEL));
|
||||
|
||||
|
||||
for(int j=0; j<=SCR_HEI_PIXEL; j++)
|
||||
{
|
||||
fj=fix(j);
|
||||
for(int i=0; i<=SCR_WID_PIXEL; i++)
|
||||
{
|
||||
|
||||
fi=fix(i);
|
||||
x0=xmin+fmul(fi, xinc);
|
||||
y0=ymax-fmul(fj, yinc);
|
||||
|
||||
x = fix(0);
|
||||
y = fix(0);
|
||||
w = fix(0);
|
||||
x2 = fmul(x, x);
|
||||
y2 = fmul(y, y);
|
||||
u=0;
|
||||
|
||||
while((x2+y2<=fix(4)) && (u<maxiter))
|
||||
{
|
||||
x = x2-y2+x0;
|
||||
y = w - x2 - y2 + y0;
|
||||
x2 = fmul(x, x);
|
||||
y2 = fmul(y, y);
|
||||
w = fmul(x+y, x+y );
|
||||
u++;
|
||||
}
|
||||
|
||||
if (u==maxiter)
|
||||
{
|
||||
drect(i*PIXELZOOM, j*PIXELZOOM, (i+1)*PIXELZOOM-1, (j+1)*PIXELZOOM-1, 0x0000 );
|
||||
//drect( i*PIXELZOOM, MAXHEIGHT-j*PIXELZOOM, (i+1)*PIXELZOOM+1, MAXHEIGHT-(j+1)*PIXELZOOM+1, 0x0000 );
|
||||
}
|
||||
else
|
||||
{
|
||||
int sr=0;
|
||||
int sg=0;
|
||||
int sb=0;
|
||||
|
||||
if (u < MAX_ITERATION/4 /SPEED_UP)
|
||||
{
|
||||
sr=0;
|
||||
sg=u*4*SPEED_UP;
|
||||
sb=255;
|
||||
}
|
||||
else if (u < 2*MAX_ITERATION/4 /SPEED_UP)
|
||||
{
|
||||
sr=0;
|
||||
sg=255;
|
||||
sb=(255-(u-MAX_ITERATION/4 /SPEED_UP)*4*SPEED_UP);
|
||||
}
|
||||
else if (u < 3*MAX_ITERATION/4 /SPEED_UP)
|
||||
{
|
||||
sr=(u-2*MAX_ITERATION/4 /SPEED_UP)*4*SPEED_UP;
|
||||
sg=255;
|
||||
sb=0;
|
||||
}
|
||||
else if (u < MAX_ITERATION /SPEED_UP)
|
||||
{
|
||||
sr=255;
|
||||
sg=(256-(u-3*MAX_ITERATION/4 /SPEED_UP)*4*SPEED_UP);
|
||||
sb=0;
|
||||
}
|
||||
|
||||
drect(i*PIXELZOOM, j*PIXELZOOM, (i+1)*PIXELZOOM-1, (j+1)*PIXELZOOM-1, C_RGB(sr,sg,sb) );
|
||||
//drect( i*PIXELZOOM, MAXHEIGHT-j*PIXELZOOM, (i+1)*PIXELZOOM+1, MAXHEIGHT-(j+1)*PIXELZOOM+1, C_RGB(sr,sg,sb) );
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void run_module9( void )
|
||||
{
|
||||
|
||||
//float x0 = -0.749292248 - 4.0f/zoomfactor;
|
||||
//float x1 = -0.749292248 + 4.0f/zoomfactor;
|
||||
//float y0 = 0.084150839 - 1.5f/zoomfactor;
|
||||
//float y1 = 0.084150839 + 1.5f/zoomfactor;
|
||||
|
||||
float x0 = -0.7746806106269039 - 4.0f/zoomfactor;
|
||||
float x1 = -0.7746806106269039 + 4.0f/zoomfactor;
|
||||
float y0 = -0.1374168856037867 - 1.5f/zoomfactor;
|
||||
float y1 = -0.1374168856037867 + 1.5f/zoomfactor;
|
||||
|
||||
draw_Mandelbrot( x0, y0, x1, y1);
|
||||
|
||||
if (sens>0) zoomfactor*=1.2f;
|
||||
else zoomfactor/=1.2f;
|
||||
|
||||
if (zoomfactor==100 || zoomfactor==1 ) sens*=-1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void get_minimum_inputs( void )
|
||||
{
|
||||
|
@ -654,41 +1020,69 @@ static void get_minimum_inputs( void )
|
|||
|
||||
if(keydown(KEY_EXIT)) stop=true;
|
||||
|
||||
if(keydown(KEY_F1))
|
||||
if(pagevisible==0 && keydown(KEY_F1))
|
||||
{
|
||||
init_module1();
|
||||
moduleToRun = 1;
|
||||
}
|
||||
|
||||
if(keydown(KEY_F2))
|
||||
if(pagevisible==0 && keydown(KEY_F2))
|
||||
{
|
||||
init_module2();
|
||||
moduleToRun = 2;
|
||||
}
|
||||
|
||||
if(keydown(KEY_F3))
|
||||
if(pagevisible==0 && keydown(KEY_F3))
|
||||
{
|
||||
init_module3();
|
||||
moduleToRun = 3;
|
||||
}
|
||||
|
||||
if(keydown(KEY_F4))
|
||||
if(pagevisible==0 && keydown(KEY_F4))
|
||||
{
|
||||
init_module4();
|
||||
moduleToRun = 4;
|
||||
}
|
||||
|
||||
if(keydown(KEY_F5))
|
||||
if(pagevisible==0 && keydown(KEY_F5))
|
||||
{
|
||||
init_module5();
|
||||
moduleToRun = 5;
|
||||
}
|
||||
|
||||
if(keydown(KEY_F6))
|
||||
if(pagevisible==0 && keydown(KEY_F6))
|
||||
{
|
||||
pagevisible=1;
|
||||
}
|
||||
|
||||
if(pagevisible==1 && keydown(KEY_F1))
|
||||
{
|
||||
pagevisible=0;
|
||||
}
|
||||
|
||||
if(pagevisible==1 && keydown(KEY_F2))
|
||||
{
|
||||
init_module6();
|
||||
moduleToRun = 6;
|
||||
}
|
||||
|
||||
if(pagevisible==1 && keydown(KEY_F3))
|
||||
{
|
||||
init_module7();
|
||||
moduleToRun = 7;
|
||||
}
|
||||
|
||||
if(pagevisible==1 && keydown(KEY_F4))
|
||||
{
|
||||
init_module8();
|
||||
moduleToRun = 8;
|
||||
}
|
||||
|
||||
if(pagevisible==1 && keydown(KEY_F5))
|
||||
{
|
||||
init_module9();
|
||||
moduleToRun = 9;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -696,11 +1090,9 @@ static void get_minimum_inputs( void )
|
|||
|
||||
int main(void)
|
||||
{
|
||||
|
||||
srand( rtc_ticks() );
|
||||
|
||||
|
||||
|
||||
|
||||
size_t size = image_size_profile( 2, DWIDTH, MAXHEIGHT);
|
||||
screen = malloc( size );
|
||||
screen->profile = 2;
|
||||
|
@ -709,9 +1101,11 @@ int main(void)
|
|||
screen->height = MAXHEIGHT;
|
||||
|
||||
|
||||
|
||||
|
||||
init_module1();
|
||||
|
||||
|
||||
dfont(&matrix);
|
||||
|
||||
while(!stop)
|
||||
{
|
||||
|
@ -723,13 +1117,28 @@ int main(void)
|
|||
else if (moduleToRun==4) run_module4();
|
||||
else if (moduleToRun==5) run_module5();
|
||||
else if (moduleToRun==6) run_module6();
|
||||
else if (moduleToRun==7) run_module7();
|
||||
else if (moduleToRun==8) run_module8();
|
||||
else if (moduleToRun==9) run_module9();
|
||||
|
||||
dprint_opt(33, 212, C_RGB(255,255,255), C_NONE, DTEXT_CENTER, DTEXT_CENTER, "PLASMA" );
|
||||
dprint_opt(99, 212, C_RGB(255,255,255), C_NONE, DTEXT_CENTER, DTEXT_CENTER, "BLOBS" );
|
||||
dprint_opt(165, 212, C_RGB(255,255,255), C_NONE, DTEXT_CENTER, DTEXT_CENTER, "LENS" );
|
||||
dprint_opt(231, 212, C_RGB(255,255,255), C_NONE, DTEXT_CENTER, DTEXT_CENTER, "STARS" );
|
||||
dprint_opt(297, 212, C_RGB(255,255,255), C_NONE, DTEXT_CENTER, DTEXT_CENTER, "RAIN" );
|
||||
dprint_opt(363, 212, C_RGB(255,255,255), C_NONE, DTEXT_CENTER, DTEXT_CENTER, "MATRIX" );
|
||||
if (pagevisible==0)
|
||||
{
|
||||
dprint_opt(33, 212, moduleToRun==1?C_RGB(255,0,0):C_RGB(255,255,255), C_NONE, DTEXT_CENTER, DTEXT_CENTER, "PLASMA" );
|
||||
dprint_opt(99, 212, moduleToRun==2?C_RGB(255,0,0):C_RGB(255,255,255), C_NONE, DTEXT_CENTER, DTEXT_CENTER, "BLOBS" );
|
||||
dprint_opt(165, 212, moduleToRun==3?C_RGB(255,0,0):C_RGB(255,255,255), C_NONE, DTEXT_CENTER, DTEXT_CENTER, "LENS" );
|
||||
dprint_opt(231, 212, moduleToRun==4?C_RGB(255,0,0):C_RGB(255,255,255), C_NONE, DTEXT_CENTER, DTEXT_CENTER, "STARS" );
|
||||
dprint_opt(297, 212, moduleToRun==5?C_RGB(255,0,0):C_RGB(255,255,255), C_NONE, DTEXT_CENTER, DTEXT_CENTER, "RAIN" );
|
||||
dprint_opt(363, 212, C_RGB(255,255,255), C_NONE, DTEXT_CENTER, DTEXT_CENTER, "%c%c%c",'!'+31,'!'+31,'!'+31 );
|
||||
}
|
||||
else if (pagevisible==1)
|
||||
{
|
||||
dprint_opt(33, 212, C_RGB(255,255,255), C_NONE, DTEXT_CENTER, DTEXT_CENTER, "%c%c%c",'!'-1,'!'-1,'!'-1 );
|
||||
dprint_opt(99, 212, moduleToRun==6?C_RGB(255,0,0):C_RGB(255,255,255), C_NONE, DTEXT_CENTER, DTEXT_CENTER, "MATRIX" );
|
||||
dprint_opt(165, 212, moduleToRun==7?C_RGB(255,0,0):C_RGB(255,255,255), C_NONE, DTEXT_CENTER, DTEXT_CENTER, "FIRE" );
|
||||
dprint_opt(231, 212, moduleToRun==8?C_RGB(255,0,0):C_RGB(255,255,255), C_NONE, DTEXT_CENTER, DTEXT_CENTER, "JULIA" );
|
||||
dprint_opt(297, 212, moduleToRun==9?C_RGB(255,0,0):C_RGB(255,255,255), C_NONE, DTEXT_CENTER, DTEXT_CENTER, "MANDEL" );
|
||||
dprint_opt(363, 212, moduleToRun==10?C_RGB(255,0,0):C_RGB(255,255,255), C_NONE, DTEXT_CENTER, DTEXT_CENTER, "%c%c%c",'!'+63,'!'+63,'!'+63 );
|
||||
}
|
||||
|
||||
dupdate();
|
||||
|
||||
|
|
Loading…
Reference in New Issue