Subversion Repositories Kolibri OS

Compare Revisions

Regard whitespace Rev 5238 → Rev 5239

/programs/games/marblematch3/game/rsgame.c
217,6 → 217,8
game.loader_counter = 0;
game.process_timer = 0;
game.need_redraw = 1;
game.score = 0;
381,8 → 383,8
};
};
 
int process_timer = 0;
 
 
void GameProcess() {
if (game.status == STATUS_LOADING) {
400,13 → 402,12
}
else if (game.status == STATUS_PLAYING) {
game.process_timer++;
process_timer++;
 
if (process_timer > 3) {
if (game.process_timer > ANIMATION_PROCESS_TIMER_LIMIT) {
game_check_and_explode();
game_fall();
process_timer = 0;
game.process_timer = 0;
};
int i;
607,8 → 608,16
 
};
 
typedef struct {
int a;
int b;
unsigned short c;
unsigned short d;
} cc_t;
 
void GameMouseDown(int x, int y) {
game.need_redraw = 1;
game.tx = x;
657,7 → 666,7
}
else {
// success
process_timer = 0;
game.process_timer = 0;
};
}
/programs/games/marblematch3/game/rsgame.h
135,6 → 135,8
#define EXPLOSIONS_MAX_COUNT 16
//#define EXPLOSION_PACK(x,y,frame) ( (x) | ( (y)<<8 ) | (frame)<<16 )
 
#define ANIMATION_PROCESS_TIMER_LIMIT 3
 
typedef struct rs_game_t {
rs_texture_t framebuffer;
unsigned char *scaled_framebuffer; // 24-bit BGRBGRBGR... for direct drawing
167,6 → 169,8
int window_scale;
int process_timer;
int tx;
int ty;
int tz;
/programs/games/marblematch3/game/rsgamedraw.c
17,7 → 17,10
int w = GAME_WIDTH;
int h = GAME_HEIGHT;
int continue_need_redraw = 0;
if (game.need_redraw) {
// if (1) {
 
59,20 → 62,25
texture_draw(&game.framebuffer, &game.tex_bg_gameplay, 0, 0, DRAW_MODE_REPLACE);
int i, j;
int i, j, y_shift;
for (i = 0; i < FIELD_HEIGHT; i++) {
for (j = 0; j < FIELD_WIDTH; j++) {
if ( IS_BIT_SET( game.field[i*FIELD_WIDTH + j], CRYSTAL_VISIBLE_BIT )) {
texture_draw( &game.framebuffer, &game.tex_crystals[ game.field[i*FIELD_WIDTH + j] & CRYSTAL_INDEX_MASK ], FIELD_X0+ j*CRYSTAL_SIZE, FIELD_Y0+ i*CRYSTAL_SIZE, DRAW_MODE_ALPHA );
if (game.selected) {
if ( (j == game.selected_x) && (i == game.selected_y) ) {
texture_draw( &game.framebuffer, &game.tex_cursor, FIELD_X0+ j*CRYSTAL_SIZE, FIELD_Y0+ i*CRYSTAL_SIZE, DRAW_MODE_ALPHA );
y_shift = 0;
if ( IS_BIT_SET( game.field[i*FIELD_WIDTH + j], CRYSTAL_MOVING_BIT ) ) {
y_shift = -CRYSTAL_SIZE + CRYSTAL_SIZE*(game.process_timer+1)/(ANIMATION_PROCESS_TIMER_LIMIT+1);
continue_need_redraw = 1;
};
texture_draw( &game.framebuffer, &game.tex_crystals[ game.field[i*FIELD_WIDTH + j] & CRYSTAL_INDEX_MASK ], FIELD_X0+ j*CRYSTAL_SIZE, y_shift + FIELD_Y0+ i*CRYSTAL_SIZE, DRAW_MODE_ALPHA );
};
};
};
if (game.selected) {
texture_draw( &game.framebuffer, &game.tex_cursor, FIELD_X0+ game.selected_x*CRYSTAL_SIZE, FIELD_Y0+ game.selected_y*CRYSTAL_SIZE, DRAW_MODE_ALPHA );
};
for (i = 0; i < game.explosions_count; i++) {
texture_draw( &game.framebuffer, &(game.tex_explosion[ (game.explosions[i]>>16) & 0xFF ]),
FIELD_X0 + CRYSTAL_SIZE*( game.explosions[i] & 0xFF) - (EXPLOSION_SIZE-CRYSTAL_SIZE)/2 ,
99,10 → 107,13
};
 
 
rskos_draw_area(0, 0, w, h, game.window_scale, game.framebuffer.data, game.scaled_framebuffer);
// rskos_draw_area(0, 0, w, h, game.window_scale, game.framebuffer.data, NULL, RSKOS_BGRA);
rskos_draw_area(0, 0, w, h, game.window_scale, game.framebuffer.data, game.scaled_framebuffer, 0);
};
if (!continue_need_redraw) {
game.need_redraw = 0;
};
 
};
 
194,47 → 205,51
float cr_b[CRYSTALS_COUNT] = { 0.0, 0.1, 1.0, 1.0, 0.0, 0.9, 0.9 };
 
// rs_gen_init(5, CRYSTAL_SIZE);
// for (i = 0; i < CRYSTALS_COUNT; i++) {
// texture_init(&(game.tex_crystals[i]), CRYSTAL_SIZE, CRYSTAL_SIZE);
//
// rs_gen_func_set(0, 0.0);
// rs_gen_func_radial(0, 0.5, 0.5, 0.5, 0.75, 10.0);
//
// rs_gen_func_set(1, 0.0);
// rs_gen_func_cell(1, 110+100*i, 7+i, NULL, 1.0, 1.0, 0.0, 1.0, 0.0, 1.0);
// rs_gen_func_normalize(1, 0.0, 1.0);
//
// rs_gen_tex_out_rgba_set(0.0, 0.0, 0.0, 0.0);
// rs_gen_tex_out_rgba(1, 1, 1, 0, cr_b[i], cr_g[i], cr_r[i], 1.0);
//
// memcpy(game.tex_crystals[i].data, rs_gen_reg.tex_out, CRYSTAL_SIZE*CRYSTAL_SIZE*4 );
// };
// rs_gen_term();
rs_gen_init(5, CRYSTAL_SIZE);
for (i = 0; i < CRYSTALS_COUNT; i++) {
texture_init(&(game.tex_crystals[i]), CRYSTAL_SIZE, CRYSTAL_SIZE);
rs_gen_func_set(0, 0.0);
rs_gen_func_radial(0, 0.5, 0.5, 0.5, 0.75, 10.0);
 
// rs_gen_func_perlin(2, 33, 4, 0.5, 350+i);
// rs_gen_func_normalize(2, 0.0, 1.0);
// rs_gen_func_posterize(2, 4);
//
// rs_gen_func_cell(1, 410+i, 50, NULL, -2.0, 1.0, 1.0, 1.0, 0.0, 1.0);
// rs_gen_func_posterize(1, 2);
// rs_gen_func_normalize(1, 0.0, 1.0);
// rs_gen_func_add(1, 1, 2, 1.0, 0.5);
// rs_gen_func_normalize(1, 0.0, 1.0);
// rs_gen_func_posterize(1, 4);
//
// rs_gen_func_add(1, 0, 1, 1.0, 1.0);
// rs_gen_func_normalize(1, 0.0, 1.0);
// rs_gen_func_mult(1, 0, 1);
// rs_gen_func_normalize(1, 0.0, 1.0);
// rs_gen_func_posterize(1, 4);
rs_gen_func_set(1, 0.0);
rs_gen_func_cell(1, 110+100*i, 7+i, NULL, 1.0, 1.0, 0.0, 1.0, 0.0, 1.0);
rs_gen_func_set(1, 1.0);
rs_gen_func_cell(1, 310+100*i, 5, NULL, -0.5, 1.0, 1.0, 0.0, -2.0, 2.0);
rs_gen_func_normalize(1, 0.0, 1.0);
// rs_gen_func_mult_add_value(1, 1, 0.9, 0.1);
// rs_gen_func_normalmap(2, 3, 3, 1, 1.0);
// rs_gen_func_mult(1, 1, 2);
rs_gen_func_normalmap(2, 3, 4, 1, 1.0);
rs_gen_func_mult_add_value(3, 3, -1.0, 1.0);
//rs_gen_tex_out_rgba_set(0.0, 0.0, 0.0, 0.0);
//rs_gen_tex_out_rgba(1, 1, 1, 1, 0.5+ 0.03*(i%2), 0.7+ 0.03*(i%3) , 0.9, 1.0);
// rs_gen_tex_out_rgba_set(0.2 + 0.2*(i/3), 0.2 + 0.1*(i%5), 0.2 + 0.1*(i%7), 0.0);
// rs_gen_tex_out_rgba(1, 1, 1, 1, 0.0, 0.0, 0.0, 1.0);
rs_gen_func_clamp(2, 0.5, 1.0);
rs_gen_func_normalize(2, 0.0, 1.0);
rs_gen_func_clamp(3, 0.5, 1.0);
rs_gen_func_normalize(3, 0.0, 1.0);
rs_gen_func_add(4, 2, 3, 0.5, 0.5);
rs_gen_func_mult(1, 1, 4);
rs_gen_func_normalize(1, 0.0, 1.0);
rs_gen_tex_out_rgba_set(0.0, 0.0, 0.0, 0.0);
// rs_gen_tex_out_rgba_set( cr_b[i], cr_g[i], cr_r[i], 0.0);
rs_gen_tex_out_rgba(1, 1, 1, 0, cr_b[i], cr_g[i], cr_r[i], 1.0);
// rs_gen_tex_out_rgba(4, 4, 4, 0, 0.8-0.8*cr_b[i], 0.8-0.8*cr_g[i], 0.8-0.8*cr_r[i], 0.0);
// rs_gen_tex_out_rgba(1, 1, 1, 0, 1.0, 1.0, 1.0, 1.0);
 
memcpy(game.tex_crystals[i].data, rs_gen_reg.tex_out, CRYSTAL_SIZE*CRYSTAL_SIZE*4 );
};
/programs/games/marblematch3/game/rskos.c
35,18 → 35,20
};
 
void rskos_draw_area(int x, int y, int w, int h, int k_scale, unsigned char *data, unsigned char *scaled_buffer) {
void rskos_draw_area(int x, int y, int w, int h, int k_scale, unsigned char *data, unsigned char *scaled_buffer, int image_format) {
 
int bpp = image_format == RSKOS_BGR ? 3 : 4;
 
int i, j;
// int i, j;
//
// for (i = 0; i < h*k_scale; i++) {
// for (j = 0; j < w*k_scale; j++) {
// scaled_buffer[ (i*w*k_scale + j)*3 + 0] = data[ ( (i/k_scale)*w + (j/k_scale) )*4 + 0];
// scaled_buffer[ (i*w*k_scale + j)*3 + 1] = data[ ( (i/k_scale)*w + (j/k_scale) )*4 + 1];
// scaled_buffer[ (i*w*k_scale + j)*3 + 2] = data[ ( (i/k_scale)*w + (j/k_scale) )*4 + 2];
// };
// };
for (i = 0; i < h*k_scale; i++) {
for (j = 0; j < w*k_scale; j++) {
scaled_buffer[ (i*w*k_scale + j)*3 + 0] = data[ ( (i/k_scale)*w + (j/k_scale) )*4 + 0];
scaled_buffer[ (i*w*k_scale + j)*3 + 1] = data[ ( (i/k_scale)*w + (j/k_scale) )*4 + 1];
scaled_buffer[ (i*w*k_scale + j)*3 + 2] = data[ ( (i/k_scale)*w + (j/k_scale) )*4 + 2];
};
};
 
 
53,7 → 55,6
 
 
 
 
glViewport(0, 0, rs_app.width, rs_app.height);
glClearColor( 0.2596078431, 0.2815686275, 0.3929411765, 1.0 ); // #98d0ed
//glClearColor( 0.0, 0.4, 0.1 + 0.5*0.001*(rs_get_time()%1024) , 1.0 );
65,7 → 66,8
rs_tx_t tex = rs_tx_create_from_data(w*k_scale, h*k_scale, 3, 0, 1, scaled_buffer);
//rs_tx_t tex = rs_tx_create_from_data(w*k_scale, h*k_scale, 3, 0, 1, scaled_buffer);
rs_tx_t tex = rs_tx_create_from_data(w, h, bpp, 0, 1, data);
glBindTexture(GL_TEXTURE_2D, tex);
86,10 → 88,6
 
rsDoSwapBuffers();
 
// swap buffers (??)
};
 
 
150,9 → 148,13
return 1;
};
 
void rskos_draw_area(int x, int y, int w, int h, int k_scale, unsigned char *data, unsigned char *scaled_buffer) {
void rskos_draw_area(int x, int y, int w, int h, int k_scale, unsigned char *data, unsigned char *scaled_buffer, int image_format) {
 
// unsigned char *scaled_buffer = malloc(w*k_scale*h*k_scale*3);
 
 
// if (scaled_buffer != NULL) {
 
int i, j;
for (i = 0; i < h*k_scale; i++) {
164,11 → 166,18
};
 
kol_paint_image(0, 0, w*k_scale, h*k_scale, scaled_buffer);
// }
// else {
// //kol_paint_image_pal(0, 0, w, h, data, &image_format)
// h/=4;
// asm volatile ("int $0x40"::"a"(65), "b"(data), "c"(w*65536+h), "d"(0*65536+0), "D"(0), "S"(24) );
//// asm volatile ("int $0x40"::"a"(7), "c"(w*65536+h), "d"(x*65536+y), "b"(data));
// };
//
//// free(image_data);
// free(image_data);
 
 
};
void rskos_resize_window(int w, int h) {
/programs/games/marblematch3/game/rskos.h
6,8 → 6,11
 
unsigned int rskos_get_time();
 
void rskos_draw_area(int x, int y, int w, int h, int k_scale, unsigned char *data, unsigned char *scaled_buffer);
#define RSKOS_BGRA 32
#define RSKOS_BGR 24
 
void rskos_draw_area(int x, int y, int w, int h, int k_scale, unsigned char *data, unsigned char *scaled_buffer, int image_format);
 
void rskos_resize_window(int w, int h);
void rskos_get_screen_size(unsigned int *pw, unsigned int *ph);