mirror of
https://github.com/ondra-novak/gates_of_skeldal.git
synced 2025-07-05 06:00:33 -04:00
import sdl, some tests, nothing work yet
This commit is contained in:
parent
a7278bac40
commit
378b5586ab
37 changed files with 721 additions and 167 deletions
|
@ -1,7 +1,16 @@
|
||||||
cmake_minimum_required(VERSION 3.28)
|
cmake_minimum_required(VERSION 3.28)
|
||||||
project(skeldal)
|
project(skeldal)
|
||||||
|
|
||||||
|
# Najít SDL2 knihovnu
|
||||||
|
find_package(SDL2 REQUIRED)
|
||||||
|
|
||||||
|
|
||||||
include_directories(platform libs)
|
include_directories(platform libs)
|
||||||
|
|
||||||
|
|
||||||
|
include_directories( ${SDL2_INCLUDE_DIRS})
|
||||||
add_compile_options(-funsigned-char)
|
add_compile_options(-funsigned-char)
|
||||||
|
enable_testing()
|
||||||
add_subdirectory(libs)
|
add_subdirectory(libs)
|
||||||
|
add_subdirectory(platform)
|
||||||
add_subdirectory(game)
|
add_subdirectory(game)
|
||||||
|
|
|
@ -42,7 +42,7 @@ char *script_name;
|
||||||
extern word ikones;
|
extern word ikones;
|
||||||
extern word boldcz;
|
extern word boldcz;
|
||||||
extern word font8x5;
|
extern word font8x5;
|
||||||
word icone_color[7]={RGB555(8,8,8),RGB555(31,31,31),RGB555(0,0,15),RGB555(16,16,16),RGB555(0x1b,0x1b,0x1b)};
|
word icone_color[7]={RGB555(8,8,8),RGB555(31,31,31),RGB555(0,0,15),RGB555(16,16,16),RGB555(0x1b,0x1b,0x1b)};
|
||||||
extern word sipka;
|
extern word sipka;
|
||||||
static char *error_texts[]=
|
static char *error_texts[]=
|
||||||
{
|
{
|
||||||
|
@ -233,7 +233,7 @@ static word *p=NULL;
|
||||||
|
|
||||||
const char *c=get_text_field(config_file,"MAPEDIT_WINDOW");
|
const char *c=get_text_field(config_file,"MAPEDIT_WINDOW");
|
||||||
int scale = 1;
|
int scale = 1;
|
||||||
if (c != 0)
|
if (c != 0)
|
||||||
{
|
{
|
||||||
int x,y;
|
int x,y;
|
||||||
if (sscanf(c,"%dx%d",&x,&y) == 2 && x>=640 && y>=480)
|
if (sscanf(c,"%dx%d",&x,&y) == 2 && x>=640 && y>=480)
|
||||||
|
@ -301,7 +301,8 @@ static void key_test(va_list args)
|
||||||
word c;
|
word c;
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
c=*(word *)task_wait_event(E_KEYBOARD);
|
EVENT_MSG *msg = task_wait_event(E_KEYBOARD);
|
||||||
|
c=va_arg(msg->data,unsigned int);
|
||||||
}
|
}
|
||||||
while ((c & 0xff)!='!');
|
while ((c & 0xff)!='!');
|
||||||
puts("\x7");
|
puts("\x7");
|
||||||
|
@ -685,7 +686,7 @@ void load_background()
|
||||||
{
|
{
|
||||||
FILE *f;
|
FILE *f;
|
||||||
long siz;
|
long siz;
|
||||||
|
|
||||||
if (gui_background!=NULL)
|
if (gui_background!=NULL)
|
||||||
{
|
{
|
||||||
free(gui_background);
|
free(gui_background);
|
||||||
|
@ -878,7 +879,7 @@ int main(int argc,char *argv[])
|
||||||
TSTR_LIST adv_cfg=read_config(filename);
|
TSTR_LIST adv_cfg=read_config(filename);
|
||||||
config_file=merge_configs(config_file,adv_cfg);
|
config_file=merge_configs(config_file,adv_cfg);
|
||||||
filename[0]=0;
|
filename[0]=0;
|
||||||
}
|
}
|
||||||
sample_path=get_text_field(config_file,"CESTA_ZVUKY");
|
sample_path=get_text_field(config_file,"CESTA_ZVUKY");
|
||||||
if (sample_path==NULL) sample_path="";
|
if (sample_path==NULL) sample_path="";
|
||||||
mob_dir=get_text_field(config_file,"CESTA_ENEMY");
|
mob_dir=get_text_field(config_file,"CESTA_ENEMY");
|
||||||
|
@ -886,7 +887,7 @@ int main(int argc,char *argv[])
|
||||||
init_sound();
|
init_sound();
|
||||||
init();
|
init();
|
||||||
|
|
||||||
concat(mask,get_text_field(config_file,"CESTA_MAPY"),"*.map");
|
concat(mask,get_text_field(config_file,"CESTA_MAPY"),"*.map");
|
||||||
atexit(shut_down);
|
atexit(shut_down);
|
||||||
// signal(SIGABRT,shut_down);
|
// signal(SIGABRT,shut_down);
|
||||||
init_mob_list();
|
init_mob_list();
|
||||||
|
@ -973,4 +974,4 @@ int __stdcall WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance, LPSTR lpCmdLi
|
||||||
int GetExeVersion()
|
int GetExeVersion()
|
||||||
{
|
{
|
||||||
return MAPEDIT_NVERSION;
|
return MAPEDIT_NVERSION;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,27 @@
|
||||||
SET(files automap.c clk_map.c dialogy.c dump.cpp enemy.c engine2.c globmap.c inv.c kouzla.c menu.c skeldal.c souboje.c
|
SET(files automap.c
|
||||||
builder.c engine1.c gamesave.c interfac.c kniha.c macros.c realgame.c setup.c sndandmus.c specproc.c)
|
clk_map.c
|
||||||
|
dialogy.c
|
||||||
|
dump.cpp
|
||||||
|
enemy.c
|
||||||
|
engine2.c
|
||||||
|
globmap.c
|
||||||
|
inv.c
|
||||||
|
kouzla.c
|
||||||
|
menu.c
|
||||||
|
skeldal.c
|
||||||
|
souboje.c
|
||||||
|
builder.c
|
||||||
|
engine1.c
|
||||||
|
gamesave.c
|
||||||
|
interfac.c
|
||||||
|
kniha.c
|
||||||
|
macros.c
|
||||||
|
realgame.c
|
||||||
|
setup.c
|
||||||
|
chargen.c
|
||||||
|
sndandmus.c
|
||||||
|
specproc.c
|
||||||
|
temp_storage.cpp)
|
||||||
|
|
||||||
add_executable(skeldal ${files})
|
add_executable(skeldal ${files})
|
||||||
target_link_libraries(skeldal skeldal_libs)
|
target_link_libraries(skeldal skeldal_libs skeldal_platform_libs ${SDL2_LIBRARIES} pthread)
|
||||||
|
|
|
@ -24,7 +24,7 @@
|
||||||
|
|
||||||
void display_items_wearing(THUMAN *h);
|
void display_items_wearing(THUMAN *h);
|
||||||
void inv_display_vlastnosti();;
|
void inv_display_vlastnosti();;
|
||||||
extern void (*inv_redraw)();
|
extern void (*inv_redraw)(char);
|
||||||
void write_human_big_name(char *c);
|
void write_human_big_name(char *c);
|
||||||
|
|
||||||
#define MSG_COLOR1 RGB555(30,30,23)
|
#define MSG_COLOR1 RGB555(30,30,23)
|
||||||
|
@ -123,16 +123,16 @@ char *error_text=NULL;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
char select_xicht(int id,int xa,int ya,int xr,int yr);
|
static char select_xicht(int id,int xa,int ya,int xr,int yr);
|
||||||
char vol_vlastnosti(int id,int xa,int ya,int xr,int yr);
|
static char vol_vlastnosti(int id,int xa,int ya,int xr,int yr);
|
||||||
char go_next_page(int id,int xa,int ya,int xr,int yr);
|
static char go_next_page(int id,int xa,int ya,int xr,int yr);
|
||||||
char vls_click(int id,int xa,int ya,int xr,int yr);
|
char vls_click(int id,int xa,int ya,int xr,int yr);
|
||||||
char view_another_click2(int id,int xa,int ya,int xr,int yr);
|
static char view_another_click2(int id,int xa,int ya,int xr,int yr);
|
||||||
//char edit_another_click(int id,int xa,int ya,int xr,int yr);
|
//char edit_another_click(int id,int xa,int ya,int xr,int yr);
|
||||||
char edit_another_click2(int id,int xa,int ya,int xr,int yr);
|
//static char edit_another_click2(int id,int xa,int ya,int xr,int yr);
|
||||||
char gen_exit_editor(int id,int xa,int ya,int xr,int yr);
|
static char gen_exit_editor(int id,int xa,int ya,int xr,int yr);
|
||||||
|
|
||||||
void zobraz_staty(T_VLASTS *st);
|
static void zobraz_staty(T_VLASTS *st);
|
||||||
|
|
||||||
#define CLK_PAGE1 6
|
#define CLK_PAGE1 6
|
||||||
|
|
||||||
|
@ -513,9 +513,9 @@ static void edit_name()
|
||||||
static void stop_edit_name()
|
static void stop_edit_name()
|
||||||
{
|
{
|
||||||
shut_downing_text=1;send_message(E_KEYBOARD,13);
|
shut_downing_text=1;send_message(E_KEYBOARD,13);
|
||||||
task_sleep(NULL);
|
task_sleep();
|
||||||
if (edit_task>0 && is_running(edit_task))
|
if (edit_task>0 && is_running(edit_task))
|
||||||
shut_down_task(edit_task);
|
term_task(edit_task);
|
||||||
shut_downing_text=0;
|
shut_downing_text=0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -623,7 +623,7 @@ void generuj_postavu(THUMAN *h)
|
||||||
//postava je vygenerovana
|
//postava je vygenerovana
|
||||||
}
|
}
|
||||||
|
|
||||||
static void redraw_page3()
|
static void redraw_page3(char)
|
||||||
{
|
{
|
||||||
update_mysky();
|
update_mysky();
|
||||||
schovej_mysku();
|
schovej_mysku();
|
||||||
|
@ -639,7 +639,7 @@ static void redraw_page3()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void redraw_svitek()
|
static void redraw_svitek(char)
|
||||||
{
|
{
|
||||||
if (postavy[cur_edited].bonus==0)
|
if (postavy[cur_edited].bonus==0)
|
||||||
{
|
{
|
||||||
|
@ -649,7 +649,7 @@ static void redraw_svitek()
|
||||||
if (!postavy[charmax-1].used) mode&=~1;
|
if (!postavy[charmax-1].used) mode&=~1;
|
||||||
if (!del_mode) mode&=~4;
|
if (!del_mode) mode&=~4;
|
||||||
b_disables=mode;
|
b_disables=mode;
|
||||||
redraw_page3();
|
redraw_page3(0);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
update_mysky();
|
update_mysky();
|
||||||
|
@ -694,13 +694,13 @@ static void empty_proc()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
char potvrzeno(char *text,void (*redraw)())
|
char potvrzeno(char *text,void (*redraw)(char))
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
unwire_proc=empty_proc;
|
unwire_proc=empty_proc;
|
||||||
stop_edit_name();
|
stop_edit_name();
|
||||||
i=message(2,0,1,texty[118],text,texty[114],texty[115])==0;
|
i=message(2,0,1,texty[118],text,texty[114],texty[115])==0;
|
||||||
redraw();
|
redraw(0);
|
||||||
edit_name();
|
edit_name();
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
@ -721,7 +721,7 @@ static char view_another_click2(int id,int xa,int ya,int xr,int yr)
|
||||||
human_selected=postavy+id;
|
human_selected=postavy+id;
|
||||||
cur_edited=id;
|
cur_edited=id;
|
||||||
edit_name();
|
edit_name();
|
||||||
redraw_page3();
|
redraw_page3(0);
|
||||||
if (del_mode)
|
if (del_mode)
|
||||||
if (potvrzeno(texty[117],redraw_page3))
|
if (potvrzeno(texty[117],redraw_page3))
|
||||||
{
|
{
|
||||||
|
@ -764,15 +764,14 @@ static void enter_reaction(EVENT_MSG *msg,void **unused)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void enter_reaction2(EVENT_MSG *msg,void **unused)
|
static void enter_reaction2(EVENT_MSG *msg,void **)
|
||||||
{
|
{
|
||||||
unused;
|
int c = va_arg(msg->data, int);
|
||||||
int c = va_arg(msg->data, int)
|
|
||||||
if (msg->msg==E_KEYBOARD && c==13 && !shut_downing_text && ~b_disables & 0x3)
|
if (msg->msg==E_KEYBOARD && c==13 && !shut_downing_text && ~b_disables & 0x3)
|
||||||
{
|
{
|
||||||
send_message(E_KEYBOARD,13);
|
send_message(E_KEYBOARD,13);
|
||||||
bott_draw(1);
|
bott_draw(1);
|
||||||
redraw_page3();
|
redraw_page3(0);
|
||||||
msg->msg=-1;
|
msg->msg=-1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -787,7 +786,7 @@ char gen_exit_editor(int id,int xa,int ya,int xr,int yr)
|
||||||
del_mode=0;
|
del_mode=0;
|
||||||
mouse_set_default(H_MS_DEFAULT);
|
mouse_set_default(H_MS_DEFAULT);
|
||||||
b_disables&=~0x4;
|
b_disables&=~0x4;
|
||||||
redraw_svitek();
|
redraw_svitek(0);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
unwire_proc=empty_proc;
|
unwire_proc=empty_proc;
|
||||||
|
@ -799,7 +798,7 @@ char gen_exit_editor(int id,int xa,int ya,int xr,int yr)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (id==2)redraw_generator(1);
|
if (id==2)redraw_generator(1);
|
||||||
else redraw_svitek();
|
else redraw_svitek(0);
|
||||||
edit_name();
|
edit_name();
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -841,7 +840,8 @@ char enter_generator()
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
send_message(E_ADD,E_KEYBOARD,enter_reaction);
|
send_message(E_ADD,E_KEYBOARD,enter_reaction);
|
||||||
i=*(char *)task_wait_event(E_CLOSE_GEN);
|
EVENT_MSG *ev= task_wait_event(E_CLOSE_GEN);;
|
||||||
|
i=va_arg(ev->data, int);
|
||||||
send_message(E_DONE,E_KEYBOARD,enter_reaction);
|
send_message(E_DONE,E_KEYBOARD,enter_reaction);
|
||||||
if (i==3 && potvrzeno(texty[116],redraw_generator)) goto znova;
|
if (i==3 && potvrzeno(texty[116],redraw_generator)) goto znova;
|
||||||
if (i==255) return 1;
|
if (i==255) return 1;
|
||||||
|
@ -857,12 +857,13 @@ char enter_generator()
|
||||||
b_disables=0x7;
|
b_disables=0x7;
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
redraw_svitek();
|
redraw_svitek(0);
|
||||||
change_click_map(clk_page2,CLK_PAGE2);
|
change_click_map(clk_page2,CLK_PAGE2);
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
send_message(E_ADD,E_KEYBOARD,enter_reaction2);
|
send_message(E_ADD,E_KEYBOARD,enter_reaction2);
|
||||||
i=*(char *)task_wait_event(E_CLOSE_GEN);
|
EVENT_MSG *ev= task_wait_event(E_CLOSE_GEN);;
|
||||||
|
i=va_arg(ev->data, int);
|
||||||
send_message(E_DONE,E_KEYBOARD,enter_reaction2);
|
send_message(E_DONE,E_KEYBOARD,enter_reaction2);
|
||||||
if (i==3 && potvrzeno(texty[116],redraw_svitek)) goto znova;
|
if (i==3 && potvrzeno(texty[116],redraw_svitek)) goto znova;
|
||||||
if (i==2)
|
if (i==2)
|
||||||
|
@ -870,7 +871,7 @@ char enter_generator()
|
||||||
del_mode=1;
|
del_mode=1;
|
||||||
mouse_set_default(H_MS_WHO);
|
mouse_set_default(H_MS_WHO);
|
||||||
b_disables|=0x4;
|
b_disables|=0x4;
|
||||||
redraw_svitek();
|
redraw_svitek(0);
|
||||||
i=3;
|
i=3;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -170,7 +170,7 @@ static void dialog_anim(va_list args)
|
||||||
anm=open_mgif(aptr);
|
anm=open_mgif(aptr);
|
||||||
while (anm!=NULL && task_quitmsg())
|
while (anm!=NULL && task_quitmsg())
|
||||||
{
|
{
|
||||||
task_sleep(NULL);
|
task_sleep();
|
||||||
if (!spdc)
|
if (!spdc)
|
||||||
{
|
{
|
||||||
if (ms_last_event.x<=PIC_X+320 && ms_last_event.y<=PIC_Y+180)
|
if (ms_last_event.x<=PIC_X+320 && ms_last_event.y<=PIC_Y+180)
|
||||||
|
|
|
@ -142,12 +142,10 @@ int load_enemy_paths(TMPFILE_RD *f)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static EVENT_PROC(mob_reload)
|
static void mob_reload(EVENT_MSG *msg,void **){
|
||||||
{
|
|
||||||
static int counter=0;
|
static int counter=0;
|
||||||
|
|
||||||
user_ptr;
|
if (msg->msg = E_KOUZLO_KOLO)
|
||||||
WHEN_MSG(E_KOUZLO_KOLO)
|
|
||||||
{
|
{
|
||||||
if (insleep) return;
|
if (insleep) return;
|
||||||
if (counter++==10)
|
if (counter++==10)
|
||||||
|
|
|
@ -888,7 +888,7 @@ static void load_specific_file(int slot_num,char *filename,void **out,int32_t *s
|
||||||
fread(fname,1,12,slot);
|
fread(fname,1,12,slot);
|
||||||
while(fname[0] && !succes)
|
while(fname[0] && !succes)
|
||||||
{
|
{
|
||||||
task_sleep(NULL);
|
task_sleep();
|
||||||
if (task_quitmsg()) break;
|
if (task_quitmsg()) break;
|
||||||
fread(&siz,1,4,slot);
|
fread(&siz,1,4,slot);
|
||||||
if (!strncmp(fname,filename,12)) succes=1; else
|
if (!strncmp(fname,filename,12)) succes=1; else
|
||||||
|
@ -1113,10 +1113,9 @@ char updown_scroll(int id,int xa,int ya,int xr,int yr);
|
||||||
|
|
||||||
static char updown_noinst=0;
|
static char updown_noinst=0;
|
||||||
|
|
||||||
static EVENT_PROC(updown_scroll_hold)
|
static void updown_scroll_hold(EVENT_MSG *msg,void **)
|
||||||
{
|
{
|
||||||
user_ptr;
|
if (msg->msg == E_MOUSE)
|
||||||
WHEN_MSG(E_MOUSE)
|
|
||||||
{
|
{
|
||||||
MS_EVENT *ms;
|
MS_EVENT *ms;
|
||||||
|
|
||||||
|
@ -1128,7 +1127,7 @@ static EVENT_PROC(updown_scroll_hold)
|
||||||
updown_noinst=0;
|
updown_noinst=0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
WHEN_MSG(E_TIMER)
|
if (msg->msg == E_TIMER)
|
||||||
{
|
{
|
||||||
MS_EVENT *ms;
|
MS_EVENT *ms;
|
||||||
|
|
||||||
|
@ -1382,12 +1381,12 @@ T_CLK_MAP clk_save[]=
|
||||||
{-1,0,0,639,479,close_saveload,9,H_MS_DEFAULT},
|
{-1,0,0,639,479,close_saveload,9,H_MS_DEFAULT},
|
||||||
};
|
};
|
||||||
|
|
||||||
static EVENT_PROC(saveload_keyboard)
|
static void saveload_keyboard(EVENT_MSG *msg,void **)
|
||||||
{
|
{
|
||||||
user_ptr;
|
if (msg->msg == E_KEYBOARD)
|
||||||
WHEN_MSG(E_KEYBOARD)
|
|
||||||
{
|
{
|
||||||
switch (GET_DATA(word)>>8)
|
int v = va_arg(msg->data, int);
|
||||||
|
switch (v>>8)
|
||||||
{
|
{
|
||||||
case 1:unwire_proc();wire_proc();break;
|
case 1:unwire_proc();wire_proc();break;
|
||||||
case 'H':if (last_select>0) bright_slot((last_select-1)*SLOT_SPACE+1);break;
|
case 'H':if (last_select>0) bright_slot((last_select-1)*SLOT_SPACE+1);break;
|
||||||
|
|
|
@ -1386,7 +1386,8 @@ void init_tracks();
|
||||||
void recalc_volumes(int sector,int side);
|
void recalc_volumes(int sector,int side);
|
||||||
void play_effekt(int x,int y,int xd,int yd,int side,int sided,TMA_SOUND *p);
|
void play_effekt(int x,int y,int xd,int yd,int side,int sided,TMA_SOUND *p);
|
||||||
void create_playlist(char *playlist);
|
void create_playlist(char *playlist);
|
||||||
void play_next_music(char **c);
|
const char *get_next_music_from_playlist();
|
||||||
|
const char * end_of_song_callback(void *ctx);
|
||||||
void purge_playlist();
|
void purge_playlist();
|
||||||
void restore_sound_names();
|
void restore_sound_names();
|
||||||
void play_sample_at_sector(int sample,int sector1,int sector2,int track, char loop);
|
void play_sample_at_sector(int sample,int sector1,int sector2,int track, char loop);
|
||||||
|
|
|
@ -495,17 +495,16 @@ static char *fly_text;
|
||||||
static int fly_x,fly_y,fly_xs,fly_ys;
|
static int fly_x,fly_y,fly_xs,fly_ys;
|
||||||
static void *fly_background;
|
static void *fly_background;
|
||||||
|
|
||||||
EVENT_PROC(global_map_point)
|
void global_map_point(EVENT_MSG *msg,void **)
|
||||||
{
|
{
|
||||||
MS_EVENT *ms;
|
MS_EVENT *ms;
|
||||||
|
|
||||||
user_ptr;
|
if(msg->msg == E_INIT)
|
||||||
WHEN_MSG(E_INIT)
|
|
||||||
{
|
{
|
||||||
fly_background=NULL;last_index=0;fly_text=NULL;
|
fly_background=NULL;last_index=0;fly_text=NULL;
|
||||||
fly_x=0;fly_y=0;fly_xs=4;fly_ys=4;
|
fly_x=0;fly_y=0;fly_xs=4;fly_ys=4;
|
||||||
}
|
}
|
||||||
WHEN_MSG(E_MOUSE)
|
if(msg->msg == E_MOUSE)
|
||||||
{
|
{
|
||||||
int x,y,i,xs,ys;
|
int x,y,i,xs,ys;
|
||||||
char *ptr;
|
char *ptr;
|
||||||
|
@ -561,7 +560,7 @@ EVENT_PROC(global_map_point)
|
||||||
trans_bar(x,y,xs,ys,0);
|
trans_bar(x,y,xs,ys,0);
|
||||||
position(x+2,y+2);outtext(fly_text);
|
position(x+2,y+2);outtext(fly_text);
|
||||||
}
|
}
|
||||||
send_message(E_MOUSE,msg);
|
send_message(E_MOUSE,ms);
|
||||||
ukaz_mysku();
|
ukaz_mysku();
|
||||||
showview(fly_x,fly_y,fly_xs+1,fly_ys);
|
showview(fly_x,fly_y,fly_xs+1,fly_ys);
|
||||||
showview(fly_x=x,fly_y=y,(fly_xs=xs)+1,fly_ys=ys);
|
showview(fly_x=x,fly_y=y,(fly_xs=xs)+1,fly_ys=ys);
|
||||||
|
@ -582,7 +581,7 @@ EVENT_PROC(global_map_point)
|
||||||
msg->msg=-1;
|
msg->msg=-1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
WHEN_MSG(E_DONE)
|
if (msg->msg == E_DONE)
|
||||||
{
|
{
|
||||||
free(fly_background);
|
free(fly_background);
|
||||||
}
|
}
|
||||||
|
|
|
@ -232,23 +232,30 @@ void open_message_win(int pocet_textu,char **texts)
|
||||||
|
|
||||||
static char default_action,cancel_action;
|
static char default_action,cancel_action;
|
||||||
|
|
||||||
EVENT_PROC(message_keyboard)
|
void message_keyboard(EVENT_MSG *msg,void **user_ptr)
|
||||||
{
|
{
|
||||||
switch(GET_MSG())
|
char *c;
|
||||||
|
char *d;
|
||||||
|
switch(msg->msg)
|
||||||
{
|
{
|
||||||
case E_INIT:SAVE_USER_PTR(NewArr(char,strlen(GET_DATA(char *))+1));
|
case E_INIT:
|
||||||
strcpy(GET_USER(char *),GET_DATA(char *));
|
c = va_arg(msg->data, char *);
|
||||||
break;
|
d = NewArr(char, strlen(c)+1);
|
||||||
case E_DONE:free(*GET_USER_PTR());
|
strcpy(d, c);
|
||||||
SAVE_USER_PTR(NULL);
|
*user_ptr = d;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case E_DONE:c = *user_ptr;
|
||||||
|
free(c);
|
||||||
|
user_ptr = NULL;
|
||||||
break;
|
break;
|
||||||
case E_KEYBOARD:
|
case E_KEYBOARD:
|
||||||
{
|
{
|
||||||
char *keys=GET_USER(char *);
|
char *keys=*(char **)(user_ptr);
|
||||||
char code,*p;
|
char code,*p;
|
||||||
int key;
|
int key;
|
||||||
|
|
||||||
code=GET_DATA(char);
|
code=va_arg(msg->data, int);
|
||||||
if (code==0) return;
|
if (code==0) return;
|
||||||
code=toupper(code);
|
code=toupper(code);
|
||||||
if (code==13) key=default_action;
|
if (code==13) key=default_action;
|
||||||
|
@ -383,7 +390,7 @@ void type_text_v2(va_list args)
|
||||||
short *back_pic;
|
short *back_pic;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
task_sleep(NULL);
|
task_sleep();
|
||||||
schovej_mysku();
|
schovej_mysku();
|
||||||
set_font(font,color);
|
set_font(font,color);
|
||||||
xs=max_size+text_width("_");
|
xs=max_size+text_width("_");
|
||||||
|
@ -410,7 +417,10 @@ void type_text_v2(va_list args)
|
||||||
position(px+x,y+3);outtext("_");
|
position(px+x,y+3);outtext("_");
|
||||||
ukaz_mysku();
|
ukaz_mysku();
|
||||||
showview(x,y,xs,ys);
|
showview(x,y,xs,ys);
|
||||||
znak=*(word *)task_wait_event(E_KEYBOARD); //proces bude cekat na klavesu
|
|
||||||
|
EVENT_MSG *ev= task_wait_event(E_KEYBOARD); //proces bude cekat na klavesu
|
||||||
|
if (ev == NULL) return;
|
||||||
|
znak=va_arg(ev->data, int);
|
||||||
schovej_mysku();
|
schovej_mysku();
|
||||||
if (task_quitmsg()==1) znak=27;
|
if (task_quitmsg()==1) znak=27;
|
||||||
switch(znak & 0xff)
|
switch(znak & 0xff)
|
||||||
|
@ -968,7 +978,7 @@ void skeldal_checkbox(OBJREC *o)
|
||||||
static void setup_button_init(OBJREC *o,va_list params)
|
static void setup_button_init(OBJREC *o,va_list params)
|
||||||
{
|
{
|
||||||
void **d;
|
void **d;
|
||||||
char title = va_arg(params, char *);
|
char *title = va_arg(params, char *);
|
||||||
d=NewArr(void *,2);
|
d=NewArr(void *,2);
|
||||||
d[0]=NewArr(char,strlen(title)+1);
|
d[0]=NewArr(char,strlen(title)+1);
|
||||||
strcpy(d[0],title);
|
strcpy(d[0],title);
|
||||||
|
|
|
@ -222,7 +222,7 @@ static void play_anim(va_list args) //tasked animation
|
||||||
void play_big_mgif_animation(int block)
|
void play_big_mgif_animation(int block)
|
||||||
{
|
{
|
||||||
add_task(2048,play_anim,block);
|
add_task(2048,play_anim,block);
|
||||||
task_sleep(NULL);
|
task_sleep();
|
||||||
}
|
}
|
||||||
|
|
||||||
int get_spell_mana(int num)
|
int get_spell_mana(int num)
|
||||||
|
|
|
@ -611,8 +611,7 @@ void macro_change_music(int textindex)
|
||||||
char *nextTrack;
|
char *nextTrack;
|
||||||
|
|
||||||
create_playlist(trackdef);
|
create_playlist(trackdef);
|
||||||
play_next_music(&nextTrack);
|
change_music(get_next_music_from_playlist());
|
||||||
change_music(nextTrack);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void macro_register_global_event(TMULTI_ACTION *q)
|
void macro_register_global_event(TMULTI_ACTION *q)
|
||||||
|
|
22
game/menu.c
22
game/menu.c
|
@ -280,7 +280,7 @@ static void preload_anim(va_list args)
|
||||||
for(i=0;i<30;i+=2)
|
for(i=0;i<30;i+=2)
|
||||||
{
|
{
|
||||||
apreload(H_ANIM+i);
|
apreload(H_ANIM+i);
|
||||||
task_sleep(NULL);
|
task_sleep();
|
||||||
}
|
}
|
||||||
for(i=1;i<30;i+=2)
|
for(i=1;i<30;i+=2)
|
||||||
{
|
{
|
||||||
|
@ -293,12 +293,12 @@ static void preload_anim(va_list args)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
apreload(H_ANIM+i);
|
apreload(H_ANIM+i);
|
||||||
task_sleep(NULL);
|
task_sleep();
|
||||||
}
|
}
|
||||||
for(i=0;i<5;i++)
|
for(i=0;i<5;i++)
|
||||||
{
|
{
|
||||||
apreload(H_MENU_ANIM+i);
|
apreload(H_MENU_ANIM+i);
|
||||||
task_sleep(NULL);
|
task_sleep();
|
||||||
}
|
}
|
||||||
apreload(H_MENU_MASK);
|
apreload(H_MENU_MASK);
|
||||||
task_wait_event(E_TIMER);
|
task_wait_event(E_TIMER);
|
||||||
|
@ -334,11 +334,10 @@ int enter_menu(char open)
|
||||||
init_menu_entries();
|
init_menu_entries();
|
||||||
add_task(2048,preload_anim);
|
add_task(2048,preload_anim);
|
||||||
load_ok=0;
|
load_ok=0;
|
||||||
while(!load_ok) task_sleep(NULL);
|
while(!load_ok) task_sleep();
|
||||||
if (!open)
|
if (!open)
|
||||||
{
|
{
|
||||||
play_next_music(&d);
|
change_music(get_next_music_from_playlist());
|
||||||
change_music(d);
|
|
||||||
}
|
}
|
||||||
update_mysky();
|
update_mysky();
|
||||||
schovej_mysku();
|
schovej_mysku();
|
||||||
|
@ -352,8 +351,8 @@ int enter_menu(char open)
|
||||||
send_message(E_ADD,E_KEYBOARD,klavesnice);
|
send_message(E_ADD,E_KEYBOARD,klavesnice);
|
||||||
ms_last_event.event_type=0x1;
|
ms_last_event.event_type=0x1;
|
||||||
send_message(E_MOUSE,&ms_last_event);
|
send_message(E_MOUSE,&ms_last_event);
|
||||||
d=task_wait_event(E_MENU_SELECT);
|
EVENT_MSG *ev = task_wait_event(E_MENU_SELECT);
|
||||||
c=*d;
|
c=va_arg(ev->data, int);
|
||||||
disable_click_map();
|
disable_click_map();
|
||||||
send_message(E_DONE,E_KEYBOARD,klavesnice);
|
send_message(E_DONE,E_KEYBOARD,klavesnice);
|
||||||
cur_dir[c]=UNSELECT;
|
cur_dir[c]=UNSELECT;
|
||||||
|
@ -599,10 +598,9 @@ void konec_hry()
|
||||||
bar(0,0,639,479);
|
bar(0,0,639,479);
|
||||||
effect_show(NULL);
|
effect_show(NULL);
|
||||||
create_playlist(texty[205]);
|
create_playlist(texty[205]);
|
||||||
play_next_music(&d);
|
change_music(get_next_music_from_playlist());
|
||||||
change_music(d);
|
|
||||||
timer=get_timer_value();
|
timer=get_timer_value();
|
||||||
while (get_timer_value()-timer<150) task_sleep(NULL);
|
while (get_timer_value()-timer<150) task_sleep();
|
||||||
task_id=add_task(8196,titles,1,"ENDTEXT.TXT");
|
task_id=add_task(8196,titles,1,"ENDTEXT.TXT");
|
||||||
task_wait_event(E_KEYBOARD);
|
task_wait_event(E_KEYBOARD);
|
||||||
if (is_running(task_id)) term_task(task_id);
|
if (is_running(task_id)) term_task(task_id);
|
||||||
|
@ -617,6 +615,6 @@ void konec_hry()
|
||||||
ukaz_mysku();
|
ukaz_mysku();
|
||||||
effect_show(NULL);
|
effect_show(NULL);
|
||||||
timer=get_timer_value();
|
timer=get_timer_value();
|
||||||
while (get_timer_value()-timer<150) task_sleep(NULL);
|
while (get_timer_value()-timer<150) task_sleep();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1511,7 +1511,7 @@ void postavy_teleport_effect(int sector,int dir,int postava,char effect)
|
||||||
while (running_anm) do_events();
|
while (running_anm) do_events();
|
||||||
play_sample_at_channel(H_SND_TELEPIN,2,100);
|
play_sample_at_channel(H_SND_TELEPIN,2,100);
|
||||||
play_big_mgif_animation(H_TELEPORT);
|
play_big_mgif_animation(H_TELEPORT);
|
||||||
while (!running_anm) task_sleep(NULL);
|
while (!running_anm) task_sleep();
|
||||||
kolo=global_anim_counter;
|
kolo=global_anim_counter;
|
||||||
if (norefresh)
|
if (norefresh)
|
||||||
{
|
{
|
||||||
|
|
|
@ -78,12 +78,12 @@ static void change_turn()
|
||||||
|
|
||||||
static void unwire_setup();
|
static void unwire_setup();
|
||||||
|
|
||||||
static EVENT_PROC(setup_keyboard)
|
static void setup_keyboard(EVENT_MSG *msg,void **)
|
||||||
{
|
{
|
||||||
user_ptr;
|
if (msg->msg == E_KEYBOARD)
|
||||||
WHEN_MSG(E_KEYBOARD)
|
|
||||||
{
|
{
|
||||||
if (GET_DATA(char)==27)
|
char c= va_arg(msg->data, int);
|
||||||
|
if (c==27)
|
||||||
{
|
{
|
||||||
unwire_proc();
|
unwire_proc();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1043,7 +1043,7 @@ SEND_LOG("(INIT) Mouse initialized.",0,0);
|
||||||
SEND_LOG("(INIT) Loading mouse cursor.",0,0);
|
SEND_LOG("(INIT) Loading mouse cursor.",0,0);
|
||||||
mouse_set_default(H_MS_DEFAULT);
|
mouse_set_default(H_MS_DEFAULT);
|
||||||
ukaz_mysku();
|
ukaz_mysku();
|
||||||
konec_skladby=play_next_music;
|
set_end_of_song_callback(end_of_song_callback, NULL);
|
||||||
SEND_LOG("(INIT) Loading spells.",0,0);
|
SEND_LOG("(INIT) Loading spells.",0,0);
|
||||||
kouzla_init();
|
kouzla_init();
|
||||||
SEND_LOG("(INIT) Loading items.",0,0);
|
SEND_LOG("(INIT) Loading items.",0,0);
|
||||||
|
@ -1143,7 +1143,10 @@ void enter_game()
|
||||||
set_game_click_map();
|
set_game_click_map();
|
||||||
SEND_LOG("(GAME) --------- Waiting for E_CLOSE_MAP ------------\n",0,0);
|
SEND_LOG("(GAME) --------- Waiting for E_CLOSE_MAP ------------\n",0,0);
|
||||||
send_message(E_ADD,E_RELOADMAP,reload_map_handler);
|
send_message(E_ADD,E_RELOADMAP,reload_map_handler);
|
||||||
end=*(int *)task_wait_event(E_CLOSE_MAP);
|
{
|
||||||
|
EVENT_MSG *msg = task_wait_event(E_CLOSE_MAP);
|
||||||
|
end = va_arg(msg->data, int);
|
||||||
|
}
|
||||||
send_message(E_DONE,E_RELOADMAP,reload_map_handler);
|
send_message(E_DONE,E_RELOADMAP,reload_map_handler);
|
||||||
SEND_LOG("(GAME) --------- E_CLOSE_MAP triggered, leaving map------------\n",0,0);
|
SEND_LOG("(GAME) --------- E_CLOSE_MAP triggered, leaving map------------\n",0,0);
|
||||||
unwire_main_functs();
|
unwire_main_functs();
|
||||||
|
@ -1522,10 +1525,9 @@ static void undef_menu()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static EVENT_PROC(load_error_report)
|
static void load_error_report(EVENT_MSG *msg,void **)
|
||||||
{
|
{
|
||||||
user_ptr;
|
if (msg->msg == E_IDLE)
|
||||||
WHEN_MSG(E_IDLE)
|
|
||||||
{
|
{
|
||||||
message(1,0,0,"",texty[79],texty[80]);
|
message(1,0,0,"",texty[79],texty[80]);
|
||||||
exit_wait=0;
|
exit_wait=0;
|
||||||
|
@ -1551,7 +1553,10 @@ static void load_saved_game(void)
|
||||||
wire_save_load(4);
|
wire_save_load(4);
|
||||||
ukaz_mysku();
|
ukaz_mysku();
|
||||||
update_mysky();
|
update_mysky();
|
||||||
game=*((char *)task_wait_event(E_CLOSE_MAP));
|
{
|
||||||
|
EVENT_MSG *msg = task_wait_event(E_CLOSE_MAP);
|
||||||
|
game = va_arg(msg->data, int);
|
||||||
|
}
|
||||||
unwire_proc();
|
unwire_proc();
|
||||||
disable_click_map();
|
disable_click_map();
|
||||||
task_wait_event(E_TIMER);
|
task_wait_event(E_TIMER);
|
||||||
|
|
|
@ -421,13 +421,15 @@ void create_playlist(char *playlist)
|
||||||
playing_track=-1;
|
playing_track=-1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void play_next_music(char **c)
|
const char * end_of_song_callback(void *ctx) {
|
||||||
|
return get_next_music_from_playlist();
|
||||||
|
}
|
||||||
|
const char *get_next_music_from_playlist()
|
||||||
{
|
{
|
||||||
int i,step;
|
int i,step;
|
||||||
static char d[MAX_FILESYSTEM_PATH];
|
static char d[MAX_FILESYSTEM_PATH];
|
||||||
|
|
||||||
*c=NULL;
|
if (cur_playlist==NULL) return NULL;
|
||||||
if (cur_playlist==NULL) return;
|
|
||||||
if (!remain_play)
|
if (!remain_play)
|
||||||
for(i=0;cur_playlist[i]!=NULL;remain_play++,i++) cur_playlist[i][0]=32;
|
for(i=0;cur_playlist[i]!=NULL;remain_play++,i++) cur_playlist[i][0]=32;
|
||||||
if (play_list_mode==PL_RANDOM)
|
if (play_list_mode==PL_RANDOM)
|
||||||
|
@ -444,11 +446,15 @@ void play_next_music(char **c)
|
||||||
while (step);
|
while (step);
|
||||||
playing_track=i;
|
playing_track=i;
|
||||||
snprintf(d,sizeof(d),"%s%s",pathtable[SR_MUSIC],cur_playlist[i]+1);
|
snprintf(d,sizeof(d),"%s%s",pathtable[SR_MUSIC],cur_playlist[i]+1);
|
||||||
if (access(d,0) == -1)
|
if (access(d,0) == -1) {
|
||||||
snprintf(d,sizeof(d),"%s%s",pathtable[SR_ORGMUSIC],cur_playlist[i]+1);
|
snprintf(d,sizeof(d),"%s%s",pathtable[SR_ORGMUSIC],cur_playlist[i]+1);
|
||||||
|
if (access(d,0) == -1) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
cur_playlist[i][0]=33;
|
cur_playlist[i][0]=33;
|
||||||
remain_play--;
|
remain_play--;
|
||||||
*c=d;
|
return d;
|
||||||
}
|
}
|
||||||
|
|
||||||
void purge_playlist()
|
void purge_playlist()
|
||||||
|
|
|
@ -645,11 +645,10 @@ T_CLK_MAP clk_end_game[]=
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
EVENT_PROC(end_game_end_phase)
|
void end_game_end_phase(EVENT_MSG *msg,void **)
|
||||||
{
|
{
|
||||||
static int wait=0;
|
static int wait=0;
|
||||||
WHEN_MSG(E_TIMER)
|
if (msg->msg == E_TIMER) {
|
||||||
{
|
|
||||||
if (pass_zavora) return;
|
if (pass_zavora) return;
|
||||||
if (wait==2)
|
if (wait==2)
|
||||||
{
|
{
|
||||||
|
@ -659,10 +658,10 @@ EVENT_PROC(end_game_end_phase)
|
||||||
}
|
}
|
||||||
else wait++;
|
else wait++;
|
||||||
}
|
}
|
||||||
WHEN_MSG(E_INIT)
|
if (msg->msg == E_INIT) {
|
||||||
wait=0;
|
wait=0;
|
||||||
user_ptr;
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void wire_end_game()
|
void wire_end_game()
|
||||||
{
|
{
|
||||||
|
|
96
game/temp_storage.cpp
Normal file
96
game/temp_storage.cpp
Normal file
|
@ -0,0 +1,96 @@
|
||||||
|
#include <map>
|
||||||
|
#include <string>
|
||||||
|
#include <string_view>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
extern "C" {
|
||||||
|
#include "temp_storage.h"
|
||||||
|
}
|
||||||
|
|
||||||
|
typedef struct _temp_storage_file_wr {
|
||||||
|
std::vector<uint8_t> *_data;
|
||||||
|
} TMPFILE_WR;
|
||||||
|
|
||||||
|
typedef struct _temp_storage_file_rd {
|
||||||
|
std::basic_string_view<uint8_t> _data;
|
||||||
|
} TMPFILE_RD;
|
||||||
|
|
||||||
|
using FileSystem = std::map<std::string, std::vector<uint8_t>, std::less<> >;
|
||||||
|
static FileSystem temp_fsystem;
|
||||||
|
|
||||||
|
|
||||||
|
void temp_storage_store(const char *name, const void *data, int32_t size) {
|
||||||
|
auto b = reinterpret_cast<const uint8_t *>(data);
|
||||||
|
auto e = b+size;
|
||||||
|
temp_fsystem[std::string(name)] = {b,e};
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t temp_storage_find(const char *name) {
|
||||||
|
auto iter = temp_fsystem.find(std::string_view(name));
|
||||||
|
if (iter == temp_fsystem.end()) return -1;
|
||||||
|
return iter->second.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t temp_storage_retrieve(const char *name, void *data, int32_t size) {
|
||||||
|
auto iter = temp_fsystem.find(std::string_view(name));
|
||||||
|
if (iter == temp_fsystem.end()) return -1;
|
||||||
|
size = std::min<int32_t>(size, iter->second.size());
|
||||||
|
std::copy(iter->second.begin(), iter->second.end(), reinterpret_cast<uint8_t *>(data));
|
||||||
|
return iter->second.size();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void temp_storage_list(void (*callback)(const char*, void*), void *context) {
|
||||||
|
for (const auto &[k,v]: temp_fsystem) {
|
||||||
|
callback(k.c_str(), context);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void temp_storage_clear() {
|
||||||
|
temp_fsystem.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
TMPFILE_RD* temp_storage_open(const char *name) {
|
||||||
|
auto iter = temp_fsystem.find(std::string_view(name));
|
||||||
|
if (iter == temp_fsystem.end()) return NULL;
|
||||||
|
return new TMPFILE_RD{std::basic_string_view<uint8_t>(iter->second.data(), iter->second.size())};
|
||||||
|
}
|
||||||
|
|
||||||
|
TMPFILE_WR* temp_storage_create(const char *name) {
|
||||||
|
auto &v = temp_fsystem[std::string(name)] = {};
|
||||||
|
return new TMPFILE_WR{&v};
|
||||||
|
}
|
||||||
|
|
||||||
|
TMPFILE_WR* temp_storage_append(const char *name) {
|
||||||
|
auto &v = temp_fsystem[std::string(name)];
|
||||||
|
return new TMPFILE_WR{&v};
|
||||||
|
}
|
||||||
|
|
||||||
|
void temp_storage_close_rd(TMPFILE_RD *f) {
|
||||||
|
delete f;
|
||||||
|
}
|
||||||
|
|
||||||
|
void temp_storage_close_wr(TMPFILE_WR *f) {
|
||||||
|
delete f;
|
||||||
|
}
|
||||||
|
|
||||||
|
void temp_storage_write(const void *data, uint32_t size, TMPFILE_WR *f) {
|
||||||
|
auto b = reinterpret_cast<const uint8_t *>(data);
|
||||||
|
auto e = b+size;
|
||||||
|
std::copy(b,e, std::back_inserter(*f->_data));
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32_t temp_storage_read(void *data, uint32_t size, TMPFILE_RD *f) {
|
||||||
|
auto &d = f->_data;
|
||||||
|
auto p = d.substr(0,size);
|
||||||
|
d = d.substr(p.size());
|
||||||
|
auto b = reinterpret_cast<uint8_t *>(data);
|
||||||
|
std::copy(d.begin(), d.end(), b);
|
||||||
|
return p.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
void temp_storage_skip(TMPFILE_RD *f, int bytes) {
|
||||||
|
auto &d = f->_data;
|
||||||
|
auto p = d.substr(0,bytes);
|
||||||
|
d = d.substr(p.size());
|
||||||
|
}
|
|
@ -1,4 +1,4 @@
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
///store to temp storage
|
///store to temp storage
|
||||||
void temp_storage_store(const char *name, const void *data, int32_t size);
|
void temp_storage_store(const char *name, const void *data, int32_t size);
|
||||||
|
|
|
@ -16,16 +16,41 @@ extern MS_EVENT win_mouseEvent;
|
||||||
TMS_BASIC_INFO ms_basic_info={0};
|
TMS_BASIC_INFO ms_basic_info={0};
|
||||||
static char ms_keys;
|
static char ms_keys;
|
||||||
|
|
||||||
|
/*
|
||||||
void get_ms_event(MS_EVENT *event)
|
void get_ms_event(MS_EVENT *event)
|
||||||
{
|
{
|
||||||
CheckMessageQueue();
|
CheckMessageQueue();
|
||||||
*event=win_mouseEvent;
|
*event=win_mouseEvent;
|
||||||
win_mouseEvent.event=0;
|
win_mouseEvent.event=0;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
char cz_table_1[]=" 1!3457<35>908+,-./<2F>+<2B><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>\"<EFBFBD>?=:_2ABCDEFGHIJKLMNOPQRSTUVWXYZ<59>\\)6=;abcdefghijklmnopqrstuvwxyz/|(; ";
|
char cz_table_1[] = { 0x20, 0x31, 0x21, 0x33, 0x34, 0x35, 0x37, 0xad, 0x39,
|
||||||
char cz_table_2[]=" !\"#$%&'()*+,-./0123456789:;<=>?@<40>BCD<43>FGH<47>JK<4A>MN<4D>PQ<50>ST<53>VWX<57>Z[\\]^_`<60>bcd<63>fgh<67>jk<6A>mn<6D>pq<70>st<73>vwx<77>z{|}~ ";
|
0x30, 0x38, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, 0x82, 0x2b, 0x88, 0xa8, 0x87,
|
||||||
char cz_table_3[]=" !\"#$%&'()*+,-./0123456789:;<=>?@AB<41><42><EFBFBD>FGHIJK<4A>M<EFBFBD><4D>PQ<50><51><EFBFBD><EFBFBD>VWXY<58>[\\]^_`ab<61><62><EFBFBD>fghijk<6A>m<EFBFBD><6D>pq<70><71><EFBFBD><EFBFBD>vwxy<78>{|}~ ";
|
0xa9, 0x91, 0x98, 0xa0, 0xa1, 0x5c, 0x22, 0x96, 0x3f, 0x3d, 0x3a, 0x5f,
|
||||||
|
0x32, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4a, 0x4b,
|
||||||
|
0x4c, 0x4d, 0x4e, 0x4f, 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57,
|
||||||
|
0x58, 0x59, 0x5a, 0xa3, 0x5c, 0x5c, 0x29, 0x36, 0x3d, 0x3b, 0x61, 0x62,
|
||||||
|
0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e,
|
||||||
|
0x6f, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7a,
|
||||||
|
0x2f, 0x7c, 0x28, 0x3b, 0x20 };
|
||||||
|
char cz_table_2[] = { 0x20, 0x21, 0x5c, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27,
|
||||||
|
0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, 0x30, 0x31, 0x32, 0x33,
|
||||||
|
0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f,
|
||||||
|
0x40, 0x8f, 0x42, 0x43, 0x44, 0x90, 0x46, 0x47, 0x48, 0x8b, 0x4a, 0x4b,
|
||||||
|
0x8a, 0x4d, 0x4e, 0x95, 0x50, 0x51, 0xab, 0x53, 0x54, 0x97, 0x56, 0x57,
|
||||||
|
0x58, 0x9d, 0x5a, 0x5b, 0x5c, 0x5c, 0x5d, 0x5e, 0x5f, 0x60, 0xa0, 0x62,
|
||||||
|
0x63, 0x64, 0x82, 0x66, 0x67, 0x68, 0xa1, 0x6a, 0x6b, 0x8d, 0x6d, 0x6e,
|
||||||
|
0xa2, 0x70, 0x71, 0xaa, 0x73, 0x74, 0xa3, 0x76, 0x77, 0x78, 0x98, 0x7a,
|
||||||
|
0x7b, 0x7c, 0x7d, 0x7e, 0x20 };
|
||||||
|
char cz_table_3[] = { 0x20, 0x21, 0x5c, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27,
|
||||||
|
0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, 0x30, 0x31, 0x32, 0x33,
|
||||||
|
0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f,
|
||||||
|
0x40, 0x41, 0x42, 0x80, 0x85, 0x89, 0x46, 0x47, 0x48, 0x49, 0x4a, 0x4b,
|
||||||
|
0x9c, 0x4d, 0xa5, 0xa7, 0x50, 0x51, 0x9e, 0x9b, 0x86, 0xa6, 0x56, 0x57,
|
||||||
|
0x58, 0x59, 0x92, 0x5b, 0x5c, 0x5c, 0x5d, 0x5e, 0x5f, 0x60, 0x61, 0x62,
|
||||||
|
0x87, 0x83, 0x88, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x8c, 0x6d, 0xa4,
|
||||||
|
0x93, 0x70, 0x71, 0xa9, 0xa8, 0x9f, 0x96, 0x76, 0x77, 0x78, 0x79, 0x91,
|
||||||
|
0x7b, 0x7c, 0x7d, 0x7e, 0x20 };
|
||||||
char *cz_key_tabs[]={cz_table_1,cz_table_2,cz_table_3};
|
char *cz_key_tabs[]={cz_table_1,cz_table_2,cz_table_3};
|
||||||
|
|
||||||
void keyboard(EVENT_MSG *msg,void *user_data)
|
void keyboard(EVENT_MSG *msg,void *user_data)
|
||||||
|
|
15
libs/event.c
15
libs/event.c
|
@ -430,11 +430,10 @@ void timer(EVENT_MSG *msg)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void tasker(EVENT_MSG *msg,void **data)
|
void tasker(EVENT_MSG *msg,void **)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
data;
|
|
||||||
switch (msg->msg)
|
switch (msg->msg)
|
||||||
{
|
{
|
||||||
case E_INIT:
|
case E_INIT:
|
||||||
|
@ -449,22 +448,22 @@ void tasker(EVENT_MSG *msg,void **data)
|
||||||
case E_IDLE:
|
case E_IDLE:
|
||||||
default:
|
default:
|
||||||
if (q_any_task()>=1)
|
if (q_any_task()>=1)
|
||||||
task_sleep(NULL);
|
task_sleep();
|
||||||
break;
|
break;
|
||||||
case E_DONE:
|
case E_DONE:
|
||||||
{
|
{
|
||||||
int i;
|
/* int i;
|
||||||
memset(task_info,1,taskcount);
|
memset(task_info,1,taskcount);
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
for (i=1;i<taskcount;i++)
|
for (i=1;i<taskcount;i++)
|
||||||
if (tasklist_sp[i]!=NULL) break;
|
if (tasklist_sp[i]!=NULL) break;
|
||||||
if (i!=taskcount) task_sleep(NULL);
|
if (i!=taskcount) task_sleep();
|
||||||
}
|
}
|
||||||
while (i<taskcount);
|
while (i<taskcount);
|
||||||
free(tasklist_sp);
|
free(tasklist_sp);
|
||||||
free(tasklist_low);
|
free(tasklist_low);
|
||||||
free(task_info);
|
free(task_info);*/
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -505,7 +504,7 @@ static char do_events_called=0;
|
||||||
void do_events()
|
void do_events()
|
||||||
{
|
{
|
||||||
do_events_called=1;
|
do_events_called=1;
|
||||||
if (!q_is_mastertask()) task_sleep(NULL);
|
if (!q_is_mastertask()) task_sleep();
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
send_message(E_WATCH);
|
send_message(E_WATCH);
|
||||||
|
@ -662,6 +661,6 @@ void shut_down_task(int id_num)
|
||||||
{
|
{
|
||||||
if (!curtask) return NULL;
|
if (!curtask) return NULL;
|
||||||
suspend_task(curtask,event_number);
|
suspend_task(curtask,event_number);
|
||||||
return task_sleep(NULL);
|
return task_sleep();
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
14
libs/event.h
14
libs/event.h
|
@ -124,7 +124,7 @@ static __inline void shift_message(EVENT_MSG *msg) {
|
||||||
void do_events();
|
void do_events();
|
||||||
void escape();
|
void escape();
|
||||||
|
|
||||||
#include <FCS_Tasker.h>
|
#include <legacy_coroutines.h>
|
||||||
/*
|
/*
|
||||||
void *task_sleep(void *param);
|
void *task_sleep(void *param);
|
||||||
//#pragma aux task_sleep parm [eax] value [eax]
|
//#pragma aux task_sleep parm [eax] value [eax]
|
||||||
|
@ -142,18 +142,6 @@ char is_running(int id_num);
|
||||||
*/
|
*/
|
||||||
void timer(EVENT_MSG *msg);
|
void timer(EVENT_MSG *msg);
|
||||||
|
|
||||||
#define EVENT_PROC(name) void name(EVENT_MSG *msg,void **user_ptr)
|
|
||||||
#define WHEN_MSG(msg_num) if (msg->msg==msg_num)
|
|
||||||
#define UNTIL_MSG(msg_num) if (msg->msg!=msg_num)
|
|
||||||
#define GET_DATA(data_type) (va_arg(msg->data, data_type))
|
|
||||||
#define GET_DATA_PTR(data_type) (va_arg(msg->data, data_type *))
|
|
||||||
#define GET_USER(data_type) (*(data_type *)user_ptr)
|
|
||||||
#define SAVE_USER_PTR(p) (*user_ptr=p)
|
|
||||||
#define GET_USER_PTR() user_ptr
|
|
||||||
#define EVENT_RETURN(value) msg->msg=value
|
|
||||||
#define GET_MSG_VAR() msg
|
|
||||||
#define GET_MSG() msg->msg
|
|
||||||
#define TASK_GET_TERMINATE() ((task_info[cur_task] & TASK_TERMINATING)!=0)
|
|
||||||
|
|
||||||
#define EVENT_HALT -1
|
#define EVENT_HALT -1
|
||||||
#define EVENT_DONE -2
|
#define EVENT_DONE -2
|
||||||
|
|
30
libs/event_macros.h
Normal file
30
libs/event_macros.h
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
/*
|
||||||
|
* event_macros.h
|
||||||
|
*
|
||||||
|
* Created on: 26. 1. 2025
|
||||||
|
* Author: ondra
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef LIBS_EVENT_MACROS_H_
|
||||||
|
#define LIBS_EVENT_MACROS_H_
|
||||||
|
|
||||||
|
#include "event.h"
|
||||||
|
|
||||||
|
#define EVENT_PROC(name) void name(EVENT_MSG *msg,void **user_ptr)
|
||||||
|
#define WHEN_MSG(msg_num) if (msg->msg==msg_num)
|
||||||
|
#define UNTIL_MSG(msg_num) if (msg->msg!=msg_num)
|
||||||
|
#define GET_DATA(data_type) (va_arg(msg->data, data_type))
|
||||||
|
#define GET_DATA_PTR(data_type) (va_arg(msg->data, data_type *))
|
||||||
|
#define GET_USER(data_type) (*(data_type *)user_ptr)
|
||||||
|
#define SAVE_USER_PTR(p) (*user_ptr=p)
|
||||||
|
#define GET_USER_PTR() user_ptr
|
||||||
|
#define EVENT_RETURN(value) msg->msg=value
|
||||||
|
#define GET_MSG_VAR() msg
|
||||||
|
#define GET_MSG() msg->msg
|
||||||
|
#define TASK_GET_TERMINATE() ((task_info[cur_task] & TASK_TERMINATING)!=0)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* LIBS_EVENT_MACROS_H_ */
|
|
@ -19,7 +19,7 @@ extern "C" {
|
||||||
#define DEV_DIRECTSOUND 9 //only valid device for this module
|
#define DEV_DIRECTSOUND 9 //only valid device for this module
|
||||||
|
|
||||||
extern int bvolume;
|
extern int bvolume;
|
||||||
extern void (*konec_skladby)(char **jmeno);
|
|
||||||
|
|
||||||
int sound_detect(int *dev,int *port,int *dma, int *irq);
|
int sound_detect(int *dev,int *port,int *dma, int *irq);
|
||||||
void set_mixing_device(int mix_dev,int mix_freq,...);
|
void set_mixing_device(int mix_dev,int mix_freq,...);
|
||||||
|
@ -28,6 +28,7 @@ void stop_mixing();
|
||||||
void play_sample(int channel,void *sample,int32_t size,int32_t lstart,int32_t sfreq,int type);
|
void play_sample(int channel,void *sample,int32_t size,int32_t lstart,int32_t sfreq,int type);
|
||||||
void set_channel_volume(int channel,int left,int right);
|
void set_channel_volume(int channel,int left,int right);
|
||||||
void init_winamp_plugins(const char *path);
|
void init_winamp_plugins(const char *path);
|
||||||
|
void set_end_of_song_callback(const char * (*cb)(void *), void *ctx);
|
||||||
|
|
||||||
void fade_music();
|
void fade_music();
|
||||||
int mix_back_sound(int synchro);
|
int mix_back_sound(int synchro);
|
||||||
|
|
6
platform/CMakeLists.txt
Normal file
6
platform/CMakeLists.txt
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
SET(files error.cpp legacy_coroutines.cpp)
|
||||||
|
|
||||||
|
add_library(skeldal_platform_libs ${files})
|
||||||
|
set_property(TARGET skeldal_platform_libs PROPERTY CXX_STANDARD 20)
|
||||||
|
|
||||||
|
add_subdirectory(sdl)
|
|
@ -1,34 +0,0 @@
|
||||||
#ifndef _FCS_TASKER_H_
|
|
||||||
#define _FCS_TASKER_H_
|
|
||||||
|
|
||||||
#include <stdarg.h>
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
typedef void (*TaskerFunctionName)(va_list);
|
|
||||||
|
|
||||||
void tasker(EVENT_MSG *msg,void **data);
|
|
||||||
int create_task();
|
|
||||||
int add_task(int stack,TaskerFunctionName fcname,...);
|
|
||||||
void term_task(int id_num);
|
|
||||||
char is_running(int id_num);
|
|
||||||
void suspend_task(int id_num,int msg);
|
|
||||||
void shut_down_task(int id_num);
|
|
||||||
void unsuspend_task(EVENT_MSG *msg);
|
|
||||||
void *task_sleep(void *data);
|
|
||||||
void *task_wait_event(int32_t event_number);
|
|
||||||
int q_any_task();
|
|
||||||
char task_quitmsg();
|
|
||||||
char task_quitmsg_by_id(int id);
|
|
||||||
char q_is_mastertask();
|
|
||||||
int q_current_task();
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
|
|
@ -0,0 +1 @@
|
||||||
|
|
9
platform/error.cpp
Normal file
9
platform/error.cpp
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
#include <iostream>
|
||||||
|
extern "C" {
|
||||||
|
#include "error.h"
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void display_error(const char *text) {
|
||||||
|
std::cerr << "ERROR:" << text << std::endl;
|
||||||
|
}
|
3
platform/error.h
Normal file
3
platform/error.h
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
void display_error(const char *text);
|
141
platform/legacy_coroutines.cpp
Normal file
141
platform/legacy_coroutines.cpp
Normal file
|
@ -0,0 +1,141 @@
|
||||||
|
#include "legacy_coroutines.h"
|
||||||
|
|
||||||
|
|
||||||
|
#include <thread>
|
||||||
|
#include <atomic>
|
||||||
|
#include <memory>
|
||||||
|
#include <unordered_map>
|
||||||
|
|
||||||
|
struct TaskInfo {
|
||||||
|
int id;
|
||||||
|
std::thread thr;
|
||||||
|
std::atomic<bool> resume_flag = {false};
|
||||||
|
std::chrono::system_clock::time_point _wake_up_after = {};
|
||||||
|
int wake_up_msg = -1;
|
||||||
|
bool request_exit = false;
|
||||||
|
|
||||||
|
TaskInfo(int id):id(id) {}
|
||||||
|
};
|
||||||
|
|
||||||
|
using TaskList = std::unordered_map<int, std::unique_ptr<TaskInfo> >;
|
||||||
|
static int next_task_id = 1;
|
||||||
|
static TaskList task_list;
|
||||||
|
|
||||||
|
static int get_new_task_id() {
|
||||||
|
int id = next_task_id;
|
||||||
|
next_task_id = (next_task_id + 1) & 0xFFFF;
|
||||||
|
if (task_list.find(id) != task_list.end()) id = get_new_task_id();
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::atomic<bool> resume_master_flag = {false};
|
||||||
|
static TaskInfo *current_task_inst = NULL;
|
||||||
|
static EVENT_MSG *cur_message = NULL;
|
||||||
|
|
||||||
|
static void switch_to_task(TaskInfo *task) {
|
||||||
|
if (task == current_task_inst) return;
|
||||||
|
if (task == NULL) {
|
||||||
|
TaskInfo *me = current_task_inst;
|
||||||
|
current_task_inst = NULL;
|
||||||
|
me->resume_flag = false;
|
||||||
|
resume_master_flag = true;
|
||||||
|
resume_master_flag.notify_all();
|
||||||
|
me->resume_flag.wait(false);
|
||||||
|
} else if (current_task_inst == NULL) {
|
||||||
|
current_task_inst = task;
|
||||||
|
resume_master_flag = false;
|
||||||
|
task->resume_flag = true;
|
||||||
|
task->resume_flag.notify_all();
|
||||||
|
resume_master_flag.wait(false);
|
||||||
|
} else {
|
||||||
|
TaskInfo *me = current_task_inst;
|
||||||
|
me->resume_flag = false;
|
||||||
|
task->resume_flag = true;
|
||||||
|
task->resume_flag.notify_all();
|
||||||
|
me->resume_flag.wait(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void clean_up_current_task() {
|
||||||
|
TaskInfo *me = current_task_inst;
|
||||||
|
if (!me) return;
|
||||||
|
int id = me->id;
|
||||||
|
me->thr.detach();
|
||||||
|
task_list.erase(id);
|
||||||
|
current_task_inst = NULL;
|
||||||
|
resume_master_flag = true;
|
||||||
|
resume_master_flag.notify_all();
|
||||||
|
}
|
||||||
|
|
||||||
|
int add_task(int stack,TaskerFunctionName fcname,...) {
|
||||||
|
int id = get_new_task_id();
|
||||||
|
auto st = task_list.emplace(id, std::make_unique<TaskInfo>(id));
|
||||||
|
TaskInfo *new_task = st.first->second.get();
|
||||||
|
va_list args;
|
||||||
|
va_start(args, fcname);
|
||||||
|
new_task->thr = std::thread([&]{
|
||||||
|
new_task->resume_flag.wait(false);
|
||||||
|
fcname(args);
|
||||||
|
clean_up_current_task();
|
||||||
|
});
|
||||||
|
switch_to_task(new_task);
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
void term_task(int id_num) {
|
||||||
|
auto iter = task_list.find(id_num);
|
||||||
|
if (iter != task_list.end()) {
|
||||||
|
iter->second->request_exit = true;
|
||||||
|
switch_to_task(iter->second.get());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
char is_running(int id_num) {
|
||||||
|
return id_num < 0 || task_list.find(id_num) != task_list.end();
|
||||||
|
}
|
||||||
|
void unsuspend_task(EVENT_MSG *msg) {
|
||||||
|
for (auto &[id, task]: task_list) {
|
||||||
|
if (task->wake_up_msg == msg->msg) {
|
||||||
|
EVENT_MSG cpy;
|
||||||
|
cpy.msg = msg->msg;
|
||||||
|
va_copy(cpy.data, msg->data);
|
||||||
|
cur_message = &cpy;
|
||||||
|
switch_to_task(task.get());
|
||||||
|
va_end(cpy.data);
|
||||||
|
cur_message = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
void task_sleep(void) {
|
||||||
|
if (current_task_inst) {
|
||||||
|
switch_to_task(NULL);
|
||||||
|
} else {
|
||||||
|
auto now = std::chrono::system_clock::now();
|
||||||
|
for (auto &[id, task]: task_list) {
|
||||||
|
if (task->_wake_up_after < now && task->wake_up_msg == -1) {
|
||||||
|
switch_to_task(task.get());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
EVENT_MSG *task_wait_event(int32_t event_number) {
|
||||||
|
if (current_task_inst == NULL) return NULL;
|
||||||
|
current_task_inst->wake_up_msg = event_number;
|
||||||
|
switch_to_task(NULL);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
int q_any_task() {
|
||||||
|
return task_list.size();
|
||||||
|
}
|
||||||
|
char task_quitmsg() {
|
||||||
|
if (current_task_inst == NULL) return 0;
|
||||||
|
return current_task_inst->request_exit?1:0;
|
||||||
|
}
|
||||||
|
char q_is_mastertask() {
|
||||||
|
return current_task_inst == NULL;
|
||||||
|
}
|
||||||
|
int q_current_task() {
|
||||||
|
return current_task_inst?current_task_inst->id:-1;
|
||||||
|
}
|
||||||
|
void task_sleep_for(unsigned int time_ms) {
|
||||||
|
|
||||||
|
}
|
68
platform/legacy_coroutines.h
Normal file
68
platform/legacy_coroutines.h
Normal file
|
@ -0,0 +1,68 @@
|
||||||
|
#ifndef _FCS_TASKER_H_
|
||||||
|
#define _FCS_TASKER_H_
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <stdarg.h>
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <event.h>
|
||||||
|
|
||||||
|
|
||||||
|
typedef void (*TaskerFunctionName)(va_list);
|
||||||
|
|
||||||
|
//void tasker(EVENT_MSG *msg,void **data);
|
||||||
|
//int create_task();
|
||||||
|
///start new task
|
||||||
|
/**
|
||||||
|
* @param stack stack size - ignored by some platforms
|
||||||
|
* @param fcname function to start
|
||||||
|
* @param ... arguments
|
||||||
|
* @return id of task
|
||||||
|
*
|
||||||
|
* @note task is started immediatelly.
|
||||||
|
* @note arguments are valid only until task is suspended
|
||||||
|
*/
|
||||||
|
int add_task(int stack,TaskerFunctionName fcname,...);
|
||||||
|
///terminate task
|
||||||
|
/**
|
||||||
|
* request to terminate given task. The task can check this flag by
|
||||||
|
* task_quitmsg()
|
||||||
|
|
||||||
|
*/
|
||||||
|
void term_task(int id_num);
|
||||||
|
///returns true, if task is running
|
||||||
|
char is_running(int id_num);
|
||||||
|
//void suspend_task(int id_num,int msg);
|
||||||
|
//void shut_down_task(int id_num);
|
||||||
|
///resumes task waiting on given message event
|
||||||
|
|
||||||
|
void unsuspend_task(EVENT_MSG *msg);
|
||||||
|
|
||||||
|
///sleep current task and switch to another
|
||||||
|
void task_sleep(void);
|
||||||
|
|
||||||
|
void task_sleep_for(unsigned int time_ms);
|
||||||
|
///sleep current task and wake up when given event is triggered
|
||||||
|
/**
|
||||||
|
* @param event_number waiting number
|
||||||
|
* @return received message, NULL if task_term called
|
||||||
|
*/
|
||||||
|
EVENT_MSG *task_wait_event(int32_t event_number);
|
||||||
|
///returns count of tasks
|
||||||
|
int q_any_task();
|
||||||
|
///returns 1 if terminate is requested
|
||||||
|
char task_quitmsg();
|
||||||
|
//char task_quitmsg_by_id(int id);
|
||||||
|
char q_is_mastertask();
|
||||||
|
///returns id of current task
|
||||||
|
int q_current_task();
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
1
platform/sdl/CMakeLists.txt
Normal file
1
platform/sdl/CMakeLists.txt
Normal file
|
@ -0,0 +1 @@
|
||||||
|
add_subdirectory(tests)
|
16
platform/sdl/tests/CMakeLists.txt
Normal file
16
platform/sdl/tests/CMakeLists.txt
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/tests/)
|
||||||
|
|
||||||
|
set(testFiles sdl_minimal_test.cpp sdl_surface_test.cpp
|
||||||
|
)
|
||||||
|
|
||||||
|
foreach (testFile ${testFiles})
|
||||||
|
string(REGEX MATCH "([^\/]+$)" filename ${testFile})
|
||||||
|
string(REGEX MATCH "[^.]*" executable_name test_${filename})
|
||||||
|
add_executable(${executable_name} ${testFile})
|
||||||
|
target_link_libraries(${executable_name} ${SDL2_LIBRARIES} )
|
||||||
|
add_test(NAME ${executable_name} COMMAND ${executable_name})
|
||||||
|
endforeach ()
|
||||||
|
|
||||||
|
|
||||||
|
add_executable(sdl_fullscreen_window sdl_fullscreen_window.cpp)
|
||||||
|
target_link_libraries(sdl_fullscreen_window ${SDL2_LIBRARIES} )
|
57
platform/sdl/tests/sdl_fullscreen_window.cpp
Normal file
57
platform/sdl/tests/sdl_fullscreen_window.cpp
Normal file
|
@ -0,0 +1,57 @@
|
||||||
|
#include <iostream>
|
||||||
|
#include <SDL2/SDL.h>
|
||||||
|
|
||||||
|
int main(int argc, char* argv[]) {
|
||||||
|
if (SDL_Init(SDL_INIT_VIDEO) < 0) {
|
||||||
|
SDL_Log("Unable to initialize SDL: %s", SDL_GetError());
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
SDL_Window* window = SDL_CreateWindow("Fullscreen Toggle with Aspect Ratio",
|
||||||
|
SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED,
|
||||||
|
640, 480, SDL_WINDOW_RESIZABLE);
|
||||||
|
|
||||||
|
if (!window) {
|
||||||
|
SDL_Log("Unable to create window: %s", SDL_GetError());
|
||||||
|
SDL_Quit();
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
SDL_Renderer* renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_ACCELERATED);
|
||||||
|
if (!renderer) {
|
||||||
|
SDL_Log("Unable to create renderer: %s", SDL_GetError());
|
||||||
|
SDL_DestroyWindow(window);
|
||||||
|
SDL_Quit();
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int isFullscreen = 0;
|
||||||
|
int running = 1;
|
||||||
|
SDL_Event event;
|
||||||
|
|
||||||
|
while (running) {
|
||||||
|
while (SDL_PollEvent(&event)) {
|
||||||
|
if (event.type == SDL_QUIT) {
|
||||||
|
running = 0;
|
||||||
|
}
|
||||||
|
if (event.type == SDL_KEYDOWN) {
|
||||||
|
if (event.key.keysym.sym == SDLK_RETURN && (event.key.keysym.mod & KMOD_ALT)) {
|
||||||
|
// Přepnutí mezi fullscreen a oknem
|
||||||
|
isFullscreen = !isFullscreen;
|
||||||
|
SDL_SetWindowFullscreen(window, isFullscreen ? SDL_WINDOW_FULLSCREEN_DESKTOP : 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Renderování
|
||||||
|
SDL_SetRenderDrawColor(renderer, 0, 0, 0, 255);
|
||||||
|
SDL_RenderClear(renderer);
|
||||||
|
SDL_RenderPresent(renderer);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Uklid zdrojů
|
||||||
|
SDL_DestroyRenderer(renderer);
|
||||||
|
SDL_DestroyWindow(window);
|
||||||
|
SDL_Quit();
|
||||||
|
return 0;
|
||||||
|
}
|
27
platform/sdl/tests/sdl_minimal_test.cpp
Normal file
27
platform/sdl/tests/sdl_minimal_test.cpp
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
#include <SDL2/SDL.h>
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
|
int main(int argc, char* argv[]) {
|
||||||
|
if (SDL_Init(SDL_INIT_VIDEO) != 0) {
|
||||||
|
std::cerr << "SDL Initialization Error: " << SDL_GetError() << std::endl;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
SDL_Window* window = SDL_CreateWindow("SDL Window",
|
||||||
|
SDL_WINDOWPOS_CENTERED,
|
||||||
|
SDL_WINDOWPOS_CENTERED,
|
||||||
|
800, 600,
|
||||||
|
SDL_WINDOW_SHOWN);
|
||||||
|
|
||||||
|
if (!window) {
|
||||||
|
std::cerr << "Window Creation Error: " << SDL_GetError() << std::endl;
|
||||||
|
SDL_Quit();
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
SDL_Delay(500); // Zobrazí okno na 3 sekundy
|
||||||
|
|
||||||
|
SDL_DestroyWindow(window);
|
||||||
|
SDL_Quit();
|
||||||
|
return 0;
|
||||||
|
}
|
73
platform/sdl/tests/sdl_surface_test.cpp
Normal file
73
platform/sdl/tests/sdl_surface_test.cpp
Normal file
|
@ -0,0 +1,73 @@
|
||||||
|
#include <SDL2/SDL.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
#define WIDTH 640
|
||||||
|
#define HEIGHT 480
|
||||||
|
|
||||||
|
|
||||||
|
int main(int argc, char *argv[]) {
|
||||||
|
// Inicializace SDL
|
||||||
|
if (SDL_Init(SDL_INIT_VIDEO) != 0) {
|
||||||
|
fprintf(stderr, "Chyba při inicializaci SDL: %s\n", SDL_GetError());
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Vytvoření SDL okna
|
||||||
|
SDL_Window *window = SDL_CreateWindow("DOS Game Port", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, WIDTH, HEIGHT, 0);
|
||||||
|
if (!window) {
|
||||||
|
fprintf(stderr, "Chyba při vytváření okna: %s\n", SDL_GetError());
|
||||||
|
SDL_Quit();
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Vytvoření rendereru (pouze pro zobrazení)
|
||||||
|
SDL_Renderer *renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_ACCELERATED);
|
||||||
|
if (!renderer) {
|
||||||
|
fprintf(stderr, "Chyba při vytváření rendereru: %s\n", SDL_GetError());
|
||||||
|
SDL_DestroyWindow(window);
|
||||||
|
SDL_Quit();
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Vytvoření SDL Surface (backbuffer)
|
||||||
|
SDL_Texture *texture = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_RGB565,SDL_TEXTUREACCESS_STREAMING, WIDTH, HEIGHT);
|
||||||
|
if (!texture) {
|
||||||
|
fprintf(stderr, "Chyba při vytváření surface: %s\n", SDL_GetError());
|
||||||
|
SDL_DestroyRenderer(renderer);
|
||||||
|
SDL_DestroyWindow(window);
|
||||||
|
SDL_Quit();
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
void *raw_pixels;
|
||||||
|
int pitch;
|
||||||
|
SDL_LockTexture(texture, NULL, &raw_pixels, &pitch);
|
||||||
|
// Přímý přístup do paměti surface
|
||||||
|
Uint16 *pixels = reinterpret_cast<Uint16 *>(raw_pixels);
|
||||||
|
printf("Adresa pixelů: %p, pitch: %d bajtů\n", (void *)pixels, pitch);
|
||||||
|
|
||||||
|
// Software rendering - příklad kreslení do paměti
|
||||||
|
for (int y = 0; y < HEIGHT; y++) {
|
||||||
|
for (int x = 0; x < WIDTH; x++) {
|
||||||
|
Uint16 color = (x ^ y) & 0xFFFF; // Příklad barvy
|
||||||
|
pixels[y * (pitch / 2) + x] = color; // Zápis pixelu
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
SDL_UnlockTexture(texture);
|
||||||
|
|
||||||
|
SDL_RenderClear(renderer);
|
||||||
|
SDL_RenderCopy(renderer, texture, NULL, NULL);
|
||||||
|
SDL_RenderPresent(renderer);
|
||||||
|
|
||||||
|
SDL_Delay(3000); // Zobrazení okna na 3 sekundy
|
||||||
|
|
||||||
|
// Uvolnění zdrojů
|
||||||
|
SDL_DestroyTexture(texture);
|
||||||
|
SDL_DestroyRenderer(renderer);
|
||||||
|
SDL_DestroyWindow(window);
|
||||||
|
SDL_Quit();
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue