/programs/games/marblematch3/game/rsgame.c |
---|
219,6 → 219,7 |
void game_reg_init() { |
game.loader_counter = 0; |
game.menu_replay_timeout = 0; |
225,6 → 226,8 |
game.process_timer = 0; |
game.hiscore = 0; |
game.sound_index = 0; |
game.need_redraw = 1; |
411,6 → 414,14 |
game.loader_counter++; |
if (game.loader_counter == 2) { |
// Hiscore file... |
rskos_file_load(HISCORE_FILENAME, (unsigned char*)&game.hiscore, 4); |
DEBUG10f("hiscore: %d \n", game.hiscore); |
// Textures... |
game_textures_init_stage2(); |
533,6 → 544,12 |
// Game Over |
game.status = STATUS_MENU; |
game.need_redraw = 1; |
if (game.score > game.hiscore) { |
game.hiscore = game.score; |
rskos_file_save(HISCORE_FILENAME, (unsigned char*)&game.hiscore, 4); |
}; |
soundbuf_play(&game.sound_bang); |
game.menu_replay_timeout = 40; |
631,7 → 648,7 |
if (key == RS_KEY_A) { |
game.need_redraw = 1; |
game.time = 50; |
}; |
/programs/games/marblematch3/game/rsgame.h |
---|
142,6 → 142,12 |
//#define GAME_MODE_MATCH3 0 |
//#define GAME_MODE_RAMPAGE 1 |
#ifdef RS_KOS |
#define HISCORE_FILENAME "/sys/games/marble-hiscore.dat" |
#else |
#define HISCORE_FILENAME "marble-hiscore.dat" |
#endif |
typedef struct rs_game_t { |
rs_texture_t framebuffer; |
unsigned char *bgr_framebuffer; // 24-bit BGRBGRBGR... for direct drawing |
179,6 → 185,8 |
int process_timer; |
int hiscore; |
// int tx; |
// int ty; |
// int tz; |
/programs/games/marblematch3/game/rsgamedraw.c |
---|
53,11 → 53,38 |
game_textout_at_center( 0, 260, 0, s ); |
game_textout_at_center( -3, 260-2, 3, s ); |
if (game.score == game.hiscore) { |
game_textout_at_center( 0, 290, 0, L_NEW_HISCORE); |
game_textout_at_center( -3, 290-2, 3, L_NEW_HISCORE ); |
} |
else { |
char hs[] = L_HISCORE; |
str_num = strchr(hs, 'x'); |
str_num[0] = '0' + ( (game.hiscore / 100) % 10); |
str_num[1] = '0' + ( (game.hiscore / 10) % 10); |
str_num[2] = '0' + ( (game.hiscore / 1) % 10); |
game_textout_at_center( 0, 290, 0, hs); |
game_textout_at_center( -3, 290-2, 3, hs ); |
}; |
} |
else { |
if (game.hiscore) { |
char *str_num; |
char hs[] = L_HISCORE; |
str_num = strchr(hs, 'x'); |
str_num[0] = '0' + ( (game.hiscore / 100) % 10); |
str_num[1] = '0' + ( (game.hiscore / 10) % 10); |
str_num[2] = '0' + ( (game.hiscore / 1) % 10); |
game_textout_at_center( 0, 230, 0, hs); |
game_textout_at_center( -3, 230-2, 3, hs ); |
}; |
}; |
if (!game.menu_replay_timeout) { |
game_textout_at_center( 0, 300, 0, L_START ); |
game_textout_at_center( -3, 300-2, 3, L_START ); |
game_textout_at_center( 0, 400, 0, L_START ); |
game_textout_at_center( -3, 400-2, 3, L_START ); |
}; |
/programs/games/marblematch3/game/rskos.c |
---|
104,6 → 104,46 |
rsAppExit(); |
}; |
int rskos_file_save(char *filename, unsigned char *data, int length) { |
FILE *fp; |
fp = fopen(filename, "w"); |
if (!fp) { |
return 0; |
}; |
fwrite(data, 1, length, fp); |
fclose(fp); |
return 1; |
}; |
int rskos_file_load(char *filename, unsigned char *data, int length) { |
FILE *fp; |
fp = fopen(filename, "r"); |
if (!fp) { |
return 0; |
}; |
fread(data, 1, length, fp); |
fclose(fp); |
return 1; |
}; |
//void rskos_snd_init() { |
// // |
// |
144,10 → 184,85 |
#include "rs/rsplatform.h" |
#pragma pack(push,1) |
typedef struct rskos_file_struct_t { |
unsigned int func_num; |
unsigned int offset; |
unsigned int flags; |
unsigned int length; |
unsigned char *data; |
unsigned char zero; |
char *filename; |
} rskos_file_struct_t; |
#pragma pack(pop) |
unsigned int rskos_get_time() { |
return 1; |
}; |
int rskos_file_load(char *filename, unsigned char *data, int length) { |
// char filename_abs[] = "/sys/games/************************"; |
// memcpy( filename_abs[ strchr(filename_abs, "*") ], filename, strlen(filename)+1 ); |
rskos_file_struct_t file_struct; |
file_struct.func_num = 0; |
file_struct.offset = 0; |
file_struct.flags = 0; |
file_struct.length = length; |
file_struct.data = data; |
file_struct.zero = 0; |
file_struct.filename = filename; |
asm volatile ("int $0x40"::"a"(70), "b"(&file_struct) : "memory"); |
return 1; |
} |
int rskos_file_save(char *filename, unsigned char *data, int length) { |
// char filename_abs[] = "/sys/games/************************"; |
// memcpy( filename_abs[ strchr(filename_abs, "*") ], filename, strlen(filename)+1 ); |
rskos_file_struct_t file_struct; |
file_struct.func_num = 2; |
file_struct.offset = 0; |
file_struct.flags = 0; |
file_struct.length = length; |
file_struct.data = data; |
file_struct.zero = 0; |
file_struct.filename = filename; |
asm volatile ("int $0x40"::"a"(70), "b"(&file_struct) : "memory" ); |
return 1; |
} |
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); |
/programs/games/marblematch3/game/rskos.h |
---|
16,6 → 16,11 |
void rskos_exit(); |
// files |
int rskos_file_save(char *filename, unsigned char *data, int length); |
int rskos_file_load(char *filename, unsigned char *data, int length); |
// sound |
#ifndef SNDBUF |
/programs/games/marblematch3/game/strings.h |
---|
2,7 → 2,7 |
#define RS_STRINGS_H |
#ifndef RS_KOS |
#include "strings_en.h" |
#include "strings_ru.h" |
#else |
#ifdef LANG_RU |
/programs/games/marblematch3/game/strings_en.h |
---|
17,6 → 17,9 |
#define L_GAME_OVER "GAME 0VER" |
#define L_HISCORE "REC0RD: xxx" |
#define L_NEW_HISCORE "NEW REC0RD" |
#define L_BOTTOM_LINE_DEVELOPER_INFO "DEVELOPER: ROMAN SHUVALOV` TOGLIATTI_ 2014" |
#endif |
/programs/games/marblematch3/game/strings_ru.h |
---|
17,6 → 17,9 |
#define L_GAME_OVER "igPA 0K0H4EHA" |
#define L_HISCORE "PEK0Pd: xxx" |
#define L_NEW_HISCORE "H0B\\^ PEK0Pd" |
#define L_BOTTOM_LINE_DEVELOPER_INFO "PA3PAb0T4iK: P0MAH hYBAl0B` T0l]aTTi_ 2014" |
#endif |