diff --git a/programs/games/heliothryx/Tupfile.lua b/programs/games/heliothryx/Tupfile.lua
index a83d4ed9e7..707584a06a 100644
--- a/programs/games/heliothryx/Tupfile.lua
+++ b/programs/games/heliothryx/Tupfile.lua
@@ -1,8 +1,21 @@
if tup.getconfig("NO_FASM") ~= "" or tup.getconfig("NO_GCC") ~= "" then return end
+-- tup.rule("echo \"#define LANG_" .. ((tup.getconfig("LANG") == "") and "en" or tup.getconfig("LANG")) .. "\" > lang.h", {"lang.h"})
HELPERDIR = (tup.getconfig("HELPERDIR") == "") and "../.." or tup.getconfig("HELPERDIR")
tup.include(HELPERDIR .. "/use_gcc.lua")
tup.include(HELPERDIR .. "/use_sound.lua")
LDFLAGS = LDFLAGS .. " -T kolibri.ld"
tup.append_table(OBJS, tup.rule("start.asm", "fasm %f %o", "start.o"))
-compile_gcc{"system/kolibri.c", "game/rs/rsmicrolibc.c", "game/rs/rsplatform_kos.c", "game/rs/rsmx.c", "game/rsnoise.c", "game/rsgentex.c", "game/rsmain.c", "game/rsgame.c", "game/rsgamedraw.c", "game/rskos.c", "game/rsgametext.c", "game/rsgamemenu.c"}
-link_gcc("heliothryx")
+
+if tup.getconfig("LANG") == "ru"
+then C_LANG = "LANG_RU"
+
+elseif tup.getconfig("LANG") == "sp"
+then C_LANG = "LANG_SP" -- just for example, other languages are not implemented
+
+else C_LANG = "LANG_EN" -- default language is English
+end
+
+CFLAGS = CFLAGS .. " -DRS_KOS -D" .. C_LANG .. " "
+
+compile_gcc{ "system/kolibri.c", "game/rs/rsmicrolibc.c", "game/rs/rsplatform_kos.c", "game/rs/rsmx.c", "game/rsnoise.c", "game/rsgentex.c", "game/rsgame.c", "game/rsgamedraw.c", "game/rskos.c", "game/rsgametext.c", "game/rsgamemenu.c"}
+link_gcc ("heliothryx")
diff --git a/programs/games/heliothryx/game/rs/rsmicrolibc.c b/programs/games/heliothryx/game/rs/rsmicrolibc.c
index e5049201ce..e51613d0d7 100644
--- a/programs/games/heliothryx/game/rs/rsmicrolibc.c
+++ b/programs/games/heliothryx/game/rs/rsmicrolibc.c
@@ -170,5 +170,24 @@ void* memcpy(void *dst, const void *src, unsigned size)
}
+char* strchr(char* s, int c) {
+ while (*s) {
+ if (*s == (char) c) {
+ return s;
+ };
+ s++;
+ };
+ return NULL;
+
+};
+
+unsigned int strlen ( char * str ) {
+ unsigned int len = 0;
+ while ( *str ) {
+ len++;
+ str++;
+ };
+ return len;
+};
diff --git a/programs/games/heliothryx/game/rs/rsmicrolibc.h b/programs/games/heliothryx/game/rs/rsmicrolibc.h
index 110159ef37..9bb391ae84 100644
--- a/programs/games/heliothryx/game/rs/rsmicrolibc.h
+++ b/programs/games/heliothryx/game/rs/rsmicrolibc.h
@@ -50,4 +50,7 @@ void free(void* pointer);
void* memset(void *mem, int c, unsigned size);
void* memcpy(void *dst, const void *src, unsigned size);
+char* strchr(char* s, int c);
+unsigned int strlen ( char * str );
+
#endif
diff --git a/programs/games/heliothryx/game/rs/rsplatform.h b/programs/games/heliothryx/game/rs/rsplatform.h
index 00918b6b0d..c3f0f4295b 100644
--- a/programs/games/heliothryx/game/rs/rsplatform.h
+++ b/programs/games/heliothryx/game/rs/rsplatform.h
@@ -40,43 +40,52 @@
#define RS_KEY_X 45
+unsigned int get_time();
+
+
typedef void RSFUNC0();
-typedef void RSFUNC1i(int);
+/*typedef void RSFUNC1i(int);
typedef void RSFUNC2i(int,int);
-typedef void RSFUNC1i1f(int,float);
+typedef void RSFUNC1i1f(int,float); */
typedef RSFUNC0 *PRSFUNC0;
-typedef RSFUNC1i *PRSFUNC1i;
+/*typedef RSFUNC1i *PRSFUNC1i;
typedef RSFUNC2i *PRSFUNC2i;
-typedef RSFUNC1i1f *PRSFUNC1i1f;
-
+typedef RSFUNC1i1f *PRSFUNC1i1f;*/
+/*
void NullFunc0();
void NullFunc1i(int i);
void NullFunc2i(int i, int j);
void NullFunc1i1f(int i, float f);
+*/
typedef struct rs_app_t {
unsigned short app_time;
unsigned short delta_time;
-
- PRSFUNC2i OnSize;
+
+ /*
PRSFUNC2i OnKeyDown;
PRSFUNC1i OnKeyUp;
+
+ PRSFUNC2i OnMouseDown;
+ PRSFUNC2i OnMouseUp;
PRSFUNC0 OnAppProcess;
PRSFUNC0 rsAppOnInitDisplay;
PRSFUNC0 rsAppOnTermDisplay;
+
+ */
} rs_app_t;
extern rs_app_t rs_app;
-void rsAppZero();
+//void rsAppZero();
diff --git a/programs/games/heliothryx/game/rs/rsplatform_kos.c b/programs/games/heliothryx/game/rs/rsplatform_kos.c
index 665103aa26..c0c9ffc663 100644
--- a/programs/games/heliothryx/game/rs/rsplatform_kos.c
+++ b/programs/games/heliothryx/game/rs/rsplatform_kos.c
@@ -1,101 +1,101 @@
#include "rsplatform.h"
-
+
rs_app_t rs_app;
-
-
-
-
+
+
+
+
// set this macro to zero (0) if bug is fixed
#define FIX_MENUETOS_LEGACY_ONE_PIXEL_BORDER_GAP_BUG (-1)
-
+
// Fixed frame rate, set to 25
-#define GAME_REQUIRED_FPS 25
-
-
-
-//extern char PATH[256];
-//extern char PARAM[256];
-
+#define GAME_REQUIRED_FPS 25
+
+
+
+//extern char PATH[256];
+//extern char PARAM[256];
+
int window_width, window_height;
-
+
int fps = 0;
int dt = 1;
int draw_dt = 1;
int area_width = 160;
int area_height = 160;
-
+
int w_plus = 0;
-
-
-
-
-
+
+
+
+
+
#define BIT_SET(var,mask) { var |= (mask); }
#define BIT_CLEAR(var,mask) { var &= ~(mask); }
#define BIT_TOGGLE(var,mask) { var ^= (mask); }
-
+
#define IS_BIT_SET(var,mask) ( (var) & (mask) )
#define IS_BIT_CLEARED(var,mask) (!( (var) & (mask) ))
-
-
+
+
void BoardPuts(const char *s)
{
- unsigned int i = 0;
- while(*(s + i))
- {
- asm volatile ("int $0x40"::"a"(63), "b"(1), "c"(*(s + i)));
- i++;
- }
+ unsigned int i = 0;
+ while(*(s + i))
+ {
+ asm volatile ("int $0x40"::"a"(63), "b"(1), "c"(*(s + i)));
+ i++;
+ }
}
-
+
void board_write_integer(const char *s, int i) {
-
- char tmp[16];
-
-
-
+
+ char tmp[16];
+
+
+
};
-
-
+
+
void kol_wnd_resize(unsigned w, unsigned h)
{
- asm volatile ("int $0x40"::"a"(67), "b"(-1), "c"(-1), "d"(w), "S"(h));
+ asm volatile ("int $0x40"::"a"(67), "b"(-1), "c"(-1), "d"(w), "S"(h));
}
-
-
-
-
+
+
+
+
void wnd_draw()
{
-
- char tmp[] = "Fps:000 | Heliothryx Beta by Roman Shuvalov";
-
- kol_paint_start();
-
- tmp[4] = '0' + ( (fps/100) % 10 );
- tmp[5] = '0' + ( (fps/10) % 10 );
- tmp[6] = '0' + ( (fps) % 10 );
-
- kol_wnd_define(100, 100, window_width, window_height, 0x74ddddff, 0x34ddddff, "HELLO WINDOW");
- kol_wnd_caption(tmp);
-
- GameProcess();
-
- kol_paint_end();
-
+
+ char tmp[] = "Fps:000 | Heliothryx Beta by Roman Shuvalov";
+
+ kol_paint_start();
+
+ tmp[4] = '0' + ( (fps/100) % 10 );
+ tmp[5] = '0' + ( (fps/10) % 10 );
+ tmp[6] = '0' + ( (fps) % 10 );
+
+ kol_wnd_define(100, 100, window_width, window_height, 0x74ddddff, 0x34ddddff, "HELLO WINDOW");
+ kol_wnd_caption(tmp);
+
+ GameProcess();
+
+ kol_paint_end();
+
}
-
-
-
-
+
+
+
+
/// ===========================================================
-
+
void kol_main()
{
-
- BoardPuts("Hello, Heliothryx!\n");
-
- int err;
+
+ BoardPuts("Hello, Heliothryx!\n");
+
+ int err;
int version =-1;
if((err = InitSound(&version)) !=0 ){
@@ -106,139 +106,137 @@ void kol_main()
(SOUND_VERSION<(version >> 16))){
BoardPuts("Sound Error 2\n");
}
-
-
- unsigned event;
- unsigned key;
- unsigned key_up;
-
- unsigned btn;
- unsigned pos, x, y;
- int gx, gy;
-
- //srand(kol_system_time_get());
-
- // kol_event_mask( 0xC0000027 ); // enable using of mouse
- kol_event_mask(7); // keyboard only
-
- kol_key_mode_set(1);
-
- area_width = 640;
- area_height = 360;
-
- // Initializing variables
- window_width = FIX_MENUETOS_LEGACY_ONE_PIXEL_BORDER_GAP_BUG + area_width + 10; // 2 x 5px border
- window_height = FIX_MENUETOS_LEGACY_ONE_PIXEL_BORDER_GAP_BUG + kol_skin_height() + area_height + 5; // bottom 5px border
-
-
- GameInit();
-
- wnd_draw();
-
- fps = 0;
-
- unsigned int tick_start = kol_time_tick();
- unsigned int tick_current = tick_start;
- unsigned int tick_last = tick_start;
-
- unsigned int fps_counter = 0;
- int wait_time;
- int already_drawn = 0;
-
- float xf;
- float xfs;
- int xfs_i;
-
- while (1) {
- tick_last = tick_current;
- tick_current = kol_time_tick();
- dt = tick_current - tick_last;
- tick_last = tick_current;
-
- already_drawn = 0;
-
- while (( event = kol_event_wait_time(1) )) {
-
- switch (event) {
-
- case 1:
- wnd_draw(); // <--- need to clear event!
- already_drawn = 1;
- break;
-
- case 2:
- key = kol_key_get();
- key = (key & 0xff00)>>8;
- key_up = key & 0x80;
- key = key & 0x7F;
-
- if (key_up) {
- GameKeyUp(key, 1);
- }
- else {
- GameKeyDown(key);
- };
-
- break;
-
- case 3:
- switch ((kol_btn_get() & 0xff00)>>8)
- {
- case 1: // close button
- kol_exit();
- case 2: // 'new' button
- //init_board();
- //wnd_draw();
- break;
- }
- break;
-
- case 6:
- btn = kol_mouse_btn(); // read mouse button
- pos = kol_mouse_posw(); // read mouse position
- x = pos / 65536;
- y = pos % 65536;
- if (x > window_width)
- x=0;
- if (y > window_height)
- y=0;
-
-
- break;
- }
-
- };
-
-
- if (!already_drawn) {
- wnd_draw();
- };
-
-
- fps_counter++;
-
- tick_current = kol_time_tick();
-
- if (tick_current > tick_start+100) {
- fps = fps_counter;
- fps_counter = 0;
- tick_start += 100;
- };
-
- draw_dt = tick_current - tick_last;
-
- wait_time = (100/GAME_REQUIRED_FPS) - draw_dt;
- if (wait_time <= 0) {
- wait_time = 1;
- };
- kol_sleep(wait_time);
-
-
- }
-
- GameTerm();
-
- kol_exit();
+
+
+ unsigned event;
+ unsigned key;
+ unsigned key_up;
+
+ unsigned btn;
+ unsigned pos, x, y;
+ int gx, gy;
+
+ //srand(kol_system_time_get());
+
+ // kol_event_mask( 0xC0000027 ); // enable using of mouse
+ kol_event_mask(7); // keyboard only
+
+ kol_key_mode_set(1);
+
+ area_width = 640;
+ area_height = 360;
+
+ // Initializing variables
+ window_width = FIX_MENUETOS_LEGACY_ONE_PIXEL_BORDER_GAP_BUG + area_width + 10; // 2 x 5px border
+ window_height = FIX_MENUETOS_LEGACY_ONE_PIXEL_BORDER_GAP_BUG + kol_skin_height() + area_height + 5; // bottom 5px border
+
+
+ GameInit();
+
+ wnd_draw();
+
+ fps = 0;
+
+ unsigned int tick_start = kol_time_tick();
+ unsigned int tick_current = tick_start;
+ unsigned int tick_last = tick_start;
+
+ unsigned int fps_counter = 0;
+ int wait_time;
+ int already_drawn = 0;
+
+ float xf;
+ float xfs;
+ int xfs_i;
+
+ while (1) {
+ tick_last = tick_current;
+ tick_current = kol_time_tick();
+ dt = tick_current - tick_last;
+ tick_last = tick_current;
+
+ already_drawn = 0;
+
+ while (( event = kol_event_wait_time(1) )) {
+
+ switch (event) {
+
+ case 1:
+ wnd_draw(); // <--- need to clear event!
+ already_drawn = 1;
+ break;
+
+ case 2:
+ key = kol_key_get();
+ key = (key & 0xff00)>>8;
+ key_up = key & 0x80;
+ key = key & 0x7F;
+
+ if (key_up) {
+ GameKeyUp(key, 1);
+ }
+ else {
+ GameKeyDown(key);
+ };
+
+ break;
+
+ case 3:
+ switch ((kol_btn_get() & 0xff00)>>8)
+ {
+ case 1: // close button
+ kol_exit();
+ case 2: // 'new' button
+ //init_board();
+ //wnd_draw();
+ break;
+ }
+ break;
+
+ case 6:
+ btn = kol_mouse_btn(); // read mouse button
+ pos = kol_mouse_posw(); // read mouse position
+ x = pos / 65536;
+ y = pos % 65536;
+ if (x > window_width)
+ x=0;
+ if (y > window_height)
+ y=0;
+
+
+ break;
+ }
+
+ };
+
+
+ if (!already_drawn) {
+ wnd_draw();
+ };
+
+
+ fps_counter++;
+
+ tick_current = kol_time_tick();
+
+ if (tick_current > tick_start+100) {
+ fps = fps_counter;
+ fps_counter = 0;
+ tick_start += 100;
+ };
+
+ draw_dt = tick_current - tick_last;
+
+ wait_time = (100/GAME_REQUIRED_FPS) - draw_dt;
+ if (wait_time <= 0) {
+ wait_time = 1;
+ };
+ kol_sleep(wait_time);
+
+
+ }
+
+ GameTerm();
+
+ kol_exit();
}
-
-
diff --git a/programs/games/heliothryx/game/rsgame.c b/programs/games/heliothryx/game/rsgame.c
index 5d94f371bd..584c64a515 100755
--- a/programs/games/heliothryx/game/rsgame.c
+++ b/programs/games/heliothryx/game/rsgame.c
@@ -24,6 +24,7 @@
#endif
+
rs_game_t game;
@@ -162,6 +163,24 @@ void soundbuf_sin_fade(rs_soundbuf_t *snd, float freq) {
for (i = 0; i < snd->length_samples; i++) {
snd->data[i] = ( 1.0 - 1.0*i/snd->length_samples ) * sin( ( (1.0 - 0.48*i/snd->length_samples) * freq ) *i) * amp;
};
+
+
+ /*
+
+ // ok
+
+ rs_sgen_init(2, snd->length_samples);
+ rs_sgen_func_pm(1, 880.0, 21.0, 0.3, 110.0, 0.3);
+ rs_sgen_func_normalize(1, 1.0);
+ rs_sgen_func_lowpass(0, 1, 1.0, 0.0, 1.0);
+ rs_sgen_wave_out(0);
+
+ memcpy(snd->data, rs_sgen_reg.wave_out, snd->length_samples*2 );
+
+ rs_sgen_term();
+
+ */
+
rskos_snd_update_buffer(&snd->hbuf, snd->data, snd->length_samples);
};
@@ -196,9 +215,9 @@ void game_reg_init() {
game.status = STATUS_MENU;
game.window_scale = 2;
- #ifdef RS_LINUX
+ #ifndef RS_KOS
game.window_scale = 3;
- window_scale_str[3] = '3';
+ window_scale_str[3] = '3';
#endif
game.keyboard_state = 0;
@@ -421,7 +440,7 @@ void GameInit() {
rs_gen_term();
- #ifdef RS_LINUX
+ #ifndef RS_KOS
rs_audio_init(RS_AUDIO_FMT_MONO16, RS_AUDIO_FREQ_16000, 0);
#endif
@@ -446,7 +465,7 @@ void GameTerm() {
DEBUG10("--- Game Term ---");
- #ifdef RS_LINUX
+ #ifndef RS_KOS
rs_audio_term();
#endif
@@ -511,6 +530,7 @@ void GameKeyDown(int key, int first) {
if ( (game.menu_index == MENU_SETTINGS) && (game.menu_item_index == MENU_ITEM_WINDOW_SCALE) ) {
game_change_window_scale(-1);
+ game_ding(1);
};
//PlayBuffer(hBuff, 0);
@@ -520,6 +540,7 @@ void GameKeyDown(int key, int first) {
if ( (game.menu_index == MENU_SETTINGS) && (game.menu_item_index == MENU_ITEM_WINDOW_SCALE) ) {
game_change_window_scale(1);
+ game_ding(1);
};
//StopBuffer(hBuff);
@@ -591,6 +612,16 @@ void GameKeyUp(int key) {
};
+void GameMouseDown(int x, int y) {
+ game.tx = x;
+ game.ty = y;
+ DEBUG10f("Mouse Down %d, %d \n", x, y);
+};
+
+void GameMouseUp(int x, int y) {
+ //
+};
+
void game_change_window_scale(int d) {
int scale = window_scale_str[3] - '0';
@@ -621,6 +652,9 @@ void game_change_window_scale(int d) {
rskos_resize_window( GAME_WIDTH * scale, GAME_HEIGHT * scale );
window_scale_str[3] = scale + '0';
+
+
+
};
void game_ding(int i) {
diff --git a/programs/games/heliothryx/game/rsgame.h b/programs/games/heliothryx/game/rsgame.h
index 7f8a6f6716..b8778db5ee 100755
--- a/programs/games/heliothryx/game/rsgame.h
+++ b/programs/games/heliothryx/game/rsgame.h
@@ -8,6 +8,14 @@
*/
+#ifndef RS_LINUX
+ #ifndef RS_WIN32
+ #ifndef RS_KOS
+ #error Please specify platform
+ #endif
+ #endif
+#endif
+
#include "rskos.h"
#include "rs/rsplatform.h"
@@ -182,6 +190,9 @@ void GameTerm();
void GameKeyDown(int key, int first);
void GameKeyUp(int key);
+void GameMouseDown(int x, int y);
+void GameMouseUp(int x, int y);
+
void game_change_window_scale(int d);
#endif // RSGAME_H_INCLUDED
diff --git a/programs/games/heliothryx/game/rsgamedraw.c b/programs/games/heliothryx/game/rsgamedraw.c
index a94852a212..f4459743ff 100755
--- a/programs/games/heliothryx/game/rsgamedraw.c
+++ b/programs/games/heliothryx/game/rsgamedraw.c
@@ -6,7 +6,7 @@
#include "rsnoise.h"
-
+#include "strings.h"
void game_draw() {
@@ -76,9 +76,9 @@ void game_draw() {
texture_draw(&game.framebuffer, &game.tex_rocks[i], 250+80*rs_noise(i,150), 60+60*rs_noise(i,1110), DRAW_MODE_ADDITIVE );
};
- game_textout( GAME_WIDTH/2 - 100, 40, 1, "HELIOTHRYX");
- game_textout( GAME_WIDTH/2 - 8, 58, 3, "TECHDEMO");
- game_textout( 2, GAME_HEIGHT-10, 2, "DEVELOPER: ROMAN SHUVALOV` TOGLIATTI_ 2014");
+ game_textout( GAME_WIDTH/2 - 100, 40, 1, "HELI0THRYX");
+ game_textout( GAME_WIDTH/2 - 8, 58, 3, "TECHDEM0");
+ game_textout( 2, GAME_HEIGHT-10, 2, L_BOTTOM_LINE_DEVELOPER_INFO);
};
}
@@ -100,8 +100,8 @@ void game_draw() {
};
};
- game_textout( 2, 2, 2, "THIS IS TECHDEMO` ");
- game_textout( 2, 12, 2, "USE ARROWS TO MOVE_ TO SHOOT_ This is procedural font. To minimize program size, only necessary characters are implemented:
+Heliothryx Localization Tool: Text Converter
+
+
+
+
+
+
+
Actually this is part of ASCII table starting from '0' (0x30).
+ +Note that not all latin characters are in fact implemented, for example, 'S' can be successfully replaced by number 5, so other symbol are placed in place of 'S'. Some punctuation symbols are also replaced, for example, dot (.) in ASCII table have 0x2E code which is outside our range, so it is implemented in place of useless grave accent symbol (`).
+ +To make process of writing string constants easier, this tool has been made. Write any text to first field, hit Enter and take string that you can use in your code. If you try to use unsupported characters, they will be replaced by dot and you will get warning.
+ + +