trying to debug, additional rewrites

This commit is contained in:
Ondřej Novák 2025-01-26 21:36:03 +01:00
parent 378b5586ab
commit 42f780a729
87 changed files with 1771 additions and 529 deletions

View file

@ -247,29 +247,29 @@ void CMainFrame::OnFileNovdobrodrust()
switch (dlg.vOrganizace)
{
case 0:
cestaGrafika=baseMap+_T("GRFSTENY\\");
cestaDialogy=baseMap+_T("GRFDIALG\\");
cestaEnemy=baseMap+_T("GRFENEMY\\");
cestaItemy=baseMap+_T("GRFITEMS\\");
cestaPozice=baseMap+_T("SAVEGAME\\");
cestaZvuky=baseMap+_T("SOUNDS\\");
cestaBasicGr=baseMap+_T("GRFBASIC\\");
cestaGrafika=baseMap+_T("GRFSTENY" PATH_SEPARATOR);
cestaDialogy=baseMap+_T("GRFDIALG" PATH_SEPARATOR);
cestaEnemy=baseMap+_T("GRFENEMY" PATH_SEPARATOR);
cestaItemy=baseMap+_T("GRFITEMS" PATH_SEPARATOR);
cestaPozice=baseMap+_T("SAVEGAME" PATH_SEPARATOR);
cestaZvuky=baseMap+_T("SOUNDS" PATH_SEPARATOR);
cestaBasicGr=baseMap+_T("GRFBASIC" PATH_SEPARATOR);
break;
case 1:
cestaGrafika=baseMap+_T("graphics\\");
cestaDialogy=baseMap+_T("graphics\\dialogs\\");
cestaEnemy=baseMap+_T("graphics\\enemies\\");
cestaItemy=baseMap+_T("graphics\\items\\");
cestaPozice=baseMap+_T("SAVEGAME\\");
cestaZvuky=baseMap+_T("SAMPLES\\");
cestaBasicGr=baseMap+_T("graphics\\basic\\");
cestaGrafika=baseMap+_T("graphics" PATH_SEPARATOR);
cestaDialogy=baseMap+_T("graphics" PATH_SEPARATOR "dialogs" PATH_SEPARATOR);
cestaEnemy=baseMap+_T("graphics" PATH_SEPARATOR "enemies" PATH_SEPARATOR);
cestaItemy=baseMap+_T("graphics" PATH_SEPARATOR "items");
cestaPozice=baseMap+_T("SAVEGAME" PATH_SEPARATOR );
cestaZvuky=baseMap+_T("SAMPLES" PATH_SEPARATOR);
cestaBasicGr=baseMap+_T("graphics" PATH_SEPARATOR "basic" PATH_SEPARATOR);
break;
case 2:
cestaGrafika=baseMap;
cestaDialogy=baseMap;
cestaEnemy=baseMap;
cestaItemy=baseMap;
cestaPozice=baseMap+_T("SAVEGAME\\");
cestaPozice=baseMap+_T("SAVEGAME" PATH_SEPARATOR);
cestaZvuky=baseMap;
cestaBasicGr=baseMap;
break;

View file

@ -1,8 +1,19 @@
add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/default_font.base64
COMMAND base64 ${CMAKE_CURRENT_LIST_DIR}/boldcz.fon -w 0 > ${CMAKE_BINARY_DIR}/default_font.base64
DEPENDS ${CMAKE_CURRENT_LIST_DIR}/boldcz.fon)
add_custom_command(
OUTPUT ${CMAKE_BINARY_DIR}/default_font.cpp
COMMAND ${CMAKE_COMMAND} -DOUT=${CMAKE_BINARY_DIR}/default_font.cpp -DIN=${CMAKE_BINARY_DIR}/default_font.base64 -DTEMPLATE=${CMAKE_CURRENT_LIST_DIR}/default_font.in.cpp -P ${CMAKE_CURRENT_LIST_DIR}/default_font_to_cpp.cmake
DEPENDS ${CMAKE_BINARY_DIR}/default_font.base64 ${CMAKE_CURRENT_LIST_DIR}/default_font_to_cpp.cmake ${CMAKE_CURRENT_LIST_DIR}/default_font.in.cpp
)
SET(files automap.c
clk_map.c
dialogy.c
dump.cpp
enemy.c
engine1.c
engine2.c
globmap.c
inv.c
@ -21,7 +32,14 @@ setup.c
chargen.c
sndandmus.c
specproc.c
temp_storage.cpp)
temp_storage.cpp
${CMAKE_BINARY_DIR}/default_font.cpp
)
add_executable(skeldal ${files})
target_link_libraries(skeldal skeldal_libs skeldal_platform_libs ${SDL2_LIBRARIES} pthread)
target_link_libraries(skeldal
skeldal_libs
skeldal_platform_libs
skeldal_linux
skeldal_sdl
${SDL2_LIBRARIES} pthread)

View file

@ -1,4 +1,4 @@
#include <skeldal_win.h>
#include <platform.h>
#include <stdio.h>
#include <stdlib.h>
#include <malloc.h>
@ -423,10 +423,10 @@ static void draw_amap_sector(int x,int y,int sector,int mode,int turn,int line1,
{
switch (j)
{
case 0:hor_line(x,y,x+8);break;
case 1:ver_line(x+8,y,y+8);break;
case 2:hor_line(x,y+8,x+8);break;
case 3:ver_line(x,y,y+8);break;
case 0:hor_line32(x,y,x+8);break;
case 1:ver_line32(x+8,y,y+8);break;
case 2:hor_line32(x,y+8,x+8);break;
case 3:ver_line32(x,y,y+8);break;
}
}
}
@ -488,6 +488,7 @@ static void displ_button(char disable,char **text)
int sizy[]={18,20,20,21};
int i;
int32_t scr_linelen2 = GetScreenPitch();
cur_disables=disable;
set_font(H_FTINY,0);
put_picture(LEFT,BOTT,ablock(H_CHARGEN));

View file

@ -1,4 +1,4 @@
#include <skeldal_win.h>
#include <platform.h>
#include <stdio.h>
#include <stdlib.h>
#include <malloc.h>
@ -189,7 +189,8 @@ void show_money()
void anim_sipky(int h,int mode)
{
static int phase=0;
int32_t scr_linelen2 = GetScreenPitch();
static int phase=0;
static char drw=0;
static short handle=0;
@ -254,6 +255,7 @@ void draw_blood(char mode,int mob_dostal,int mob_dostal_pocet)
word *adr;
int i;
int32_t scr_linelen2 = GetScreenPitch();
mob_dostal_pocet;
if (mode) {
if (phase<3) dostal+=mob_dostal_pocet;else dostal=mob_dostal_pocet;
@ -267,13 +269,14 @@ void draw_blood(char mode,int mob_dostal,int mob_dostal_pocet)
phase++;
put_8bit_clipped(ablock(H_KREVMIN+block-1),adr,i,120,102);
set_font(H_FTINY,RGB555(31,31,31));
itoa(dostal,s,10);
int2ascii(dostal,s,10);
set_aligned_position(60+520,51+378,1,1,s);outtext(s);
}
word *bott_clear(void)
{
word *bott_scr;
int32_t scr_linelen2 = GetScreenPitch();
int32_t sz;
bott_scr=(word *)getmem(sz = scr_linelen2*104*2);
@ -314,6 +317,7 @@ static void bott_draw_normal(void **pp,int32_t *s)
word *bott_scr;
THUMAN *p;
int32_t scr_linelen2 = GetScreenPitch();
bott_scr=bott_clear();
RedirectScreen(bott_scr);
if (battle && cur_mode==MD_INBATTLE) put_picture(0,0,ablock(H_BATTLE_BAR));
@ -339,12 +343,12 @@ static void bott_draw_normal(void **pp,int32_t *s)
else put_picture(PIC_X+x,PIC_Y,ablock(H_LEBKA));
curcolor=0;
y=BARS_YS-p->lives*BARS_YS/p->vlastnosti[VLS_MAXHIT];
if (y) bar(x+ZIVOTY_S,BARS_S,x+ZIVOTY_E,BARS_S+y);
if (y) bar32(x+ZIVOTY_S,BARS_S,x+ZIVOTY_E,BARS_S+y);
y=BARS_YS-p->kondice*BARS_YS/p->vlastnosti[VLS_KONDIC];
if (y) bar(x+KONDIC_S,BARS_S,x+KONDIC_E,BARS_S+y);
if (y) bar32(x+KONDIC_S,BARS_S,x+KONDIC_E,BARS_S+y);
if (p->vlastnosti[VLS_MAXMANA]) y=BARS_YS-p->mana*BARS_YS/p->vlastnosti[VLS_MAXMANA];else y=BARS_YS;
if (y<0) y=0;
if (y) bar(x+MANA_S,BARS_S,x+MANA_E,BARS_S+y);
if (y) bar32(x+MANA_S,BARS_S,x+MANA_E,BARS_S+y);
if (p->sektor!=viewsector) trans_bar25(x,0,74,102);
set_font(H_FLITT,p->groupnum==cur_group && !battle?SEL_COLOR:barvy_skupin[p->groupnum]);
set_aligned_position(x+36,92,1,0,p->jmeno);outtext(p->jmeno);
@ -459,6 +463,7 @@ static void MaskPutPicture(int x, int y, char mask, word color, char blend, void
{
short *info=(short *)pic;
char *data=(char *)(info+3+256);
int32_t scr_linelen2 = GetScreenPitch();
word *pos=GetScreenAdr()+x+y*scr_linelen2;
if (blend) color=color & 0xF7DE;
for (y=0;y<info[1];y++,pos+=scr_linelen2,data+=info[0])
@ -555,6 +560,8 @@ void draw_spell(int handle,int phase,int xicht)
{
int x,y,i;
word *w;
int32_t scr_linelen2 = GetScreenPitch();
if (bott_display!=BOTT_NORMAL) bott_draw(1);
for(i=0;i<POCET_POSTAV;i++)
@ -588,6 +595,8 @@ void other_draw()
show_money();
anim_sipky(0,-1);
draw_fx();
int32_t scr_linelen2 = GetScreenPitch();
memset(GetScreenAdr()+(SCREEN_OFFLINE-1)*scr_linelen2,0,1280);
memset(GetScreenAdr()+(SCREEN_OFFLINE+360)*scr_linelen2,0,1280);
}
@ -1012,7 +1021,7 @@ void back_clear(int celx,int color)
{
curcolor=color;
RedirectScreenBufferSecond();
bar(x1,y1,x2,y2);
bar32(x1,y1,x2,y2);
RestoreScreen();
}
}
@ -1034,6 +1043,8 @@ extern char folow_mode;
static void zobraz_lodku(word *lodka, word *screen, int size)
{
int32_t scr_linelen2 = GetScreenPitch();
int x;
while (size)
{
@ -1073,6 +1084,9 @@ static void trace_for_bgr(int dir)
static int olddir=0;
TSTENA *ss;
int32_t scr_linelen2 = GetScreenPitch();
bgr_handle=0;
bgr_distance=-1;
for(i=0,s=0;i<VIEW3D_Z && minimap[i][VIEW3D_X];)
@ -1269,6 +1283,7 @@ void draw_fx()
FX_PLAY *fx;
FX_PLAY **last;
int32_t scr_linelen2 = GetScreenPitch();
if (fx_data==NULL) return;
fx=fx_data;last=&fx_data;
c=ablock(H_FX);

View file

@ -1,5 +1,5 @@
//CHARACTER GENERATOR
#include <skeldal_win.h>
#include <platform.h>
#include <stdio.h>
#include <stdlib.h>
#include <malloc.h>
@ -59,8 +59,8 @@ typedef struct staty
static T_STATY cur_stats;
word color_butt_on[]={0,RGB555(31,27,4),RGB555(30,26,4),RGB555(29,25,4)};
word color_butt_off[]={0,RGB555(10,10,10),RGB555(10,10,10),RGB555(10,10,10)};
word color_butt_on[7]={0,RGB555(31,27,4),RGB555(30,26,4),RGB555(29,25,4)};
word color_butt_off[7]={0,RGB555(10,10,10),RGB555(10,10,10),RGB555(10,10,10)};
typedef struct vlasts
@ -201,6 +201,8 @@ void displ_button(char disable,char **text)
int sizy[]={18,20,20,21};
int i;
int32_t scr_linelen2 = GetScreenPitch();
set_font(H_FTINY,0);
put_picture(LEFT,BOTT,ablock(H_GEN_CHARGEN));
for(i=0;i<4;i++)
@ -223,9 +225,11 @@ void displ_button(char disable,char **text)
static void draw_other_bar()
{
int i;
int32_t scr_linelen2 = GetScreenPitch();
word *bbar=ablock(H_BOTTBAR);
word *screen=GetScreenAdr()+(480-102)*scr_linelen2;
for (i=0;i<102;i++,screen+=scr_linelen2,bbar+=scr_linelen2) memcpy(screen,bbar,scr_linelen);
for (i=0;i<102;i++,screen+=scr_linelen2,bbar+=scr_linelen2) memcpy(screen,bbar,scr_linelen2*2);
//put_8bit_clipped(ablock(H_GEN_OKBUTT),378*640+520+screen,0,120,102);
displ_button(b_disables,b_texty);
put_picture(0,0,ablock(H_GEN_TOPBAR));
@ -280,6 +284,8 @@ static void zobraz_perlu(void)
word *b;
int xs,ys,xxs;
int32_t scr_linelen2 = GetScreenPitch();
alock(H_GEN_PERLA);
perla=ablock(H_GEN_PERLA);
if (pod_perlou==NULL)
@ -505,7 +511,7 @@ static int edit_task=-1;
static void edit_name()
{
if (shut_downing_text) return;
curcolor=0;bar(120,2,120+104,16);
curcolor=0;bar32(120,2,120+104,16);
edit_task=add_task(16384,type_text_v2,postavy[cur_edited].jmeno,120,2,104,
sizeof(postavy[cur_edited].jmeno)-1,H_FONT6,RGB555(31,31,0),edit_name);
}
@ -655,8 +661,8 @@ static void redraw_svitek(char)
update_mysky();
schovej_mysku();
curcolor=0;
bar(0,16,30,16+360);
bar(620,16,640,16+360);
bar32(0,16,30,16+360);
bar32(620,16,640,16+360);
inv_display_vlastnosti();
display_character(postavy+cur_edited,0);
// display_items_wearing(human_selected);
@ -817,7 +823,7 @@ char enter_generator()
b_texty[2]=texty[172];
b_texty[3]=texty[173];
def_entries();
curcolor=0;bar(0,0,639,479);
curcolor=0;bar32(0,0,639,479);
cur_angle=315;
cur_edited=0;
memset(postavy,0,sizeof(postavy));
@ -890,7 +896,7 @@ char enter_generator()
disable_click_map();
schovej_mysku();
curcolor=0;
bar(0,0,639,479);
bar32(0,0,639,479);
showview(0,0,0,0);
ukaz_mysku();
for(i=0;i<3;i++)

View file

@ -1,4 +1,4 @@
#include <skeldal_win.h>
#include <platform.h>
#include <stdio.h>
#include <types.h>
#include <event.h>

5
game/default_font.h Normal file
View file

@ -0,0 +1,5 @@
void *LoadDefaultFont();

14
game/default_font.in.cpp Normal file
View file

@ -0,0 +1,14 @@
#include <base64.h>
constexpr binary_data font_data ="@CONTENT@";
extern "C" {
const void *LoadDefaultFont() {
return font_data.begin();
}
}

View file

@ -0,0 +1,4 @@
file(READ ${IN} CONTENT)
configure_file(${TEMPLATE} ${OUT} @ONLY)

View file

@ -1,4 +1,4 @@
#include <skeldal_win.h>
#include <platform.h>
#include <stdio.h>
#include <stdlib.h>
#include <malloc.h>
@ -160,6 +160,7 @@ static void dialog_anim(va_list args)
char hid;
int spdc=0,cntr=rep,tm,tm2;
int32_t scr_linelen2 = GetScreenPitch();
loc_anim_render_buffer=PIC_Y*scr_linelen2+PIC_X;
mgif_install_proc(animace_kouzla);
concat(ch,pathtable[SR_DIALOGS],block);
@ -1125,7 +1126,7 @@ static void dark_screen(int time,int gtime)
THUMAN *h;
i=get_timer_value()+time*50;
curcolor=0;
bar(0,17,639,377);
bar32(0,17,639,377);
showview(0,0,0,0);
while (get_timer_value()<i) do_events();
game_time+=gtime*HODINA;
@ -1298,6 +1299,7 @@ static void create_back_pic()
{
int skpx=4,skpy=5,xp,yp;
word *p,*s=GetScreenAdr()+SCREEN_OFFSET,*s2;
int32_t scr_linelen2 = GetScreenPitch();
schovej_mysku();
p=back_pic=NewArr(word,3+340*200);
@ -1324,7 +1326,7 @@ void call_dialog(int entr,int mob)
void (*old_wire_proc)()=wire_proc;
curcolor=0;
create_back_pic();
bar(0,SCREEN_OFFLINE,639,SCREEN_OFFLINE+359);
bar32(0,SCREEN_OFFLINE,639,SCREEN_OFFLINE+359);
SEND_LOG("(DIALOGS) Starting dialog...",0,0);
for(i=0;i<POCET_POSTAV;i++) if (isdemon(postavy+i)) unaffect_demon(i);
mute_all_tracks(0);

View file

@ -1,3 +1,4 @@
#include <types.h>
#include <stdio.h>
#include <malloc.h>
#include <mem.h>
@ -27,7 +28,7 @@ void open_files(char *src,char *tgr)
char *c,*d;
tgr=alloca(strlen(src)+5);
strcpy(tgr,src);
c=strrchr(tgr,'\\');
c=strrchr(tgr,PATH_SEPARATOR_CHR);
d=strrchr(tgr,'.');
if (c>d) d=strchr(tgr,0);
strcpy(d,".ENC");

View file

@ -1,4 +1,4 @@
#include <skeldal_win.h>
#include <platform.h>
#include <stdio.h>
#include <stdlib.h>
#include <malloc.h>

View file

@ -1,4 +1,4 @@
#include <skeldal_win.h>
#include <platform.h>
#include <types.h>
#include <stdio.h>
#include <stdlib.h>
@ -282,6 +282,8 @@ void create_tables(void)
{
int x,y;
int32_t scr_linelen2 = GetScreenPitch();
for (y=0;y<VIEW3D_Z+1;y++)
{
@ -374,7 +376,7 @@ void create_tables(void)
xr=xr*(y1+1)/points[0][0][0].y+MIDDLE_X;
if (xl<0) xl=0;if (xr<0) xr=0;
if (xl>639) xl=639;if (xr>639) xr=639;
showtabs.f_table[x][y].lineofs=(y1+MIDDLE_Y)*scr_linelen+xl*2;
showtabs.f_table[x][y].lineofs=(y1+MIDDLE_Y)*2*scr_linelen2+xl*2;
showtabs.f_table[x][y].linesize=xr-xl+(xl!=xr);
showtabs.f_table[x][y].counter=(y1-points[0][0][yp].y);
showtabs.f_table[x][y].txtrofs=(y1+MIDDLE_Y-VIEW_SIZE_Y+F_YMAP_SIZE)*1280+xl*2;
@ -404,7 +406,7 @@ void create_tables(void)
xr=xr*(y1-2)/points[0][1][0].y+MIDDLE_X;
if (xl<0) xl=0;if (xr<0) xr=0;
if (xl>639) xl=639;if (xr>639) xr=639;
showtabs.c_table[x][y].lineofs=(y1+MIDDLE_Y)*scr_linelen+xl*2;
showtabs.c_table[x][y].lineofs=(y1+MIDDLE_Y)*2*scr_linelen2+xl*2;
showtabs.c_table[x][y].linesize=xr-xl+(xl!=xr);
showtabs.c_table[x][y].counter=points[0][1][yp].y-y1;
showtabs.c_table[x][y].txtrofs=(y1+MIDDLE_Y)*1280+xl*2;
@ -433,11 +435,13 @@ void create_zooming(void)
{
int i,j;
int32_t scr_linelen2 = GetScreenPitch();
for (j=0;j<ZOOM_PHASES;j++)
{
calc_zooming(zooming_xtable[j],320,zooming_points[j][0]);
calc_y_buffer(zooming_ytable[j],zooming_points[j][1],360,360);
for(i=0;i<360;i++) zooming_ytable[j][i]*=scr_linelen;
for(i=0;i<360;i++) zooming_ytable[j][i]*=2*scr_linelen2;
}
}
@ -574,6 +578,8 @@ void show_cel(int celx,int cely,void *stena,int xofs,int yofs,char rev)
int txtsx,txtsy,realsx,realsy,x,i,yss,ysd;
char *p;int plac;
int32_t scr_linelen2 = GetScreenPitch();
plac=rev>>5;
rev&=3;
if (celx<=0) x3d=&showtabs.z_table[-celx][cely]; else x3d=&showtabs.z_table[celx][cely];
@ -632,7 +638,7 @@ void show_cel(int celx,int cely,void *stena,int xofs,int yofs,char rev)
zoom.palette=(word *)((byte *)stena+6+512*(cely)+(secnd_shade?SHADE_STEPS*512:0));
zoom.ycount=realsy+1;
zoom.xmax=realsx;
zoom.line_len=scr_linelen;
zoom.line_len=2*scr_linelen2;
if (rev) sikma_zprava(); else sikma_zleva();
}
@ -644,6 +650,8 @@ void show_cel2(int celx,int cely,void *stena,int xofs,int yofs,char rev)
int txtsx,txtsy,realsx,realsy,x,i;
char *p;int plac;
int32_t scr_linelen2 = GetScreenPitch();
if (stena==NULL) return ;
plac=rev>>5;
rev&=3;
@ -696,7 +704,7 @@ void show_cel2(int celx,int cely,void *stena,int xofs,int yofs,char rev)
zoom.palette=(word *)((byte *)stena+6+512*(cely)+(secnd_shade?SHADE_STEPS*512:0));
zoom.ycount=realsy+1;
zoom.xmax=realsx;
zoom.line_len=scr_linelen;
zoom.line_len=scr_linelen2*2;
if (rev==2) sikma_zprava(); else sikma_zleva();
}
@ -738,6 +746,8 @@ void draw_floor_ceil(int celx,int cely,char f_c,void *txtr)
void OutBuffer2nd(void)
{
int i;
int32_t scr_linelen2 = GetScreenPitch();
for (i=0;i<480;i++)
memcpy(GetScreenAdr()+i*scr_linelen2,GetBuffer2nd()+i*scr_linelen2,640*2);
}
@ -745,6 +755,8 @@ void OutBuffer2nd(void)
void CopyBuffer2nd(void)
{
int i;
int32_t scr_linelen2 = GetScreenPitch();
for (i=0;i<480;i++)
memcpy(GetBuffer2nd()+i*scr_linelen2,GetScreenAdr()+i*scr_linelen2,640*2);
}
@ -881,7 +893,7 @@ void report_mode(int mode)
}*/
}
__inline void clear_color(void *start,int _size,word _color)
void clear_color(void *start,int _size,word _color)
{
word *s = (word *)start;
int i;
@ -906,6 +918,8 @@ __inline void clear_color(void *start,int _size,word _color)
void clear_buff(word *background,word backcolor,int lines)
{
int32_t scr_linelen2 = GetScreenPitch();
if (background!=NULL) put_picture(0,SCREEN_OFFLINE,background);else lines=0;
if (lines!=360)
for (i=lines;i<360;i++)
@ -915,6 +929,8 @@ void clear_buff(word *background,word backcolor,int lines)
void clear_screen(word *screen, word color)
{
int32_t scr_linelen2 = GetScreenPitch();
for (i=0;i<480;i++) clear_color(screen+scr_linelen2*i,640,color);
}
@ -925,6 +941,8 @@ void general_engine_init()
create_zooming();
clear_screen(GetScreenAdr(),0);
clear_screen(GetBuffer2nd(),0);
int32_t scr_linelen2 = GetScreenPitch();
screen_buffer_size=scr_linelen2*480*2;
}
@ -1035,6 +1053,8 @@ void draw_item(int celx,int cely,int posx,int posy,short *txtr,int index)
int x,y;
int clipl,clipr;
int randx,randy;
int32_t scr_linelen2 = GetScreenPitch();
if (txtr==NULL) return;
randx=items_indextab[7-(index & 0x7)][0];
@ -1057,6 +1077,8 @@ void put_textured_bar(void *src,int x,int y,int xs,int ys,int xofs,int yofs)
{
word *pos;
word *xy;
int32_t scr_linelen2 = GetScreenPitch();
pos=GetScreenAdr()+x+scr_linelen2*y;
xy=src;
@ -1071,6 +1093,7 @@ void draw_placed_texture(short *txtr,int celx,int cely,int posx,int posy,int pos
{
int x,y;
int clipl,clipr;
int32_t scr_linelen2 = GetScreenPitch();
if (txtr==NULL) return;
map_pos(celx,cely,posx,posy,posz,&x,&y);
@ -1187,6 +1210,8 @@ void draw_enemy(DRW_ENEMY *drw)
int posx,posy,cely;
short *ys,yss,*xs,xss;
int grcel;
int32_t scr_linelen2 = GetScreenPitch();
if (drw->stoned)
{
@ -1253,6 +1278,8 @@ void draw_player(short *txtr,int celx,int cely,int posx,int posy,int adjust,char
{
int x,y,yc,lx,sd;
int clipl,clipr;
int32_t scr_linelen2 = GetScreenPitch();
RedirectScreenBufferSecond();
map_pos(celx,cely,posx+64,posy+64,0,&x,&y);
@ -1285,6 +1312,8 @@ void draw_player(short *txtr,int celx,int cely,int posx,int posy,int adjust,char
void draw_spectxtr(short *txtr,int celx,int cely,int xpos)
{
int x,y,lx,clipl,clipr;
int32_t scr_linelen2 = GetScreenPitch();
map_pos(celx,cely,64,64,0,&x,&y);
lx=x;
x-=(((*txtr>>1)+xpos)*last_scale*2)/320;
@ -1304,6 +1333,7 @@ void draw_item2(int celx,int cely,int xpos,int ypos,void *txtr,int index)
{
int x,y,xs,ys,ysc,abc,asc,clipl,clipr;
static int indextab[][2]={{0,0},{0,1},{1,0},{-1,0},{1,2},{-1,1},{-2,1},{2,1}};
int32_t scr_linelen2 = GetScreenPitch();
celx--;
asc=(celx<0);

View file

@ -18,7 +18,7 @@
#define FACTOR_3D 3.33
#define ZOOM_PHASES 9
#define SCREEN_OFFLINE (17)
#define SCREEN_OFFSET (scr_linelen2*SCREEN_OFFLINE)
#define SCREEN_OFFSET (GetScreenPitch()*SCREEN_OFFLINE)
#define C_YMAP_SIZE 90
#define F_YMAP_SIZE 199
#define CF_XMAP_SIZE 7

View file

@ -1,4 +1,4 @@
#include <skeldal_win.h>
#include <platform.h>
#include "types.h"
#include "engine1.h"
#include <bgraph.h>
@ -13,6 +13,7 @@ extern word *screen;
void sikma_zleva(void)
{
int32_t scr_linelen2 = GetScreenPitch();
word *scr = (word *)zoom.startptr;
const word *palette = (word *)zoom.palette;
word cy = zoom.ycount;
@ -86,7 +87,7 @@ void sikma_zleva(void)
void sikma_zprava(void)
{
int32_t scr_linelen2 = GetScreenPitch();
word *scr = (word *)zoom.startptr;
const word *palette = (word *)zoom.palette;
word cy = zoom.ycount;
@ -204,6 +205,7 @@ void klicovani_anm_back(void *target,void *source);
void klicovani_anm(void *target,void *source,char mirror)
//#pragma aux klicovani_anm parm [edi][esi][eax] modify [ecx edx ebx]
{
int32_t scr_linelen2 = GetScreenPitch();
word *t = (word *)target;
word *s = (word *)source;
if (mirror) {
@ -334,6 +336,7 @@ kba_skip:dec ebx
void small_anm_buff(void *target,void *buff,void *paleta)
//#pragma aux small_anm_buff parm[edi][esi][ebx] modify [eax ecx]
{
int32_t scr_linelen2 = GetScreenPitch();
word *t = (word *)target;
unsigned char *s = (unsigned char *)buff;
word *p = (word *)paleta;
@ -366,6 +369,7 @@ shmab3: zobraz_1
void small_anm_delta(void *target,void *buff,void *paleta)
//#pragma aux small_anm_delta parm[edi][esi][ebx] modify [eax ecx]
{
int32_t scr_linelen2 = GetScreenPitch();
word *t = (word *)target;
word *pal = (word *)paleta;
uint32_t *deltastart = (uint32_t *)buff;
@ -444,7 +448,7 @@ shmad4: add edi,scr_linelen
void scroll_and_copy(void *pic,void *slide, void *scr, int _size,int shift, void *lineinfo)
//#pragma aux scroll_and_copy parm[esi][ebx][edi][ecx][edx][eax]
{
int32_t scr_linelen2 = GetScreenPitch();
word *srcpc = (word *)pic;
word *trg = (word *)scr;
word *sld = (word *)slide;
@ -569,6 +573,7 @@ sac_end:sub ecx,2 ;odecti counter
void enemy_draw(void *src,void *trg,int shade,int scale,int maxspace,int clip)
//#pragma aux enemy_draw parm[ESI][EDI][EBX][EDX][EAX][ECX]
{
int32_t scr_linelen2 = GetScreenPitch();
word *picinfo = (word *)src;
word *screen = (word *)trg;
int xtable[800];
@ -756,6 +761,7 @@ void enemy_draw_transp(void *src,void *trg,void *shade,int scale,int maxspace,in
//#pragma aux enemy_draw_transp parm[ESI][EDI][EBX][EDX][EAX][ECX]
{
int32_t scr_linelen2 = GetScreenPitch();
word *picinfo = (word *)src;
word *screen = (word *)trg;
int xtable[800];
@ -946,6 +952,7 @@ void enemy_draw_mirror_transp(void *src,void *trg,void *shade,int scale,int maxs
//#pragma aux enemy_draw_mirror_transp parm[ESI][EDI][EBX][EDX][EAX][ECX]
{
int32_t scr_linelen2 = GetScreenPitch();
word *picinfo = (word *)src;
word *screen = (word *)trg;
int xtable[800];
@ -1134,6 +1141,7 @@ void enemy_draw_mirror(void *src,void *trg,int shade,int scale,int maxspace,int
//#pragma aux enemy_draw_mirror parm[ESI][EDI][EBX][EDX][EAX][ECX]
//clip je v poradi vpravo - vlevo (HiLo)
{
int32_t scr_linelen2 = GetScreenPitch();
word *picinfo = (word *)src;
word *screen = (word *)trg;
int xtable[800];

View file

@ -1,4 +1,4 @@
#include <skeldal_win.h>
#include <platform.h>
#include <bios.h>
#include <stdlib.h>
#include <string.h>
@ -758,27 +758,23 @@ static void MakeSaveGameDir(const char *name)
static int save_global_events()
{
FILE *f;
char *c;
concat(c,pathtable[SR_TEMP],_GLOBAL_ST );
f=fopen(c,"wb");
TMPFILE_WR *f;
f=temp_storage_create(_GLOBAL_ST);
if (f==NULL) return 1;
fwrite(GlobEventList,1,sizeof(GlobEventList),f);
fclose(f);
temp_storage_write(GlobEventList,1*sizeof(GlobEventList),f);
temp_storage_close_wr(f);
return 0;
}
static int load_global_events()
{
FILE *f;
char *c;
TMPFILE_RD *f;
memset(GlobEventList,0,sizeof(GlobEventList));
concat(c,pathtable[SR_TEMP],_GLOBAL_ST );
f=fopen(c,"rb");
f=temp_storage_open(_GLOBAL_ST);
if (f==NULL) return 1;
fread(GlobEventList,1,sizeof(GlobEventList),f);
fclose(f);
temp_storage_read(GlobEventList,1*sizeof(GlobEventList),f);
temp_storage_close_rd(f);
return 0;
}
@ -798,7 +794,6 @@ int save_game(int slotnum,char *gamename)
strncpy(gn,gamename,SAVE_NAME_SIZE);
if ((r=save_shops())!=0) return r;
if ((r=save_basic_info())!=0) return r;
save_leaving_places();
save_book();
save_global_events();
svf=fopen(ssn,"wb");
@ -841,7 +836,6 @@ int load_game(int slotnum)
if (svf==NULL) return 1;
fseek(svf,SAVE_NAME_SIZE,SEEK_CUR);
r=unpack_all_status(svf);
load_leaving_places();
fclose(svf);
open_story_file();
if (r>0)
@ -1420,7 +1414,7 @@ void wire_save_load(char save)
load_mode=save;
if (slot_list==NULL) read_slot_list();
curcolor=0;
bar(0,17,639,17+360);
bar32(0,17,639,17+360);
if (force_save) redraw_save();else redraw_load();
if (save==4) effect_show(NULL);else showview(0,0,0,0);
redraw_story_bar(cur_story_pos);

View file

@ -103,7 +103,7 @@ static __inline int rangrnd(int a, int b) {return rnd(b-a+1)+a;}
#define TX_LOAD 0
#define LODKA_POS (SCREEN_OFFLINE+301)*scr_linelen2+GetBuffer2nd()
#define LODKA_POS (SCREEN_OFFLINE+301)*GetBuffer2ndPitch()+GetBuffer2nd()
#define LODKA_SIZ 640*60
@ -119,7 +119,7 @@ static __inline int rangrnd(int a, int b) {return rnd(b-a+1)+a;}
#define NOSHADOW(x) ((x)|BGSWITCHBIT)
#define PICTURES "..\\OBRAZKY\\"
#define PICTURES ".." PATH_SEPARATOR "OBRAZKY" PATH_SEPARATOR
#define PIC_FADE_PAL_SIZE (10*512+6)
#define E_REFRESH 256 //udalost refresh scene
@ -325,7 +325,6 @@ static __inline int rangrnd(int a, int b) {return rnd(b-a+1)+a;}
#define SR_FONT 3
#define SR_MAP 4
#define SR_MUSIC 5
#define SR_TEMP 6
#define SR_BGRAFIKA 7
#define SR_ITEMS 8
#define SR_ENEMIES 9
@ -749,8 +748,6 @@ void check_players_place(char mode);
void add_leaving_place(int sector);
void save_leaving_places(void);
void load_leaving_places(void);
int set_leaving_place(void);
int get_leaving_place(char *level_name);
@ -1647,8 +1644,7 @@ void fletna_glob_add_note(char note);
char *find_map_path(char *filename); //vyhledava jmeno mapy v alternativnich cestach.
//Vysledny retezec je nutne uvolnit (free) !
FILE *enc_open(char *filename,ENCFILE *fil); //dekoduje a otevira TXT soubor (ENC)
void enc_close(ENCFILE *fil); //uzavira dekodovany soubor.
char *enc_open(char *filename); //dekoduje a otevira TXT soubor (ENC)
int load_string_list_ex(char ***list,char *filename);
int smlouvat_nakup(int cena,int ponuka,int posledni,int puvod,int pocet);

View file

@ -1,4 +1,4 @@
#include <skeldal_win.h>
#include <platform.h>
#include <stdio.h>
#include <stdlib.h>
#include <malloc.h>
@ -246,9 +246,10 @@ static char test_kriterii(void)
break;
default:
{
char c[200];
sprintf(c,"%s%s.TMP",pathtable[SR_TEMP],text);
hodn=!access(c,0);
hodn=temp_storage_find(text);
/* char c[200];
sprintf(c,"%s.TMP",text);
hodn=!access(c,0);*/
}
break;
}
@ -477,7 +478,7 @@ static char load_index_map(int index)
if (h->sektor!=lv && !labyrinth_find_path(h->sektor,lv,(SD_PLAY_IMPS | SD_SECRET),flp_validate2,NULL))
{
char c[20];
bott_disp_text(itoa(i,c,10));
bott_disp_text(int2ascii(i,c,10));
return 0;
}
if (!GlobEvent(MAGLOB_LEAVEMAP,viewsector,viewdir)) return 0;

View file

@ -1,4 +1,4 @@
#include <skeldal_win.h>
#include <platform.h>
#include <bios.h>
#include <stdlib.h>
#include <string.h>
@ -42,6 +42,8 @@ void create_frame(int x,int y,int xs,int ys,char clear)
word *line;
word *col;
int i;
int32_t scr_linelen2 = GetScreenPitch();
x-=VEL_RAMEC;
y-=VEL_RAMEC;
@ -75,7 +77,7 @@ void create_frame(int x,int y,int xs,int ys,char clear)
x+=VEL_RAMEC;y+=VEL_RAMEC;
xs=(xs-1)*VEL_RAMEC;
ys=(ys-1)*VEL_RAMEC;
bar(x,y,x+xs-1,y+ys-1);
bar32(x,y,x+xs-1,y+ys-1);
}
}
@ -650,13 +652,13 @@ static void radio_butts_draw(int x1,int y1,int x2,int y2,OBJREC *o)
{
int xx1=x1+2,yy1=y1+1,xx2=x1+size-2,yy2=y1+size-3,xxs=(xx1+xx2)>>1,yys=(yy1+yy2)>>1;
curcolor=0x0;
line(xx2+1,yy1+2,xxs+2,yy2+2);
line(xx1+1,yys+2,xxs+1,yy2+2);
line32(xx2+1,yy1+2,xxs+2,yy2+2);
line32(xx1+1,yys+2,xxs+1,yy2+2);
curcolor=RGB555(31,31,31);
line(xx2,yy1+1,xxs+1,yy2+1);
line(xx1,yys+1,xxs,yy2+1);
line(xx2,yy1,xxs+1,yy2);
line(xx1,yys,xxs,yy2);
line32(xx2,yy1+1,xxs+1,yy2+1);
line32(xx1,yys+1,xxs,yy2+1);
line32(xx2,yy1,xxs+1,yy2);
line32(xx1,yys,xxs,yy2);
}
draw_border(x1+1,y1+1,size-2,size-2,clt);
if (*params)
@ -908,6 +910,7 @@ static void skeldal_checkbox_draw(int x1,int y1,int x2,int y2,OBJREC *o)
word *obr;
char *data;
int phase;
int32_t scr_linelen2 = GetScreenPitch();
y2,x2;
data=(char *)o->data;
@ -1321,68 +1324,45 @@ char *find_map_path(char *filename)
return p;
}
FILE *enc_open(char *filename,ENCFILE *fil)
static char *load_file_to_string(FILE *f, int *size) {
fseek(f,0, SEEK_END);
int sz = ftell(f);
fseek(f, 0 , SEEK_SET);
char *c = getmem(sz+1);
fread(c,1,sz,f);
*size = sz;
c[sz] = 0;
return c;
}
char *enc_open(char *filename)
{
FILE *f,*g;
char *c,*d,*enc,*temp;
int i,j,last=0;
int size;
f=fopen(filename,"r");
if (f!=NULL)
{
fil->f=f;
fil->to_delete=NULL;
return f;
}
if (f!=NULL) {
char *c = load_file_to_string(f, &size);
fclose(f);
return c;
}
enc=alloca(strlen(filename)+5);
strcpy(enc,filename);
c=strrchr(enc,'.');
if (c==NULL) c=strchr(enc,0);
strcpy(c,".ENC");
f=fopen(enc,"rb");
if (f==NULL)
{
fil->f=NULL;
fil->to_delete=NULL;
return NULL;
}
d=strrchr(enc,'\\');if(d==NULL)d=enc;else d++;
temp=malloc((i=strlen(pathtable[SR_TEMP]))+strlen(d)+1);
strcpy(temp,pathtable[SR_TEMP]);
strcat(temp,d);
d=temp+i;
d=strrchr(d,'.');
strcpy(d,".dec");
g=fopen(temp,"wb");
if (g==NULL)
{
free(temp);
fclose(f);
fil->f=NULL;
fil->to_delete=NULL;
return NULL;
}
i=getc(f);
while (i!=EOF)
{
j=(last+i) & 0xff;
last=j;
putc(j,g);
i=getc(f);
}
if (f==NULL) return NULL;
char *encdata = load_file_to_string(f, &size);
fclose(f);
fclose(g);
f=fopen(temp,"r");
if (f==NULL)
{
free(temp);
fil->f=NULL;
fil->to_delete=NULL;
return NULL;
}
fil->f=f;
fil->to_delete=temp;
return f;
for (int i = 0; i < size; ++i) {
last = (last + encdata[i]) & 0xFF;
encdata[i] = last;
}
return encdata;
}
void enc_close(ENCFILE *fil)
@ -1397,11 +1377,42 @@ void enc_close(ENCFILE *fil)
int load_string_list_ex(TSTR_LIST *list,char *filename)
{
char *data = enc_open(filename);
if (data == NULL) return -1;
if (*list==NULL) *list=create_list(256);
char *d = data;
do {
while (*d && isspace(d)) ++d;
if (!*d) break;
if (*d && *d == ';') {
while (*d && *d != '\n') ++d;
} else {
int idx = 0;
int m = 1;
if (*d == '-') {m = -1;++d;}
while (*d >= '0' && *d <='9') {
idx = idx*10+(*d-'0');
++d;
}
if (idx == -1) break;
while (*d && isspace(d)) ++d;
char *b = d;
while (*d && *d != '\n' && *d != '\r') ++d;
if (*d) {*d = 0;++d;}
str_replace(list, idx, b);
}
} while (1);
free(data);
}
/*
char c[1024],*p;
int i,j,lin=0;
FILE *f;
ENCFILE fl;
f=enc_open(filename,&fl);
if (*list==NULL) *list=create_list(256);
if (f==NULL) return -1;
@ -1447,6 +1458,7 @@ int load_string_list_ex(TSTR_LIST *list,char *filename)
enc_close(&fl);
return 0;
}
*/
//------------------------------------------------------------
int smlouvat_nakup(int cena,int ponuka,int posledni,int puvod,int pocet)
@ -1508,7 +1520,7 @@ int smlouvat(int cena,int puvod,int pocet,int money,char mode)
cena,puvod,pocet,money;text[0]=0;text[1]=0;
add_window(170,130,300,150,H_IDESKA,3,20,20);
define(-1,10,15,1,1,0,label,texty[241]);
set_font(H_FBOLD,RGB555(31,31,31));define(-1,150,15,100,13,0,label,itoa(cena,buffer,10));
set_font(H_FBOLD,RGB555(31,31,31));define(-1,150,15,100,13,0,label,int2ascii(cena,buffer,10));
set_font(H_FBOLD,MSG_COLOR1);
define(-1,10,30,1,1,0,label,texty[238]);
define(10,150,30,100,13,0,input_line,8);property(def_border(5,BAR_COLOR),NULL,NULL,0);set_default("");
@ -1579,7 +1591,7 @@ void show_jrc_logo(char *filename)
int cntr,cdiff,cpalf,ccc;
change_music("?");
curcolor=0;bar(0,0,639,479);
curcolor=0;bar32(0,0,639,479);
showview(0,0,0,0);sleep_ms(1000);
concat(s,pathtable[SR_VIDEO],filename);
if (open_pcx(s,A_8BIT,&pcx)) return;
@ -1628,7 +1640,7 @@ void show_jrc_logo(char *filename)
mix_back_sound(0);
}
while (cdiff<SHOWDELAY && !_bios_keybrd(_KEYBRD_READY));
curcolor=0;bar(0,0,639,479);
curcolor=0;bar32(0,0,639,479);
showview(0,0,0,0);
free(pcx);
}

View file

@ -1,4 +1,4 @@
#include <skeldal_win.h>
#include <platform.h>
#include <stdio.h>
#include <stdlib.h>
#include <malloc.h>
@ -1223,6 +1223,7 @@ void build_items_called(void **p,int32_t *s)
void display_items_wearing(THUMAN *h)
{
int it;
int32_t scr_linelen2 = GetScreenPitch();
put_picture(4,TOP_OFS,ablock(H_IOBLOUK));
zneplatnit_block(h-postavy+H_POSTAVY);
enemy_draw(ablock(h-postavy+H_POSTAVY),GetScreenAdr()+HUMAN_X+HUMAN_Y*scr_linelen2,6,320,HUMAN_Y,640*65536);
@ -1262,7 +1263,7 @@ static void percent_bar(int x,int y,int xs,int ys,int val,int max,char *popis)
char s[25];
memcpy(&clt,def_border(3,0),sizeof(clt));
bar(x,y,x+xs*val/max,ys+y);
bar32(x,y,x+xs*val/max,ys+y);
show_textured_button(x-2,y-2,xs+5,ys+5,0,&clt);
set_aligned_position(x,y-5,0,2,popis);
outtext(popis);
@ -1526,8 +1527,8 @@ void redraw_inventory()
update_mysky();
schovej_mysku();
curcolor=0;
bar(0,16,30,16+360);
bar(620,16,640,16+360);
bar32(0,16,30,16+360);
bar32(620,16,640,16+360);
if (inv_view_mode==0 && ~human_selected->stare_vls[VLS_KOUZLA] & SPL_DEMON && ~human_selected->vlastnosti[VLS_KOUZLA] & SPL_STONED) display_items_in_inv(human_selected);
else inv_display_vlastnosti();
display_items_wearing(human_selected);
@ -2859,7 +2860,7 @@ void enter_shop(int shopid)
unwire_proc();
cur_shop=shop_list[i];
curcolor=0;
bar(0,0,639,479);
bar32(0,0,639,479);
rebuild_keepers_items();
bott_draw(1);
shop_sector=viewsector;
@ -2970,43 +2971,41 @@ void reroll_all_shops()
char save_shops()
{
FILE *f;
TMPFILE_WR *f;
char *c;
int res=0;
SEND_LOG("(SHOP) Saving shops...",0,0);
if (max_shops==0 || shop_hacek==NULL) return 0;
concat(c,pathtable[SR_TEMP],_SHOP_ST);
f=fopen(c,"wb");
f = temp_storage_create(_SHOP_ST);
if (f==NULL) return 1;
fwrite(&max_shops,1,sizeof(max_shops),f);
fwrite(&shop_hacek_size,1,sizeof(shop_hacek_size),f);
res=(fwrite(shop_hacek,1,shop_hacek_size,f)!=(unsigned)shop_hacek_size);
fclose(f);
temp_storage_write(&max_shops,1*sizeof(max_shops),f);
temp_storage_write(&shop_hacek_size,1*sizeof(shop_hacek_size),f);
temp_storage_write(shop_hacek,1*shop_hacek_size,f);
temp_storage_close_wr(f);
return res;
}
char load_saved_shops()
{
FILE *f;
TMPFILE_RD *f;
char *c;
int res=0;
int i=0,j=0;
SEND_LOG("(SHOP) Loading saved shops...",0,0);
concat(c,pathtable[SR_TEMP],_SHOP_ST);
f=fopen(c,"rb");
f=temp_storage_open(_SHOP_ST);
if (f==NULL) return 0;
fread(&i,1,sizeof(max_shops),f);
fread(&j,1,sizeof(shop_hacek_size),f);
temp_storage_read(&i,1*sizeof(max_shops),f);
temp_storage_read(&j,1*sizeof(shop_hacek_size),f);
if (i!=max_shops || j!=shop_hacek_size)
{
fclose(f);
temp_storage_close_rd(f);
return 0;
}
res=(fread(shop_hacek,1,shop_hacek_size,f)!=(unsigned)shop_hacek_size);
fclose(f);
res=(temp_storage_read(shop_hacek,1*shop_hacek_size,f)!=(unsigned)shop_hacek_size);
temp_storage_close_rd(f);
rebuild_shops();
return res;
}

View file

@ -1,4 +1,4 @@
#include <skeldal_win.h>
#include <platform.h>
/*
Popis jazyka pro psani textu do knihy
@ -286,25 +286,25 @@ static void break_line()
save_buffer();
}
static char read_set(FILE *txt,char *var,char *set)
static char read_set(TMPFILE_RD *txt,char *var,char *set)
{
int c;
char *cc;
char d;
fscanf(txt,"%[^=]%c",var,&d);
temp_storage_scanf(txt,"%[^=]%c",var,&d);
do
c=fgetc(txt);
c=temp_storage_getc(txt);
while (c<33);
if (c=='"') fscanf(txt,"%[^\"]%c%c",set,&d,&d);
else if (c=='\'') fscanf(txt,"%[^']%c%c",set,&d,&d);
if (c=='"') temp_storage_scanf(txt,"%[^\"]%c%c",set,&d,&d);
else if (c=='\'') temp_storage_scanf(txt,"%[^']%c%c",set,&d,&d);
else
{
ungetc(c,txt);
fscanf(txt,"%[^> ]%c",set,&d);
temp_storage_ungetc(txt);
temp_storage_scanf(txt,"%[^> ]%c",set,&d);
}
while(c<33 && c!=EOF) c=fgetc(txt);
if (c!='>') ungetc(c,txt);
while(c<33 && c!=EOF) c=temp_storage_getc(txt);
if (c!='>') temp_storage_ungetc(txt);
cc=strchr(var,0);
while (cc!=var)
{
@ -375,14 +375,14 @@ static void insert_picture(char *filename,int align,int line,int lsize)
str_add(&all_text,write_buff);
}
static char read_tag(FILE *txt)
static char read_tag(TMPFILE_RD *txt)
{
char c,var[256],set[256];
int i;
i=fscanf(txt,"%[^> ] %c",var,&c);
while(c<33 && i!=EOF) c=i=fgetc(txt);
if (c!='>') ungetc(c,txt);
i=temp_storage_scanf(txt,"%[^> ] %c",var,&c);
while(c<33 && i!=EOF) c=i=temp_storage_getc(txt);
if (c!='>') temp_storage_ungetc(txt);
strupr(var);
if (!strcmp(var,PARAGRAPH))
{
@ -432,15 +432,15 @@ static char read_tag(FILE *txt)
}
static char skip_section(FILE *txt)
static char skip_section(TMPFILE_RD *txt)
{
int c;
char end=1;
c=fgetc(txt);
c=temp_storage_getc(txt);
while (c!=']' && c!=EOF)
{
c=fgetc(txt);
c=temp_storage_getc(txt);
end=0;
}
if (c==EOF) end=1;
@ -456,9 +456,9 @@ void prekodovat(char *c)
}
}
static void read_text(FILE *txt)
static void read_text(TMPFILE_RD *txt)
{
int i;
int i = 0;
int xs;
char ss[2]=" ";
char wsp=1;
@ -468,7 +468,7 @@ static void read_text(FILE *txt)
xs=0;
do
{
i=fgetc(txt);
i=temp_storage_getc(txt);
if (i==EOF) break;
if (i<32) i=32;
if (i=='<')
@ -492,7 +492,7 @@ static void read_text(FILE *txt)
wsp=1;
}
else wsp=0;
if (i=='&') i=fgetc(txt);
if (i=='&') i=temp_storage_getc(txt);
if (winconv && i>137) i=xlat_table[i-138];
ss[0]=i;
xs+=text_width(ss);
@ -507,26 +507,33 @@ static void read_text(FILE *txt)
while (1);
}
void seek_section(FILE *txt,int sect_number)
static void seek_section(TMPFILE_RD *txt,int sect_number)
{
int c=0,i;
winconv=0;
do
{
while (c!='[' && c!=EOF) c=fgetc(txt);
while (c!='[' && c!=EOF) c=temp_storage_getc(txt);
if (c=='[')
{
i=-2;
fscanf(txt,"%d",&i);
c = temp_storage_getc(txt);
if (c>='0' && c<='9') {
i = 0;
while (c>='0' && c<='9') {
i = i * 10 +(c - '0');
c = temp_storage_getc(txt);
}
}
if (i==sect_number)
{
c=fgetc(txt);
c=temp_storage_getc(txt);
while(c!=']')
{
if (c=='W' || c=='w') winconv=1;
if (c=='K' || c=='k') winconv=0;
c=fgetc(txt);
c=temp_storage_getc(txt);
}
return;
}
@ -545,17 +552,22 @@ void seek_section(FILE *txt,int sect_number)
void add_text_to_book(char *filename,int odst)
{
FILE *txt;
ENCFILE fl;
char *txt;
TMPFILE_RD *fl;
set_font(H_FKNIHA,NOSHADOW(0));
if (all_text==NULL) all_text=create_list(256);
txt=enc_open(filename,&fl);
txt=enc_open(filename);
if (txt==NULL) return;
seek_section(txt,odst);
read_text(txt);
const char *bookenc = "__bookenc";
temp_storage_store(bookenc, txt, strlen(txt));
fl = temp_storage_open(bookenc);
seek_section(fl,odst);
read_text(fl);
next_line(1000);
enc_close(&fl);
free(txt);
temp_storage_close_rd(fl);
temp_storage_delete(bookenc);
}
static char *displ_picture(char *c)
@ -563,6 +575,8 @@ static char *displ_picture(char *c)
char *d;
int x,y,hn,z,ln,sl;
short *sh;
int32_t scr_linelen2 = GetScreenPitch();
d=write_buff;
while (*c!=':') *d++=*c++;
@ -675,41 +689,47 @@ int count_pages()
void save_book()
{
char *c;
FILE *f;
TMPFILE_WR *f;
int i,ss;
char *tx;
if (all_text==NULL) return;
concat(c,pathtable[SR_TEMP],BOOK_FILE);
f=fopen(c,"w");if (f==NULL) return;
f = temp_storage_create(BOOK_FILE);
i=0;
ss=str_count(all_text);
while (i<ss && (tx=all_text[i++])!=NULL)
{
fputs(tx,f);
fputc('\n',f);
temp_storage_write(tx,strlen(tx), f);
temp_storage_write("\n",1, f);
}
fclose(f);
temp_storage_close_wr(f);
}
void load_book()
{
char *c;
FILE *f;
char tx[512];
TMPFILE_RD *f;
if (all_text!=NULL) release_list(all_text);
all_text=NULL;
concat(c,pathtable[SR_TEMP],BOOK_FILE);
f=fopen(c,"r");if (f==NULL) return;
all_text=create_list(256);
while (fgets(tx,510,f)!=NULL)
{
char *c;
c=strchr(tx,0);c--;*c=0;
str_add(&all_text,tx);
}
fclose(f);
int sz = temp_storage_find(BOOK_FILE);
if (sz < 0) return;
char *data = getmem(sz);
temp_storage_retrieve(BOOK_FILE, data, sz);
int b = 0;
int e;
for (e = 0; e < sz; ++e) {
if (data[e] == '\n') {
data[e] = 0;
str_add(&all_text, data+b);
b = e+1;
}
}
if (b < e) {
str_add(&all_text, data+b);
}
free(data);
}

View file

@ -1,4 +1,4 @@
#include <skeldal_win.h>
#include <platform.h>
#include <stdio.h>
#include <stdlib.h>
#include <bgraph.h>

View file

@ -1,4 +1,4 @@
#include <skeldal_win.h>
#include <platform.h>
#include <stdio.h>
#include <stdlib.h>
#include <malloc.h>
@ -569,7 +569,7 @@ static int ma_play_anim(char *filename,char cls)
curcolor=0;
if (cls)
{
bar(0,0,639,479);
bar32(0,0,639,479);
showview(0,0,0,0);
}
mute_all_tracks(1);

View file

@ -1,4 +1,4 @@
#include <skeldal_win.h>
#include <platform.h>
#include <stdio.h>
#include <stdlib.h>
#include <malloc.h>
@ -223,6 +223,7 @@ static void zobraz_podle_masky(char barva,char anim)
{
char *maska;
word *data;
int32_t scr_linelen2 = GetScreenPitch();
word *obr=GetScreenAdr()+300*scr_linelen2+220;
word xs,ys;
@ -341,7 +342,7 @@ int enter_menu(char open)
}
update_mysky();
schovej_mysku();
curcolor=0;bar(0,0,639,479);
curcolor=0;bar32(0,0,639,479);
put_picture(0,0,ablock(H_MENU_BAR));
put_picture(0,56,ablock(H_ANIM));
ukaz_mysku();
@ -364,7 +365,8 @@ int enter_menu(char open)
char *get_next_title(signed char control,char *filename)
{
static FILE *titles=NULL;
/*
static TMPFILE_RD *titles=NULL;
static ENCFILE fl;
static char buffer[81];
char *path,*c;
@ -372,11 +374,11 @@ char *get_next_title(signed char control,char *filename)
switch(control)
{
case 1:concat(path,pathtable[SR_MAP],filename);
titles=enc_open(path,&fl);
titles=enc_open(path);
if (titles==NULL)
{
concat(path,pathtable[SR_DATA],filename);
titles=enc_open(path,&fl);
titles=enc_open(path);
if (titles==NULL)
{
char popis[300];
@ -393,6 +395,7 @@ char *get_next_title(signed char control,char *filename)
case -1:if (titles!=NULL)enc_close(&fl);
break;
}
*/
return NULL;
}
@ -448,7 +451,7 @@ static int insert_next_line(int ztrata)
if (ll<title_line) ll=title_line;
curcolor=BGSWITCHBIT;
charcolors[0]=RGB555(0,0,1);
bar(0,360+ztrata,639,360+ztrata+ll);
bar32(0,360+ztrata,639,360+ztrata+ll);
switch(title_mode)
{
case TITLE_TEXT:
@ -468,6 +471,7 @@ static int insert_next_line(int ztrata)
static void scan_lines(word *buffer,int start,int poc)
{
int first, last,i,pocet=poc;
int32_t scr_linelen2 = GetScreenPitch();
word *buf;
while (pocet--)
{
@ -506,6 +510,7 @@ static void get_max_extend(int *l,int *r)
void titles(va_list args)
//#pragma aux titles parm[]
{
int32_t scr_linelen2 = GetScreenPitch();
char send_back=va_arg(args,int);
char *textname=va_arg(args,char *);
@ -520,8 +525,8 @@ void titles(va_list args)
if (get_next_title(1,textname)==NULL) return;
schovej_mysku();
speedscroll=4;
curcolor=BGSWITCHBIT ; bar(0,0,639,479);
RedirectScreenBufferSecond();bar(0,0,639,479);RestoreScreen();
curcolor=BGSWITCHBIT ; bar32(0,0,639,479);
RedirectScreenBufferSecond();bar32(0,0,639,479);RestoreScreen();
memset(title_lines,0,sizeof(title_lines));
def_handle(H_PICTURE,"titulky.pcx",pcx_15bit_decomp,SR_BGRAFIKA);
alock(H_PICTURE);
@ -550,7 +555,7 @@ void titles(va_list args)
//showview(l,60,r-l+1,360);
showview(0,60,639,360);
buff+=scr_linelen2*359;
memcpy(buff,buff+scr_linelen2*skip,40*scr_linelen);
memcpy(buff,buff+scr_linelen2*skip,2*40*scr_linelen2);
showview(0,0,640,40);
task_wait_event(E_TIMER);
counter+=skip;
@ -595,7 +600,7 @@ void konec_hry()
schovej_mysku();
curcolor=0;
bar(0,0,639,479);
bar32(0,0,639,479);
effect_show(NULL);
create_playlist(texty[205]);
change_music(get_next_music_from_playlist());
@ -611,7 +616,7 @@ void konec_hry()
if (is_running(task_id)) term_task(task_id);
change_music("?");
curcolor=0;
bar(0,0,639,479);
bar32(0,0,639,479);
ukaz_mysku();
effect_show(NULL);
timer=get_timer_value();

View file

@ -1,4 +1,4 @@
#include <skeldal_win.h>
#include <platform.h>
#include <stdio.h>
#include <stdlib.h>
#include <malloc.h>
@ -45,7 +45,7 @@
extern TSTR_LIST texty_v_mape;
static TSTR_LIST leaving_places=NULL;
char pass_zavora=0;
@ -129,9 +129,9 @@ static void preload_percent(int cur,int max)
int pos;
pos=cur*640/max;
if (pos>640) pos=640;
curcolor=RGB555(16,16,16);hor_line(0,476,pos);
curcolor=RGB555(8,8,8);hor_line(0,477,pos);
curcolor=RGB555(31,31,31);hor_line(0,475,pos);
curcolor=RGB555(16,16,16);hor_line32(0,476,pos);
curcolor=RGB555(8,8,8);hor_line32(0,477,pos);
curcolor=RGB555(31,31,31);hor_line32(0,475,pos);
showview(0,460,640,20);
do_events();
}
@ -181,7 +181,7 @@ char *pripona(char *filename,char *pripona)
buff=getmem(strlen(filename)+strlen(pripona)+2);
strcpy(buff,filename);
c=strrchr(buff,'\\');
c=strrchr(buff,PATH_SEPARATOR_CHR);
if (c==NULL) c=buff;
c=strchr(c,'.');
if (c!=NULL) *c=0;
@ -372,8 +372,7 @@ int load_map(char *filename)
suc=load_level_texts(d);free(d);
if (!suc && level_texts!=NULL) create_playlist(level_texts[0]);
init_tracks();
play_next_music(&d);
change_music(d);
change_music(get_next_music_from_playlist());
for(r=0;r<mapsize*4;r++) flag_map[r]=(char)map_sides[r].flags;
if (!doNotLoadMapState && load_map_state()==-2)
{
@ -388,26 +387,9 @@ int load_map(char *filename)
void add_leaving_place(int sector)
{
if (leaving_places==NULL) leaving_places=create_list(16);
add_field_num(&leaving_places,level_fname,sector);
}
void save_leaving_places(void)
{
char *s;
if (leaving_places==NULL) return;
concat(s,pathtable[SR_TEMP],"_LPLACES.TMP");
save_config(leaving_places,s);
}
void load_leaving_places(void)
{
char *s;
if (leaving_places!=NULL) release_list(leaving_places);
concat(s,pathtable[SR_TEMP],"_LPLACES.TMP");
leaving_places=read_config(s);
char *s;
concat(s,level_fname, ".lplace");
temp_storage_store(s, &sector, sizeof(sector));
}
int set_leaving_place(void)
@ -417,16 +399,13 @@ int set_leaving_place(void)
int get_leaving_place(char *level_name)
{
int s=0,i;
if (leaving_places==NULL) return 0;
if (get_num_field(leaving_places,level_name,&s) ||
~map_coord[s].flags & 1 || map_sectors[s].sector_type!=S_LEAVE || s==0)
{
for (i=1;i<mapsize;i++) if (map_sectors[i].sector_type==S_LEAVE && map_coord[i].flags & 0x1)
return i;
return s;
}
return s;
char *s;
concat(s,level_fname, ".lplace");
int sector;
if (temp_storage_retrieve(s, &sector, sizeof(sector))<0) {
return 0;
}
return sector;
}
@ -1849,7 +1828,7 @@ void sleep_players(va_list args)
insleep=1;
update_mysky();
schovej_mysku();
curcolor=0;bar(0,17,639,360+16);
curcolor=0;bar32(0,17,639,360+16);
send_message(E_ADD,E_KEYBOARD,key_break_sleep);
ukaz_mysku();
showview(0,0,0,0);
@ -1868,7 +1847,7 @@ void sleep_players(va_list args)
update_mysky();
schovej_mysku();
bott_draw(0);
curcolor=0;bar(0,120,639,140);
curcolor=0;bar32(0,120,639,140);
sprintf(s,texty[71],hours++);
set_font(H_FBOLD,RGB555(31,31,0));
set_aligned_position(320,130,1,1,s);outtext(s);

View file

@ -1,4 +1,4 @@
#include <skeldal_win.h>
#include <platform.h>
#include <stdio.h>
#include <stdlib.h>
#include <malloc.h>

View file

@ -1,4 +1,4 @@
#include <skeldal_win.h>
#include <platform.h>
#include <assert.h>
#include <stdarg.h>
#include <bios.h>
@ -27,6 +27,7 @@
#include "engine1.h"
#include "wizard.h"
#include "version.h"
#include "default_font.h"
#include <unistd.h>
#define CONFIG_NAME SKELDALINI
@ -36,18 +37,18 @@
#define ERR_GENERAL 1
char def_path[]="";
char graph_path[]="graphics\\";
char basc_graph[]="graphics\\basic\\";
char item_graph[]="graphics\\items\\";
char sample_path[]="samples\\";
char font_path[]="font\\";
char map_path[]="maps\\";
char music_path[]="music\\";
char org_music_path[]="music\\";
char graph_path[]="graphics" PATH_SEPARATOR;
char basc_graph[]="graphics" PATH_SEPARATOR "basic" PATH_SEPARATOR;
char item_graph[]="graphics" PATH_SEPARATOR "items" PATH_SEPARATOR;
char sample_path[]="samples" PATH_SEPARATOR;
char font_path[]="font" PATH_SEPARATOR;
char map_path[]="maps" PATH_SEPARATOR;
char music_path[]="music" PATH_SEPARATOR;
char org_music_path[]="music" PATH_SEPARATOR;
char temp_path[]="?";
char enemies_path[]="graphics\\enemies\\";
char video_path[]="video\\";
char dialogs_path[]="graphics\\dialogs\\";
char enemies_path[]="graphics" PATH_SEPARATOR "enemies" PATH_SEPARATOR;
char video_path[]="video" PATH_SEPARATOR;
char dialogs_path[]="graphics" PATH_SEPARATOR "dialogs" PATH_SEPARATOR;
char saves_path[]="";
char work_path[]="";
char cd_path[]="";
@ -311,6 +312,8 @@ int set_video(int mode)
{
int er=0;
int32_t scr_linelen2 = GetScreenPitch();
report_mode(1);
er=initmode_dx(windowed,windowedzoom,monitor,refresh);
/*
@ -345,20 +348,13 @@ int set_video(int mode)
default:er=-1;
}*/
screen_buffer_size=scr_linelen*480;
screen_buffer_size=scr_linelen2*2*480;
return er;
}
int ask_video()
{
int c;
printf("\nJaky videomode?:\n"
" 1) 640x480x256 \n"
" 2) 640x480xHiColor \n");
c=_bios_keybrd(_KEYBRD_READ)>>8;
if (c==1) exit(0);
return c-1;
}
void purge_temps(char) {
temp_storage_clear();
}
void pcx_fade_decomp(void **p,int32_t *s)
{
@ -455,8 +451,10 @@ void set_background(void **p,int32_t *s)
char *pic;
int counter;
if (!bgr_handle) return;
if (bgr_distance==-1) return;
int32_t scr_linelen2 = GetScreenPitch();
data=ablock(bgr_handle);
*s=scr_linelen2*360*2;
ptr=*p=getmem(*s);
@ -555,14 +553,6 @@ void music_init()
set_snd_effect(SND_GFX,init_gfx_vol);
set_snd_effect(SND_MUSIC,init_music_vol);
path=plugins_path;
if (path==0 || path[0]==0)
path=AutodetectWinAmp();
if (path!=0 && path[0]!=0)
{
SEND_LOG("(SOUND) Installing plugins, path: %s",path,0);
init_winamp_plugins(path);
if (path!=plugins_path) free(path);
}
SEND_LOG("(SOUND) SOUND_DONE Sound Engine should work now",0,0);
}
@ -863,6 +853,7 @@ void global_kbd(EVENT_MSG *msg,void **usr)
if (msg->msg==E_KEYBOARD)
{
c=va_arg(msg->data,int)>>8;
int32_t scr_linelen2 = GetScreenPitch();
if (c==';') save_dump(GetScreenAdr(), DxGetResX(), DxGetResY(), scr_linelen2);
}
return;
@ -957,7 +948,7 @@ char device_error(int chyba,char disk,char info)
static void patch_error(int err)
{
position(0,460);
curcolor=0;bar(0,460,640,479);
curcolor=0;bar32(0,460,640,479);
memcpy(charcolors,flat_color(RGB555(31,31,31)),sizeof(charcolors));
curfont=boldcz;
switch(err)
@ -1227,7 +1218,10 @@ static void config_skeldal(const char *line)
maxi=strlen(c);
data=alloca(maxi+1);
strcpy(data,c);
if (data[maxi-1]=='\n') data[maxi-1]=0;
while (maxi && (isspace(data[maxi-1]))) {
--maxi;
data[maxi]=0;
}
maxi=(sizeof(sinit)/sizeof(INIS));
for(i=0;i<maxi;i++) if (comcmp(line,sinit[i].heslo)) break;
if (i==maxi)
@ -1342,7 +1336,7 @@ void play_anim(int anim_num)
}
else titl=NULL;
set_title_list(titl);set_font(H_FBIG,RGB(200,200,200));
curcolor=0;bar(0,0,639,459);
curcolor=0;bar32(0,0,639,459);
showview(0,0,0,0);
play_movie_seq(s,60);
set_title_list(NULL);if (titl!=NULL) release_list(titl);
@ -1615,7 +1609,7 @@ static void start(va_list args)
exit_wait=1;
}
break;
case V_UVOD:bar(0,0,639,479);goto zde;break;
case V_UVOD:bar32(0,0,639,479);goto zde;break;
case V_OBNOVA_HRY:load_saved_game();break;
case V_AUTORI:run_titles(NULL);break;
}
@ -1655,7 +1649,7 @@ void main(int argc,char *argv[])
c=getcwd(NULL,0);
pathtable[SR_SAVES]=getmem(strlen(c)+2);
strcpy(pathtable[SR_SAVES],c);
strcat(pathtable[SR_SAVES],"\\");
strcat(pathtable[SR_SAVES],PATH_SEPARATOR);
free(c);
SEND_LOG("(GAME) Save directory sets to '%s'",pathtable[SR_SAVES],0);
// set_verify(0);

View file

@ -1,4 +1,4 @@
#include <skeldal_win.h>
#include <platform.h>
#include <stdio.h>
#include <stdlib.h>
#include <mem.h>

View file

@ -1,4 +1,4 @@
#include <skeldal_win.h>
#include <platform.h>
#include <bios.h>
#include <stdio.h>
#include <stdlib.h>
@ -1321,6 +1321,7 @@ void fill_rune(char *d,int i)
for(y=378;y<480;y++)
{
word *z;
int32_t scr_linelen2 = GetScreenPitch();
z=GetScreenAdr()+y*scr_linelen2;
for(x=520;x<640;x++)
if (*dd++==i) z[x]=z[x]-((z[x] & RGB555(28,28,28))>>2);
@ -1376,6 +1377,7 @@ void display_power_bar(char drw)
int coords[][2]={{20,11},{20,41},{20,71}};
int i;
int32_t scr_linelen2 = GetScreenPitch();
schovej_mysku();
put_picture(520,378,ablock(H_POWERBAR));
for(i=0;i<3;i++)
@ -1662,6 +1664,7 @@ void souboje_redrawing()
void souboje_stisknout(int d)
{
int32_t scr_linelen2 = GetScreenPitch();
update_mysky();
schovej_mysku();
d--;

View file

@ -1,5 +1,5 @@
//Toto je hlavni soubor specialnich procedur pro hru BRANY SKELDALU
#include <skeldal_win.h>
#include <platform.h>
#include <stdio.h>
#include <stdlib.h>
#include <event.h>
@ -233,6 +233,8 @@ static __inline int toInt(float fval)
static void OtocObrazPodleMatice(float mx[3][2], word *picture)
{
int32_t scr_linelen2 = GetScreenPitch();
word *trg=GetScreenAdr()+17*scr_linelen2;
int x,y;
picture+=6;

View file

@ -1,3 +1,5 @@
#include <cstdarg>
#include <cstdio>
#include <map>
#include <string>
#include <string_view>
@ -13,6 +15,8 @@ typedef struct _temp_storage_file_wr {
typedef struct _temp_storage_file_rd {
std::basic_string_view<uint8_t> _data;
int skp = 0;
int scan_ret = 0;
} TMPFILE_RD;
using FileSystem = std::map<std::string, std::vector<uint8_t>, std::less<> >;
@ -94,3 +98,38 @@ void temp_storage_skip(TMPFILE_RD *f, int bytes) {
auto p = d.substr(0,bytes);
d = d.substr(p.size());
}
void temp_storage_delete(const char *name) {
temp_fsystem.erase(std::string(name));
}
int temp_storage_getc(TMPFILE_RD *f) {
if (f->_data.empty()) return -1;
int r = f->_data[0];
f->_data = f->_data.substr(1);
return r;
}
void temp_storage_internal_begin_scanf(TMPFILE_RD *f, const char *format, ...) {
if (f->_data.empty()) {
f->scan_ret = -1;
}
va_list lst;
va_start(lst, format);
f->scan_ret = vsscanf(reinterpret_cast<const char *>(f->_data.data()), format, lst);
va_end(lst);
}
int *temp_storage_internal_skip_ptr(TMPFILE_RD *f) {
return &f->skp;
}
int temp_storage_internal_end_scanf(TMPFILE_RD *f) {
temp_storage_skip(f, f->skp);
return f->scan_ret;
}
void temp_storage_ungetc(TMPFILE_RD *f) {
f->_data = std::basic_string_view<uint8_t>(f->_data.data()-1, f->_data.size()+1);
}

View file

@ -17,10 +17,21 @@ typedef struct _temp_storage_file_wr TMPFILE_WR;
TMPFILE_RD *temp_storage_open(const char *name);
TMPFILE_WR *temp_storage_create(const char *name);
TMPFILE_WR *temp_storage_append(const char *name);
void temp_storage_delete(const char *name);
void temp_storage_close_rd(TMPFILE_RD *f);
void temp_storage_close_wr(TMPFILE_WR *f);
int temp_storage_getc(TMPFILE_RD *f);
void temp_storage_ungetc(TMPFILE_RD *f);
void temp_storage_write(const void *data, uint32_t size, TMPFILE_WR *f);
uint32_t temp_storage_read(void *data, uint32_t size, TMPFILE_RD *f);
void temp_storage_skip(TMPFILE_RD *f, int bytes);
int *temp_storage_internal_skip_ptr(TMPFILE_RD *f);
void temp_storage_internal_begin_scanf(TMPFILE_RD *f, const char *format, ... );
int temp_storage_internal_end_scanf(TMPFILE_RD *f);
#define temp_storage_scanf(f, format, ...) (temp_storage_internal_begin_scanf(f, format "%n", __VA_ARGS__, temp_storage_internal_skip_ptr(f)),temp_storage_internal_end_scanf(f))

View file

@ -1,4 +1,4 @@
#include <skeldal_win.h>
#include <platform.h>
#include <bios.h>
#include <stdlib.h>
#include <ctype.h>

View file

@ -39,7 +39,7 @@ char disk_finder()
}
char find_path(char *path)
{
{SEPARATOR
char *oldpath;
unsigned pismeno='C';

174
libs/base64.h Normal file
View file

@ -0,0 +1,174 @@
#pragma once
#include <iterator>
class base64_t {
public:
constexpr base64_t(const char *charset, char terminator):_terminator(terminator) {
for (int i = 0; i < 64; ++i) _charset[i] = charset[i];
for (char &c: _charmap) c=-1;
for (unsigned int i = 0; i < 64;++i) {
int c = _charset[i]-32;
_charmap[c] = static_cast<char>(i);
}
}
template<typename InIter, typename OutIter>
constexpr OutIter encode(InIter beg, InIter end, OutIter out) const {
unsigned int remain = 0;
unsigned int accum = 0;
while (beg != end) {
accum = static_cast<unsigned char>(*beg);
++beg;
if (beg == end) {
remain = 2;
break;
}
accum = (accum << 8) | static_cast<unsigned char>(*beg);
++beg;
if (beg == end) {
remain = 1;
break;
}
accum = (accum << 8) | static_cast<unsigned char>(*beg);
++beg;
*out = _charset[accum >> 18];
++out;
*out = _charset[(accum >> 12) & 0x3F];
++out;
*out = _charset[(accum >> 6) & 0x3F];
++out;
*out = _charset[accum & 0x3F];
++out;
accum = 0;
}
switch (remain) {
case 2: *out = _charset[accum >> 2];
++out;
*out = _charset[(accum << 4) & 0x3F];
++out;
if (_terminator) {
*out = _terminator;
++out;
*out = _terminator;
++out;
}
break;
case 1: *out = _charset[accum >> 10];
++out;
*out = _charset[(accum >> 4) & 0x3F];
++out;
*out = _charset[(accum << 2) & 0x3F];
++out;
if (_terminator) {
*out = _terminator;
++out;
}
break;
default:
break;
}
return out;
}
template<typename InIter, typename OutIter>
constexpr OutIter decode(InIter beg, InIter end, OutIter out) const {
unsigned int accum = 0;
unsigned int remain = 0;
char c = 0;
auto load_next = [&]() {
do {
if (beg == end || *beg == _terminator) return false;
auto val = static_cast<unsigned int>(*beg)-32;
++beg;
if (val < 96) {
c = _charmap[val];
if (c != -1) return true;
}
//skip invalid characters
} while (true);
};
while (load_next()) {
accum = c;
if (!load_next()) {
remain = 3;
break;
}
accum = (accum << 6) | c;
if (!load_next()) {
remain = 2;
break;
}
accum = (accum << 6) | c;
if (!load_next()) {
remain = 1;
break;
}
accum = (accum << 6) | c;
*out = static_cast<char>(accum >> 16);
++out;
*out = static_cast<char>((accum >> 8) & 0xFF);
++out;
*out = static_cast<char>(accum & 0xFF);
++out;
}
switch (remain) {
default: break;
case 2: *out = static_cast<char>(accum >> 4);
++out;
break;
case 1:*out = static_cast<char>(accum >> 10);
++out;
*out = static_cast<char>((accum >> 2) & 0xFF);
++out;
break;
}
return out;
}
protected:
char _charset[64] = {};
char _charmap[96] = {};
char _terminator;
};
inline constexpr auto base64 = base64_t{"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",'='};
inline constexpr auto base64url = base64_t{"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",'\0'};
template<std::size_t N>
class binary_data {
public:
static constexpr std::size_t buff_size = (N+3)*3/4;
constexpr binary_data(const char *txt) {
auto res =base64.decode(txt, txt+N, data);
sz = res - data;
}
constexpr operator std::basic_string_view<unsigned char>() const {
return {data, sz};
}
operator std::string_view() const {
return {reinterpret_cast<const char *>(data), sz};
}
constexpr auto begin() const {return data;}
constexpr auto end() const {return data+sz;}
constexpr std::size_t size() const {return sz;}
protected:
std::size_t sz = 0;
unsigned char data[buff_size]= {};
};
template<std::size_t N>
binary_data(const char (&)[N]) -> binary_data<N>;

View file

@ -1,4 +1,4 @@
#include <skeldal_win.h>
#include <platform.h>
// toto je include soubor, jenz je pouzit v knihovne GUI.C
#include "types.h"
@ -111,7 +111,7 @@ void button_draw(int x1,int y1,int x2,int y2,OBJREC *o)
CTL3D x;
char w;
bar(x1,y1,x2,y2);
bar32(x1,y1,x2,y2);
highlight(&x,o->color);
w=*(char *)o->data;
x.bsize=2-w;
@ -126,7 +126,7 @@ void button_draw2(int x1,int y1,int x2,int y2,OBJREC *o)
CTL3D x;
char w;
bar(x1,y1,x2,y2);
bar32(x1,y1,x2,y2);
highlight(&x,o->color);
w=*(char *)o->data;
x.bsize=1;
@ -134,8 +134,8 @@ void button_draw2(int x1,int y1,int x2,int y2,OBJREC *o)
draw_border(x1+1,y1+1,x2-x1-2,y2-y1-2,&x);
if (!w)
{
curcolor=x.light;hor_line(x1,y1,x2);hor_line(x1,y1+1,x2);
curcolor=x.shadow;hor_line(x1,y2,x2);hor_line(x1,y2-1,x2);
curcolor=x.light;hor_line32(x1,y1,x2);hor_line32(x1,y1+1,x2);
curcolor=x.shadow;hor_line32(x1,y2,x2);hor_line32(x1,y2-1,x2);
}
set_aligned_position(((x1+x2)>>1)+(w<<1),((y1+y2)>>1)+(w<<1),1,1,(char *)o->userptr);
outtext((char *)o->userptr);
@ -225,7 +225,7 @@ void draw_status_line(char *c)
memcpy(&charcolors,&color,sizeof(charcolors));
y=SCR_WIDTH_Y-ysize-3;
desktop_y_size=y-3;
bar(0,y,SCR_WIDTH_X-1,SCR_WIDTH_Y-1);
bar32(0,y,SCR_WIDTH_X-1,SCR_WIDTH_Y-1);
draw_border(2,y,SCR_WIDTH_X-5,ysize,&ctl);
while (text_width(c)>SCR_WIDTH_X)
{
@ -324,7 +324,7 @@ void *show_time(EVENT_MSG *msg)
void win_label_draw(int x1,int y1,int x2,int y2,OBJREC *o)
{
bar(x1,y1,x2,y2);
bar32(x1,y1,x2,y2);
set_aligned_position(x1+5,(y1+y2)/2,0,1,(char *)o->userptr);
outtext((char *)o->userptr);
}
@ -450,18 +450,18 @@ void check_box_draw(int x1,int y1, int x2, int y2,OBJREC *o)
x1+=1;y1+=1;x2-=1;y2-=1;
x3=x1+(y2-y1);
draw_border(x1,y1,x3-x1,y2-y1,def_border(4,curcolor));
bar(x1,y1,x3,y2);
bar32(x1,y1,x3,y2);
if (*(char *)o->data & 1)
{
curcolor=0x0000;
line(x1,y1,x3,y2);line(x1+1,y1,x3,y2-1);line(x1,y1+1,x3-1,y2);
line(x1,y2,x3,y1);line(x1+1,y2,x3,y1+1);line(x1,y2-1,x3-1,y1);
line32(x1,y1,x3,y2);line32(x1+1,y1,x3,y2-1);line32(x1,y1+1,x3-1,y2);
line32(x1,y2,x3,y1);line32(x1+1,y2,x3,y1+1);line32(x1,y2-1,x3-1,y1);
}
if (*(char *)o->data & 0x80)
{
curcolor=0x0000;
hor_line(x1,y1,x3);ver_line(x3,y1,y2);
ver_line(x1,y1,y2);hor_line(x1,y2,x3);
hor_line32(x1,y1,x3);ver_line32(x3,y1,y2);
ver_line32(x1,y1,y2);hor_line32(x1,y2,x3);
}
else
{
@ -551,7 +551,7 @@ void radio_butts_draw(int x1,int y1,int x2,int y2,OBJREC *o)
cr=curcolor;
highlight(&ctl,curcolor);
params=(int32_t *)o->userptr;
if (*params) bar(x1,y1,x2,y2);
if (*params) bar32(x1,y1,x2,y2);
step=(y2-y1)/(*(params+1));
size=(step*9)/10;
sizpul=size>>1;
@ -561,16 +561,16 @@ void radio_butts_draw(int x1,int y1,int x2,int y2,OBJREC *o)
{
int j;
curcolor=ctl.shadow;
line(x1+sizpul,y1,x1,y1+sizpul);
line(x1,y1+sizpul,x1+sizpul,y1+size-1);
line32(x1+sizpul,y1,x1,y1+sizpul);
line32(x1,y1+sizpul,x1+sizpul,y1+size-1);
curcolor=ctl.light;
line(x1+sizpul+1,y1,x1+size,y1+sizpul);
line(x1+size,y1+sizpul,x1+sizpul+1,y1+size-1);
line32(x1+sizpul+1,y1,x1+size,y1+sizpul);
line32(x1+size,y1+sizpul,x1+sizpul+1,y1+size-1);
if (*(int32_t *)o->data==i) curcolor=0;else curcolor=cr;
for (j=0;j<3;j++)
{
hor_line(x1+sizpul-j,y1+sizpul-2+j,x1+sizpul+j);
hor_line(x1+sizpul-j,y1+sizpul+2-j,x1+sizpul+j);
hor_line32(x1+sizpul-j,y1+sizpul-2+j,x1+sizpul+j);
hor_line32(x1+sizpul-j,y1+sizpul+2-j,x1+sizpul+j);
}
if (*params)
{
@ -689,7 +689,7 @@ void input_line_draw(int x1,int y1, int x2, int y2, OBJREC *o)
int len;
int shift;
bar(x1,y1,x2,y2);
bar32(x1,y1,x2,y2);
position(x1,y1);
c=(char *)o->data;
if (!*c) return;
@ -868,7 +868,7 @@ void scroll_button_draw(int x1,int y1,int x2,int y2,OBJREC *o)
SCR_BUTTON *param;
param=(SCR_BUTTON *)o->userptr;
bar(x1,y1,x2,y2);
bar32(x1,y1,x2,y2);
highlight(&x,o->color);
w=*(char *)o->data;
x.bsize=2-w;
@ -963,7 +963,7 @@ void scroll_bar_v_draw(int x1,int y1,int x2,int y2,OBJREC *o)
if (barsize>wsize) barsize=wsize;
wsize-=barsize;
curcolor=p->bgcolor;
bar(x1,y1,x2,y2);
bar32(x1,y1,x2,y2);
curcolor=o->color;
highlight(&ctl,o->color);ctl.bsize=2;ctl.ctldef=0;
y=valsize?(*d-p->minvalue)*(wsize+barsize)/valsize:0;
@ -972,7 +972,7 @@ void scroll_bar_v_draw(int x1,int y1,int x2,int y2,OBJREC *o)
if (y<0) y=0;
y+=y1;
draw_border(x1+2,y+2,(x2-x1)-4,barsize-4,&ctl);
if (barsize>4)bar(x1+2,y+2,x2-2,y+barsize-2);
if (barsize>4)bar32(x1+2,y+2,x2-2,y+barsize-2);
p->barsize=barsize;
}
@ -1076,7 +1076,7 @@ void scroll_bar_h_draw(int x1,int y1,int x2,int y2,OBJREC *o)
if (barsize>wsize) barsize=wsize;if (barsize<2) barsize=2;
wsize-=barsize;
curcolor=p->bgcolor;
bar(x1,y1,x2,y2);
bar32(x1,y1,x2,y2);
curcolor=o->color;
highlight(&ctl,o->color);ctl.bsize=2;ctl.ctldef=0;
x=(*d-p->minvalue)*wsize/valsize;
@ -1085,7 +1085,7 @@ void scroll_bar_h_draw(int x1,int y1,int x2,int y2,OBJREC *o)
if (x<0) x=0;
x+=x1;
draw_border(x+2,y1+2,barsize-4,(y2-y1)-4,&ctl);
if (barsize>4)bar(x+2,y1+2,x+barsize-2,y2-2);
if (barsize>4)bar32(x+2,y1+2,x+barsize-2,y2-2);
p->barsize=barsize;
}
@ -1234,17 +1234,17 @@ void resizer_draw(int x1,int y1,int x2,int y2,OBJREC *o)
highlight(&ctl,o->color);
curcolor=o->color;
bar(x1,y1,x2,y2);
bar32(x1,y1,x2,y2);
curcolor=ctl.light;
line(x2-1,y1+1,x1+1,y2-1);
line(x2-1,(y1+y2)>>1,(x1+x2)>>1,y2-1);
line32(x2-1,y1+1,x1+1,y2-1);
line32(x2-1,(y1+y2)>>1,(x1+x2)>>1,y2-1);
curcolor=ctl.shadow;
line(x2-1,y1+4,x1+4,y2-1);
line(x2-1,y1+2,x2-1,y1+4);
line(x1+2,y2-1,x1+4,y2-1);
line(x2-1,((y1+y2)>>1)+4,((x1+x2)>>1)+4,y2-1);
line(x2-1,((y1+y2)>>1)+2,x2-1,((y1+y2)>>1)+4);
line(((x1+x2)>>1)+2,y2-1,((x1+x2)>>1)+4,y2-1);
line32(x2-1,y1+4,x1+4,y2-1);
line32(x2-1,y1+2,x2-1,y1+4);
line32(x1+2,y2-1,x1+4,y2-1);
line32(x2-1,((y1+y2)>>1)+4,((x1+x2)>>1)+4,y2-1);
line32(x2-1,((y1+y2)>>1)+2,x2-1,((y1+y2)>>1)+4);
line32(((x1+x2)>>1)+2,y2-1,((x1+x2)>>1)+4,y2-1);
}
void resizer_event(EVENT_MSG *msg,OBJREC *o)

View file

@ -1,22 +1,20 @@
#include "types.h"
#define line line32
#define hor_line hor_line32
#define ver_line ver_line32
#define bar bar32
#define point point32
word *GetScreenAdr();
int32_t GetScreenSizeBytes();
word *GetBuffer2nd();
int32_t GetScreenPitch();
int32_t GetBuffer2ndPitch();
int32_t GetScreenSizeBytes();
void RedirectScreen(word *newaddr);
void RestoreScreen();
void RedirectScreenBufferSecond();
extern word curcolor,charcolors[7];
extern int32_t scr_linelen;
extern int32_t scr_linelen2;
extern int32_t dx_linelen;
extern word *curfont,*writepos,writeposx;
extern byte fontdsize;
extern byte *palmem,*xlatmem;
@ -29,7 +27,7 @@ extern char no_restore_mode;
static __inline word *getadr32(longint x,longint y)
{
return GetScreenAdr()+scr_linelen2*y+x;
return GetScreenAdr()+GetScreenPitch()*y+x;
}
static __inline void point32(longint x,longint y, word color)

View file

@ -1,4 +1,4 @@
#include <skeldal_win.h>
#include <platform.h>
#include "types.h"
//#include <vesa.h>
//#include <dpmi.h>
@ -13,9 +13,6 @@
word *screen;
word curcolor,charcolors[7] = {0x0000,RGB555(0,31,0),RGB555(0,28,0),RGB555(0,24,0),RGB555(0,20,0),0x0000,0x0000};
int32_t scr_linelen;
int32_t scr_linelen2;
int32_t dx_linelen;
word *curfont,*writepos,writeposx;
byte fontdsize=0;
byte *palmem=NULL,*xlatmem=NULL;
@ -302,7 +299,6 @@ int initmode_dx(char inwindow, char zoom, char monitor, int refresh)
if (!DXInit64(inwindow,zoom,monitor,refresh)) return -1;
showview=showview_dx;
screenstate=1;
scr_linelen2=scr_linelen/2;
return 0;
}
@ -659,10 +655,10 @@ void set_aligned_position(int x,int y,char alignx,char aligny,char *text)
void rectangle(int x1,int y1,int x2,int y2,int color)
{
curcolor=color;
hor_line(x1,y1,x2);
hor_line(x1,y2,x2);
ver_line(x1,y1,y2);
ver_line(x2,y1,y2);
hor_line32(x1,y1,x2);
hor_line32(x1,y2,x2);
ver_line32(x1,y1,y2);
ver_line32(x2,y1,y2);
}
void *create_special_palette()

View file

@ -1,4 +1,4 @@
#include <skeldal_win.h>
#include <platform.h>
#include "types.h"
#include "bgraph.h"
@ -19,6 +19,7 @@ void bar32(int x1,int y1, int x2, int y2)
if (y1<0) y1=0;
if (x2>mx) x2=mx;
if (y2>my) y2=my;
int32_t scr_linelen2 = GetScreenPitch();
for (i=y1,begline=GetScreenAdr()+scr_linelen2*i;i<=y2;i++,begline+=scr_linelen2)
{
for (j=x1;j<=x2;j++) begline[j]=curcolor;
@ -38,6 +39,7 @@ void hor_line32(int x1,int y1,int x2)
if (x1>x2) swap_int(x1,x2);
if (x1<0) x1=0;
if (x2>mx) x2=mx;
int32_t scr_linelen2 = GetScreenPitch();
begline=GetScreenAdr()+scr_linelen2*y1;
for (i=x1;i<x2;i+=2) *(uint32_t *)(begline+i)=curcolor2;
if (i==x2) begline[i]=curcolor;
@ -54,6 +56,7 @@ void ver_line32(int x1,int y1,int y2)
if (x1<0 || x1>mx) return;
if (y1<0) y1=0;
if (y2>my) y2=my;
int32_t scr_linelen2 = GetScreenPitch();
begline=GetScreenAdr()+scr_linelen2*y1+x1;
for (i=y1;i<=y2;i++,begline+=scr_linelen2) *begline=curcolor;
}
@ -71,6 +74,7 @@ void hor_line_xor(int x1,int y1,int x2)
if (x1>x2) swap_int(x1,x2);
if (x1<0) x1=0;
if (x2>mx) x2=mx;
int32_t scr_linelen2 = GetScreenPitch();
begline=GetScreenAdr()+scr_linelen2*y1;
for (i=x1;i<x2;i+=2) *(uint32_t *)(begline+i)^=curcolor2;
if (i==x2) begline[i]^=curcolor;
@ -88,6 +92,7 @@ void ver_line_xor(int x1,int y1,int y2)
if (x1<0 || x1>mx) return;
if (y1<0) y1=0;
if (y2>my) y2=my;
int32_t scr_linelen2 = GetScreenPitch();
begline=GetScreenAdr()+scr_linelen2*y1+x1;
for (i=y1;i<=y2;i++,begline+=scr_linelen2) *begline^=curcolor;
}
@ -119,6 +124,7 @@ void line_32(int x,int y,int xs,int ys)
void char_32(word *posit,word *font,char znak)
//#pragma aux char_32 parm [edi] [esi] [eax] modify [eax ebx ecx edx]
{
int32_t scr_linelen2 = GetScreenPitch();
word *edi = posit;
unsigned char *esi = (unsigned char *)font;
@ -305,6 +311,7 @@ chsend: and eax,0ffffh
void put_picture(word x,word y,void *p)
//#pragma aux put_picture parm [esi] [eax] [edi] modify [ebx ecx edx]
{
int32_t scr_linelen2 = GetScreenPitch();
word *adr=GetScreenAdr()+scr_linelen2*y+x;
word *data=p;
word xs=data[0];
@ -375,6 +382,7 @@ void put_picture(word x,word y,void *p)
}
void get_picture(word x,word y,word xs,word ys,void *p)
{
int32_t scr_linelen2 = GetScreenPitch();
word *adr=GetScreenAdr()+scr_linelen2*y+x;
word *data=p;
word xss=xs;
@ -403,7 +411,7 @@ void get_picture(word x,word y,word xs,word ys,void *p)
void put_image(word *image,word *target,int start_line,int sizex,int sizey)
//#pragma aux put_image parm [ESI][EDI][EAX][EBX][EDX] modify [ECX]
{
int32_t scr_linelen2 = GetScreenPitch();
word *esi = image;
word *edi = target;
int eax = start_line;
@ -457,6 +465,7 @@ puti_lp:mov ecx,ebx
void put_8bit_clipped(void *src,void *trg,int startline,int velx,int vely)
//#pragma aux put_8bit_clipped parm [ESI][EDI][EAX][EBX][EDX] modify [ECX];
{
int32_t scr_linelen2 = GetScreenPitch();
if (src==NULL) return;
{
word *esi = src;
@ -529,6 +538,7 @@ void put_textured_bar_(void *src,void *trg,int xsiz,int ysiz,int xofs,int yofs)
//#pragma aux put_textured_bar_ parm [EBX][EDI][EDX][ECX][ESI][EAX];
{
int32_t scr_linelen2 = GetScreenPitch();
word *imghdr = (word *)src;
word cx = imghdr[0];
word cy = imghdr[1];
@ -633,6 +643,7 @@ ptb_skip2:
void trans_bar(int x,int y,int xs,int ys,int barva)
{
int32_t scr_linelen2 = GetScreenPitch();
word *begline;
int x1=x;
int y1=y;
@ -674,6 +685,7 @@ void trans_bar25(int x,int y,int xs,int ys)
int y2=y+ys-1;
int i,j;
int32_t scr_linelen2 = GetScreenPitch();
int mx = DxGetResX() - 1;
int my = DxGetResY() - 1;

View file

@ -1,4 +1,4 @@
#include <skeldal_win.h>
#include <platform.h>
#include "types.h"
#include "bgraph.h"
#include <debug.h>

View file

@ -1,4 +1,4 @@
#include <skeldal_win.h>
#include <platform.h>
#include "types.h"
#include "bgraph.h"
#include "event.h"

View file

@ -132,7 +132,7 @@ const char *GetLexLibPath()
static char c[MAX_PATH];
char *z;
GetModuleFileName(0,c,MAX_PATH);
z=strrchr(c,'\\')+1;
z=strrchr(c,PATH_SEPARATOR_CHR)+1;
strcpy(z,"lex_lib.exe");
return c;
}
@ -149,8 +149,8 @@ main(int argc,char *argv[])
exit(0);
}
puts("");
puts("Probˇh  kompilace:");
puts(" Spouçtˇm program LEX_LIB.EXE\n");
puts("Prob<EFBFBD>h<EFBFBD> kompilace:");
puts(" Spou<EFBFBD>t<EFBFBD>m program LEX_LIB.EXE\n");
putenv("DOS4G=QUIET");
z=(char *)malloc(strlen(argv[1])+10);
sprintf(z,"\"%s\"",argv[1]);
@ -162,8 +162,8 @@ main(int argc,char *argv[])
puts("Nemohu spustit program lex_lib.exe");
exit(1);
}
puts("Byla kompilov na tato kouzla:");
puts("¬ˇslo, zaź tek, jmeno:");
puts("Byla kompilov<EFBFBD>na tato kouzla:");
puts("<EFBFBD><EFBFBD>slo, za<7A><61>tek, jmeno:");
puts("======================");
memset(kouzla_tab,0,sizeof(kouzla_tab));
init("temp.$$$");
@ -172,8 +172,8 @@ main(int argc,char *argv[])
fclose(source);
save_tab("kouzla.dat");
remove("temp.$$$");
puts("Kompilace ŁspŘçn ...");
printf("Dlka k˘du: %d (+%d)",codesize,sizeof(kouzla_tab));
puts("Kompilace <EFBFBD>sp<EFBFBD><EFBFBD>n<EFBFBD>...");
printf("D<EFBFBD>lka k<>du: %d (+%d)",codesize,sizeof(kouzla_tab));
}

View file

@ -1,4 +1,4 @@
#include <skeldal_win.h>
#include <platform.h>
#include "types.h"
#include <stdio.h>
#include <bios.h>

View file

@ -3,6 +3,7 @@
#include "types.h"
#include "event.h"
#include "mouse.h"
typedef struct tms_basic_info
{
int mouse_event;
@ -14,21 +15,8 @@ typedef struct tms_basic_info
signed short mouse_di;
}TMS_BASIC_INFO;
typedef struct ms_event
{
char event;
word x,y;
char tl1,tl2,tl3;
word event_type;
}MS_EVENT;
extern TMS_BASIC_INFO ms_basic_info;
extern char ms_fake_mode;
//int install_mouse_handler();
//int deinstall_mouse_handler();
//void hranice_mysky(int x1,int y1,int x2,int y2);
void get_ms_event(MS_EVENT *event);
int lock_region (void *address, unsigned length);
void keyboard(EVENT_MSG *msg,void *user_data);
char ms_get_keycount();

View file

@ -1,4 +1,4 @@
#include <skeldal_win.h>
#include <platform.h>
#include <stdio.h>
#include <stdlib.h>
#include "types.h"

View file

@ -1,4 +1,4 @@
#include <skeldal_win.h>
#include <platform.h>
//Gui system - object system + graphic
#include "types.h"
#include <stdio.h>
@ -64,11 +64,11 @@ void draw_border(integer x,integer y,integer xs,integer ys,CTL3D *btype)
{
x--;y--;xs+=2;ys+=2;
if (j & 1) curcolor=btype->shadow; else curcolor=btype->light;
hor_line(x,y,xs+x);
ver_line(x,y,ys+y);
hor_line32(x,y,xs+x);
ver_line32(x,y,ys+y);
if (j & 1) curcolor=btype->light; else curcolor=btype->shadow;
hor_line(x,y+ys,xs+x);
ver_line(x+xs,y,ys+y);
hor_line32(x,y+ys,xs+x);
ver_line32(x+xs,y,ys+y);
j>>=1;
}
curcolor=c;
@ -231,6 +231,7 @@ void absolute_window(WINDOW *w,OBJREC *o, int *x, int *y)
{
int i,j;
word *a;
int32_t scr_linelen2 = GetScreenPitch();
for (i=y;i<=y+ys;i++)
{
@ -434,7 +435,7 @@ void redraw_desktop_call(EVENT_MSG *msg,void **data)
if (gui_background==NULL)
{
curcolor=DESK_TOP_COLOR;
bar(0,0,SCR_WIDTH_X,SCR_WIDTH_Y-1);
bar32(0,0,SCR_WIDTH_X,SCR_WIDTH_Y-1);
}
else
put_picture(0,0,gui_background);

View file

@ -1,4 +1,4 @@
#include <skeldal_win.h>
#include <platform.h>
#include <stdio.h>
#include <malloc.h>
#include <stdlib.h>
@ -104,7 +104,7 @@ void add_field_num(TSTR_LIST *ls,const char *name,int32_t number)
{
char buff[20];
itoa(number,buff,10);
int2ascii(number,buff,10);
add_field_txt(ls,name,buff);
}

View file

@ -1,4 +1,4 @@
#include <skeldal_win.h>
#include <platform.h>
#include "types.h"
#include <mem.h>
#include <stdio.h>

View file

@ -1,4 +1,4 @@
#include <skeldal_win.h>
#include <platform.h>
// MOTION GIF - LZW komprimovana animace v rozliseni 320x180 256 barev avsak
// upravena pro prehravani v HICOLOR pro konkretni rezim (32768 barev)

View file

@ -1,4 +1,4 @@
#include <skeldal_win.h>
#include <platform.h>
#include <bgraph.h>
#include <stdio.h>
#include "types.h"
@ -53,6 +53,7 @@ static void StretchImageHQ(word *src, word *trg, uint32_t linelen, char full)
static void PlayMGFFile(void *file, MGIF_PROC proc,int ypos,char full)
{
int32_t scr_linelen2 = GetScreenPitch();
mgif_install_proc(proc);
sound=PrepareVideoSound(22050,256*1024);
mgif_accnums[0]=mgif_accnums[1]=0;

View file

@ -1,4 +1,4 @@
#include <skeldal_win.h>
#include <platform.h>
#include <stdio.h>
#include "types.h"
#include "memman.h"

View file

@ -1,4 +1,4 @@
#include <skeldal_win.h>
#include <platform.h>
#include "types.h"
#include <mgfplay.h>
#include <bgraph.h>

24
libs/mouse.h Normal file
View file

@ -0,0 +1,24 @@
#include <stdint.h>
#ifdef __cplusplus
extern "C" {
#endif
#ifndef __SKELDAL__MOUSE__
#define __SKELDAL__MOUSE__
typedef struct ms_event
{
char event;
uint16_t x,y;
char tl1,tl2,tl3;
uint16_t event_type;
}MS_EVENT;
void get_ms_event(MS_EVENT *event);
#endif
#ifdef __cplusplus
}
#endif

View file

@ -1,4 +1,4 @@
#include <skeldal_win.h>
#include <platform.h>
#include <malloc.h>
#include <mem.h>
#include <stdio.h>

View file

@ -1,4 +1,4 @@
#include <skeldal_win.h>
#include <platform.h>
#include <stdio.h>
#include <mem.h>
#include "types.h"
@ -17,8 +17,8 @@ int bott_line;
int base_line;
int top_ofs;
char znaky[]="0123456789A<EFBFBD>BC€D…E<EFBFBD>‰FGHIJKLŠœMN¥O•PQRžST†U—¦VWXY<EFBFBD>Z"
"a bc‡dƒeˆfghi¡jkl<EFBFBD>Œmn¤o¢pqr©s¨tŸu£vwxy˜z"
char znaky[]="0123456789A<EFBFBD>BC<EFBFBD>D<EFBFBD>E<EFBFBD><EFBFBD>FGHI<EFBFBD>JKL<EFBFBD><EFBFBD>MN<EFBFBD>O<EFBFBD>PQR<EFBFBD>S<EFBFBD>T<EFBFBD>U<EFBFBD><EFBFBD>VWXY<EFBFBD>Z<EFBFBD>"
"a<EFBFBD>bc<EFBFBD>d<EFBFBD>e<EFBFBD><EFBFBD>fghi<EFBFBD>jkl<EFBFBD><EFBFBD>mn<EFBFBD>o<EFBFBD>pqr<EFBFBD>s<EFBFBD>t<EFBFBD>u<EFBFBD><EFBFBD>vwxy<EFBFBD>z<EFBFBD>"
"~!@#$%^&*()_+|-=\\[]{};':,./<>?";
void load_font_pic(char *filename)

View file

@ -1,4 +1,4 @@
#include <skeldal_win.h>
#include <platform.h>
#include "strlite.c"
#include "devices.h"
@ -100,7 +100,7 @@ void string_list_draw(int x1,int y1,int x2,int y2,OBJREC *o)
xs=x2-x1;ys=y2-y1;
p=o->userptr;
ls=p->list;
bar(x1,y1,x2,y2);
bar32(x1,y1,x2,y2);
y=y1;p->maxitems=str_count(ls);
for(j=p->maxitems-1;j>=0;j--) if (ls[j]!=NULL) break;
j++;
@ -124,7 +124,7 @@ void string_list_draw(int x1,int y1,int x2,int y2,OBJREC *o)
if (i==*(int *)(o->data))
{
curcolor=p->selcolor;
bar(x1,y,x2,y+znh-1);
bar32(x1,y,x2,y+znh-1);
}
position(x1,y);
for(j=0,x=x1,savech[0]=c[j];
@ -145,7 +145,7 @@ void string_list_draw(int x1,int y1,int x2,int y2,OBJREC *o)
int dif=y2-(y+znh);
p->topline-=(dif*2/3)/znh+1;
curcolor=savcolor;
bar(x1,y1,x2,y2);
bar32(x1,y1,x2,y2);
}
}
while (p->topline && y+2*znh<y2 && znh);

View file

@ -1,4 +1,4 @@
#include <skeldal_win.h>
#include <platform.h>
#include "strlite.h"
#include <stdlib.h>
#include <stdio.h>
@ -14,7 +14,7 @@ TSTR_LIST create_list(int count)
size_t *s=(size_t *)malloc(count*sizeof(*p)+sizeof(size_t));
if (p==NULL) return NULL;
*s = count;
p = (TSTR_LIST)s;
p = (TSTR_LIST)(s+1);
for(i=0;i<count;i++) p[i]=NULL;
return p;
}

View file

@ -2,3 +2,12 @@
#define integer signed short
#define word unsigned short
#define longint int32_t
#ifdef _WIN32
#define PATH_SEPARATOR "\\"
#define PATH_SEPARATOR_CHR '\\'
#else
#define PATH_SEPARATOR "/"
#define PATH_SEPARATOR_CHR '/'
#endif

View file

@ -1,4 +1,4 @@
#include <skeldal_win.h>
#include <platform.h>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>

View file

@ -2,10 +2,9 @@
#include <stdio.h>
//#include <i86.h>
//#include <dpmi.h>
#include <conio.h>
#include <mem.h>
#include <bios.h>
#include <dos.h>
#include "zvuk.h"
//#include "pcspeak.h"
@ -101,7 +100,7 @@ int bxbass=0;
static int gfxvol=255;
int32_t blength;
static char depack[32768];
void (__far __interrupt *oldvect)();
//void (__far __interrupt *oldvect)();
static char swap_chans=0;
char da_xlat[256]; // Xlat tabulka pro DA a PC Speaker;

View file

@ -27,7 +27,6 @@ char start_mixing();
void stop_mixing();
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 init_winamp_plugins(const char *path);
void set_end_of_song_callback(const char * (*cb)(void *), void *ctx);
void fade_music();

View file

@ -1,5 +1,5 @@
#define INITGUID
#include <skeldal_win.h>
#include <platform.h>
#include <malloc.h>
#include <debug.h>
#include <stdio.h>

View file

@ -1,6 +1,7 @@
SET(files error.cpp legacy_coroutines.cpp)
SET(files error.cpp legacy_coroutines.cpp platform.cpp int2ascii.c istr.c)
add_library(skeldal_platform_libs ${files})
set_property(TARGET skeldal_platform_libs PROPERTY CXX_STANDARD 20)
add_subdirectory(sdl)
add_subdirectory(linux)

30
platform/int2ascii.c Normal file
View file

@ -0,0 +1,30 @@
#include "platform.h"
static char *render_int(char *where, int i, int radix) {
if (i == 0) return where;
char *r = render_int(where, i/radix, radix);
int p = i % radix;
if (p<=0) {
*r = p + '0';
} else {
*r = p + 'A' - 10;
}
return r+1;
}
const char * int2ascii(int i, char *c, int radix) {
if (i == 0) {
c[0] = '0';
c[1] = 0;
return c;
}
if (i<0) {
c[0] = '-';
*render_int(c+1,-i,radix) = 0;
} else {
*render_int(c,i,radix) = 0;
}
return c;
}

23
platform/istr.c Normal file
View file

@ -0,0 +1,23 @@
#include "platform.h"
#include <ctype.h>
int stricmp(const char *a, const char *b) {
while (*a && *b) {
char ca = toupper(*a);
char cb = toupper(*b);
if (ca<cb) return -1;
if (ca>cb) return 1;
++a;
++b;
}
if (*a) return 1;
if (*b) return -1;
return 0;
}
void strupr(char *c) {
while (*c) {
*c = toupper(*c);
++c;
}
}

View file

@ -0,0 +1,2 @@
add_library(skeldal_linux map_file.cpp timer.cpp)

View file

@ -0,0 +1,59 @@
extern "C" {
#include "map_file.h"
}
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
#include <sys/mman.h>
#include <sys/stat.h>
#include <unistd.h>
// Funkce pro mapování souboru do paměti
void* map_file_to_memory(const char *name, size_t *sz) {
if (!name || !sz) {
return NULL;
}
// Otevření souboru pro čtení
int fd = open(name, O_RDONLY);
if (fd == -1) {
perror("Chyba při otevírání souboru");
return NULL;
}
// Získání velikosti souboru
struct stat st;
if (fstat(fd, &st) == -1) {
perror("Chyba při získávání velikosti souboru");
close(fd);
return NULL;
}
*sz = st.st_size;
// Namapování souboru do paměti
void *mapped = mmap(NULL, *sz, PROT_READ, MAP_PRIVATE, fd, 0);
if (mapped == MAP_FAILED) {
perror("Chyba při mapování souboru");
close(fd);
return NULL;
}
// Zavření souborového popisovače (není již potřeba po mmap)
close(fd);
return mapped;
}
// Funkce pro zrušení mapování
void unmap_file(void *ptr, size_t sz) {
if (!ptr || sz == 0) {
return;
}
// Zrušení mapování
if (munmap(ptr, sz) == -1) {
perror("Chyba při rušení mapování");
}
}

View file

@ -0,0 +1,4 @@
#include <stddef.h>
#include <stdint.h>
void *map_file_to_memory(const char *name, size_t *sz);
void unmap_file(void *ptr, size_t sz);

18
platform/linux/timer.cpp Normal file
View file

@ -0,0 +1,18 @@
#include "timer.h"
#include <chrono>
#include "../platform.h"
#include <thread>
int get_timer_value() {
auto n = std::chrono::steady_clock::now();
return std::chrono::duration_cast<std::chrono::milliseconds>(n.time_since_epoch()).count()/TIMERSPEED;
}
uint32_t get_game_tick_count() {
auto n = std::chrono::steady_clock::now();
return std::chrono::duration_cast<std::chrono::milliseconds>(n.time_since_epoch()).count();
}
void sleep_ms(uint32_t x) {
std::this_thread::sleep_for(std::chrono::milliseconds(x));
}

28
platform/linux/timer.h Normal file
View file

@ -0,0 +1,28 @@
/*
* timer.h
*
* Created on: 26. 1. 2025
* Author: ondra
*/
#ifndef PLATFORM_LINUX_TIMER_H_
#define PLATFORM_LINUX_TIMER_H_
#include <stdint.h>
#ifdef __cplusplus
extern "C" {
#endif
int get_timer_value();
uint32_t get_game_tick_count();
void sleep_ms(uint32_t);
#ifdef __cplusplus
}
#endif
#endif /* PLATFORM_LINUX_TIMER_H_ */

7
platform/platform.cpp Normal file
View file

@ -0,0 +1,7 @@
extern "C" {
void install_wizard() {
}
}

View file

@ -6,7 +6,7 @@
#define BGSWITCHBIT 0x0020
#define SKELDALINI "WSKELDAL.INI"
#define SKELDALINI "wskeldal.ini"
#ifdef __cplusplus
extern "C"
@ -17,31 +17,17 @@ extern "C"
#define _KEYBRD_READY 0
#define _KEYBRD_READ 1
#define TIMERSPEED 20;
#define TIMERSPEED 20
uint32_t _bios_keybrd(int mode);
//LRESULT GameMainWindowWindowProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
void CheckMessageQueue();
//void DSReportWindowCreation(HWND hWindow);
char *AutodetectWinAmp();
#ifdef __cplusplus
}
#endif
#define RGB888(r,g,b) ((unsigned short)((((r)<<8)&0xF800) | (((g)<<3) & 0x7C0) | ((b)>>3)))
#define RGB555(r,g,b) ((unsigned short)(((r)<<11) | ((g)<<6) | (b)))
#pragma warning (disable : 4244 4761 4133)
void *LoadDefaultFont();
void *LoadResourceFont(const char *name);
void *map_file_to_memory(const char *name, size_t *sz);
void unmap_file(void *ptr, size_t sz);
@ -56,13 +42,17 @@ int stricmp(const char *a, const char *b);
#define MIN(a, b) ((a)<(b)?(a):(b))
#define MAX(a, b) ((a)>(b)?(a):(b))
void strupr(char *c);
const char * itoa(int i, char *c, int radix);
const char * int2ascii(int i, char *c, int radix);
uint32_t get_game_tick_count();
void sleep_ms(uint32_t);
#ifdef __cplusplus
}
#endif
//------------- BGRAPH DX wrapper -------------------
#include "BGraph2Dx.h"
#include "sdl/BGraph2.h"
#define WM_RELOADMAP (WM_APP+215)
#define E_RELOADMAP 40

112
platform/sdl/BGraph2.cpp Normal file
View file

@ -0,0 +1,112 @@
#include "BGraph2.h"
#include "sdl_context.h"
#include "global_context.h"
static std::unique_ptr<uint16_t[]> screen_buffer;
static std::unique_ptr<uint16_t[]> buffer2nd;
static uint16_t *render_target;
static uint16_t screen_pitch = 640;
char DXInit64(char inwindow,int zoom,int monitor, int refresh) {
SDLContext::DisplayMode mode;
if (inwindow) {
if (zoom) {
mode = SDLContext::double_window;
} else {
mode = SDLContext::native_window;
}
} else {
mode = SDLContext::fullscreen;
}
screen_pitch = 640;
get_sdl_global_context().init_screen(mode, "Skeldal"); //todo allow change
screen_buffer = std::make_unique<uint16_t[]>(screen_pitch*480);
buffer2nd = std::make_unique<uint16_t[]>(screen_pitch*480);
render_target = screen_buffer.get();
return 0;
}
void DXCloseMode() {
get_sdl_global_context().close_screen();
}
uint16_t *GetScreenAdr() {
return render_target;
}
uint16_t *GetBuffer2nd() {
return buffer2nd.get();
}
int32_t GetScreenPitch() {
return screen_pitch;
}
int32_t GetBuffer2ndPitch() {
return screen_pitch;
}
int32_t GetScreenSizeBytes() {
return screen_pitch * 480 * 2;
}
void RedirectScreen(uint16_t *newaddr) {
render_target = newaddr;
}
void RestoreScreen() {
render_target = screen_buffer.get();
}
void RedirectScreenBufferSecond() {
render_target = buffer2nd.get();
}
int DxGetResX() {
return 640;
}
int DxGetResY() {
return 480;
}
void setvesa_displaystart(int x,int y){
}
void StripBlt(void *data, unsigned int startline, uint32_t width) {
unsigned short *start=startline*GetScreenPitch()+GetScreenAdr();
while (width--)
{
memcpy(start,data,640*2);
data=(void *)(reinterpret_cast<char *>(data)+get_sdl_global_context().get_surface_pitch());
start=start+GetScreenPitch();
}
}
void DXCopyRects64(unsigned short x,unsigned short y,unsigned short xs,unsigned short ys) {
get_sdl_global_context().present_rect(screen_buffer.get(), screen_pitch, x,y,xs,ys);
}
void *DxPrepareWalk(int ypos) {
return 0;
}
void DxZoomWalk(void *handle, int ypos, int *points,float phase, void *lodka) {
}
void DxDoneWalk(void *handle) {
}
void *DxPrepareTurn(int ypos) {
return 0;
}
void DxTurn(void *handle, char right, int ypos,int border, float phase, void *lodka) {
}
void DxDoneTurn(void *handle) {
}
void DxTurnLeftRight(char right, float phase, int border, int ypos, int *last) {
}

View file

@ -1,3 +1,5 @@
#include <stdint.h>
#ifndef __BGRAPH_DX_WRAPPER_
#define __BGRAPH_DX_WRAPPER_
@ -5,9 +7,15 @@
extern "C" {
#endif
extern int32_t scr_linelen;
extern int32_t scr_linelen2;
extern int32_t dx_linelen;
uint16_t *GetScreenAdr();
uint16_t *GetBuffer2nd();
int32_t GetScreenPitch();
int32_t GetBuffer2ndPitch();
int32_t GetScreenSizeBytes();
void RedirectScreen(uint16_t *newaddr);
void RestoreScreen();
void RedirectScreenBufferSecond();
//inicializuje a otevira rezim 640x480x16b v DX - otevre okno, pripravi vse pro beh hry
@ -19,7 +27,6 @@ void DXCloseMode();
//void DXCopyRects32(unsigned short x,unsigned short y,unsigned short xs,unsigned short ys);
void DXCopyRects64(unsigned short x,unsigned short y,unsigned short xs,unsigned short ys);
void DXCopyRects64zoom2(unsigned short x,unsigned short y,unsigned short xs,unsigned short ys);
void *DxPrepareWalk(int ypos);
void DxZoomWalk(void *handle, int ypos, int *points,float phase, void *lodka);
@ -35,8 +42,6 @@ void DxDialogs(char enable);
void setvesa_displaystart(int x,int y);
extern int32_t scr_linelen;
extern int32_t scr_linelen2;
void DxSetInitResolution(int x, int y);
int DxGetResX();

View file

@ -1 +1,3 @@
add_subdirectory(tests)
add_library(skeldal_sdl sdl_context.cpp BGraph2.cpp input.cpp sound.cpp)

View file

@ -0,0 +1,11 @@
#pragma once
#include "sdl_context.h"
inline SDLContext &get_sdl_global_context () {
static SDLContext sdl_global_context;
return sdl_global_context;
}

28
platform/sdl/input.cpp Normal file
View file

@ -0,0 +1,28 @@
#include "global_context.h"
#include "input.h"
char get_control_key_state() {
return 0; //todo
}
char get_shift_key_state() {
return 0; //todo
}
uint32_t _bios_keybrd(int mode) {
return 0;
}
void SetWheelMapping(char up, char down) { //todo
}
static MS_EVENT ms_event = {};
void get_ms_event(MS_EVENT *event) {
*event = ms_event;
}
void ShareCPU() {
}

31
platform/sdl/input.h Normal file
View file

@ -0,0 +1,31 @@
/*
* input.h
*
* Created on: 26. 1. 2025
* Author: ondra
*/
#ifndef PLATFORM_SDL_INPUT_H_
#define PLATFORM_SDL_INPUT_H_
#ifdef __cplusplus
extern "C" {
#endif
#include <devices.h>
char get_control_key_state();
char get_shift_key_state();
uint32_t _bios_keybrd(int mode);
void SetWheelMapping(char up, char down);
void get_ms_event(MS_EVENT *event);
void ShareCPU();
#ifdef __cplusplus
}
#endif
#endif /* PLATFORM_SDL_INPUT_H_ */

View file

@ -0,0 +1,186 @@
#include "sdl_context.h"
#include "../platform.h"
#include <stdexcept>
void SDLContext::SDL_Deleter::operator ()(SDL_Window* window) {
SDL_DestroyWindow(window);
}
void SDLContext::SDL_Deleter::operator ()(SDL_Renderer* renderer) {
SDL_DestroyRenderer(renderer);
}
void SDLContext::SDL_Deleter::operator ()(SDL_Surface* surface) {
SDL_FreeSurface(surface);
}
void SDLContext::SDL_Deleter::operator ()(SDL_Texture* texture) {
SDL_DestroyTexture(texture);
}
struct SDL_INIT_Context {
SDL_INIT_Context() {
if (SDL_Init(SDL_INIT_VIDEO|SDL_INIT_TIMER|SDL_INIT_AUDIO) < 0) {
SDL_Log("Unable to initialize SDL: %s", SDL_GetError());
exit(1);
}
inited = true;
}
~SDL_INIT_Context() {
SDL_Quit();
}
bool inited = false;
};
static SDL_INIT_Context init_context = {};
SDLContext::SDLContext() {
if (!init_context.inited) throw std::runtime_error("SDL not inited");
}
void SDLContext::init_screen(DisplayMode mode, const char *title) {
char buff[256];
int width = 640;
int height = 480;
if (mode == double_window) {
width*=2;
height*=2;
}
SDL_Window *window = SDL_CreateWindow(title,
SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED,
width, height, SDL_WINDOW_RESIZABLE|(mode==fullscreen?SDL_WINDOW_FULLSCREEN_DESKTOP:0));
if (!window) {
snprintf(buff, sizeof(buff), "SDL Error create window: %s\n", SDL_GetError());
throw std::runtime_error(buff);
}
_window.reset(window);
SDL_Renderer *renderer = SDL_CreateRenderer(_window.get(), -1, 0);
if (!renderer) {
snprintf(buff,sizeof(buff), "Chyba při vytváření rendereru: %s\n", SDL_GetError());
throw std::runtime_error(buff);
}
_renderer.reset(renderer);
// Vytvoření softwarového backbufferu (surface)
SDL_Surface *backbuffer = SDL_CreateRGBSurfaceWithFormat(0, 640, 480, 16, SDL_PIXELFORMAT_RGB565);
if (!backbuffer) {
snprintf(buff,sizeof(buff), "Chyba při vytváření surface: %s\n", SDL_GetError());
throw std::runtime_error(buff);
}
_surface.reset(backbuffer);
// Vytvoření textury pro zobrazení backbufferu
SDL_Texture *texture = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_RGB565, SDL_TEXTUREACCESS_STREAMING, 640, 480);
if (!texture) {
snprintf(buff, sizeof(buff), "Chyba při vytváření textury: %s\n", SDL_GetError());
throw std::runtime_error(buff);
}
_texture.reset(texture);
SDL_LockSurface(_surface.get());
if (!_timer_event) _timer_event = SDL_RegisterEvents(1);
_fullscreen_mode = mode == fullscreen;
}
void SDLContext::close_screen() {
SDL_UnlockSurface(_surface.get());
_texture.reset();
_surface.reset();
_renderer.reset();
_window.reset();
}
uint16_t* SDLContext::get_surface_addr() {
return reinterpret_cast<uint16_t *>(_surface->pixels);
}
int32_t SDLContext::get_surface_pitch() {
return _surface->pitch;
}
void SDLContext::charge_timer() {
_active_timer = SDL_AddTimer(1000/TIMERSPEED, [](Uint32 interval, void *param) -> Uint32 {
SDLContext *me = reinterpret_cast<SDLContext *>(param);
SDL_Event* event = (SDL_Event*)param;
event->type = me->_timer_event;
SDL_PushEvent(event);
return 0;
}, this);
}
void SDLContext::pool_events() {
if (!_active_timer.has_value()) charge_timer();
SDL_Event e;
while (true) {
if (SDL_WaitEvent(&e)) {
if (e.type == SDL_QUIT) {
_quit_requested = true;
return;
}
if (e.type == _timer_event) {
break;
}
if (e.type == SDL_KEYDOWN) {
if (e.key.keysym.sym == SDLK_RETURN && (e.key.keysym.mod & KMOD_ALT)) {
_fullscreen_mode = !_fullscreen_mode;
SDL_SetWindowFullscreen(_window.get(), _fullscreen_mode ? SDL_WINDOW_FULLSCREEN_DESKTOP : 0);
}
} else if (e.type == SDL_MOUSEMOTION) {
int mouseX = e.motion.x;
int mouseY = e.motion.y;
int windowWidth;
int windowHeight;
SDL_GetWindowSize(_window.get(), &windowWidth, &windowHeight);
float normalizedX = (float)mouseX / windowWidth;
float normalizedY = (float)mouseY / windowHeight;
ms_event.event = 1;
ms_event.event_type = 1;
ms_event.x = (int16_t)(640*normalizedX);
ms_event.y = (int16_t)(480*normalizedY);
} else if (e.type == SDL_MOUSEBUTTONDOWN || e.type == SDL_MOUSEBUTTONUP) {
int mouseX = e.button.x;
int mouseY = e.button.y;
int button = e.button.button;
int up = e.type == SDL_MOUSEBUTTONUP?1:0;
ms_event.event = 1;
ms_event.event_type = (1<<(2*button-1+up));
switch (button) {
default: break;
case 1: ms_event.tl1 = !up; break;
case 2: ms_event.tl2 = !up; break;
case 3: ms_event.tl3 = !up; break;
}
}
} else {
throw std::runtime_error("SDL_WaitEvent error");
}
}
charge_timer();
}
void SDLContext::present_rect(uint16_t *pixels, unsigned int pitch,
unsigned int x, unsigned int y, unsigned int xs, unsigned ys) {
auto beg = pixels + y * pitch + y;
SDL_Rect r = {static_cast<int>(x),
static_cast<int>(y),
static_cast<int>(xs),
static_cast<int>(ys)};
SDL_UpdateTexture(_texture.get(), &r, beg, pitch*2);
SDL_RenderClear(_renderer.get());
SDL_RenderCopy(_renderer.get(), _texture.get(), NULL, NULL);
SDL_RenderPresent(_renderer.get());
}

View file

@ -0,0 +1,55 @@
#pragma once
#include <memory>
#include <optional>
#include <SDL2/SDL.h>
#include <mouse.h>
class SDLContext {
public:
SDLContext();
enum DisplayMode {
native_window,
double_window,
fullscreen
};
void init_screen(DisplayMode mode, const char *title);
void close_screen();
uint16_t *get_surface_addr();
int32_t get_surface_pitch();
void pool_events();
void present_rect(uint16_t *pixels, unsigned int pitch, unsigned int x, unsigned int y, unsigned int xs,unsigned ys);
protected:
struct SDL_Deleter {
void operator()(SDL_Window *);
void operator()(SDL_Renderer *);
void operator()(SDL_Surface *);
void operator()(SDL_Texture *);
};
MS_EVENT ms_event;
std::unique_ptr<SDL_Window, SDL_Deleter> _window;
std::unique_ptr<SDL_Renderer, SDL_Deleter> _renderer;
std::unique_ptr<SDL_Surface, SDL_Deleter> _surface;
std::unique_ptr<SDL_Texture, SDL_Deleter> _texture;
std::optional<SDL_TimerID> _active_timer;
Uint32 _timer_event = 0;
bool _quit_requested = false;
bool _fullscreen_mode = false;
void charge_timer();
};

78
platform/sdl/sound.cpp Normal file
View file

@ -0,0 +1,78 @@
#include "../platform.h"
#include <zvuk.h>
void set_mixing_device(int mix_dev,int mix_freq,...) {
}
char start_mixing() {
return 0;
}
void stop_mixing() {
}
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_end_of_song_callback(const char * (*cb)(void *), void *ctx) {
}
void fade_music() {
}
int mix_back_sound(int synchro) {
return 0;
}
//int open_backsound(char *filename);
void change_music(const char *filename) {
}
//char *device_name(int device);
//void force_music_volume(int volume);
//void set_backsnd_freq(int freq);
char get_channel_state(int channel) {
return 0;
}
void get_channel_volume(int channel,int *left,int *right) {
}
void mute_channel(int channel) {
}
void chan_break_loop(int channel) {
}
void chan_break_ext(int channel,void *org_sample,int32_t size_sample) {
}
char set_snd_effect(int funct,int data) {
return 0;
}
char check_snd_effect(int funct) {
return 0;
}
int get_snd_effect(int funct) {
return 0;
}
void *PrepareVideoSound(int mixfreq, int buffsize) {
return 0;
}
char LoadNextVideoFrame(void *buffer, char *data, int size, short *xlat, short *accnums, int32_t *writepos) {
return 0;
}
void DoneVideoSound(void *buffer) {
}

15
platform/sdl/sound.h Normal file
View file

@ -0,0 +1,15 @@
/*
* sound.h
*
* Created on: 26. 1. 2025
* Author: ondra
*/
#ifndef PLATFORM_SDL_SOUND_H_
#define PLATFORM_SDL_SOUND_H_
#endif /* PLATFORM_SDL_SOUND_H_ */

View file

@ -1,6 +1,8 @@
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/tests/)
set(testFiles sdl_minimal_test.cpp sdl_surface_test.cpp
sdl_mouse.cpp
sdl_update_texture.cpp
)
foreach (testFile ${testFiles})

View file

@ -0,0 +1,79 @@
#include <SDL2/SDL.h>
#include <iostream>
int main(int argc, char* argv[]) {
if (SDL_Init(SDL_INIT_VIDEO) != 0) {
std::cerr << "SDL_Init Error: " << SDL_GetError() << std::endl;
return 1;
}
SDL_Window* window = SDL_CreateWindow("SDL Mouse Event Example", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, 800, 600, SDL_WINDOW_RESIZABLE);
if (!window) {
std::cerr << "SDL_CreateWindow Error: " << SDL_GetError() << std::endl;
SDL_Quit();
return 1;
}
SDL_Renderer* renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_ACCELERATED);
if (!renderer) {
std::cerr << "SDL_CreateRenderer Error: " << SDL_GetError() << std::endl;
SDL_DestroyWindow(window);
SDL_Quit();
return 1;
}
SDL_Event e;
bool quit = false;
int isFullscreen = 0;
while (!quit) {
while (SDL_PollEvent(&e)) {
if (e.type == SDL_QUIT) {
quit = true;
} else if (e.type == SDL_MOUSEMOTION) {
// Získání souřadnic myši
int mouseX = e.motion.x, mouseY = e.motion.y;
// Přepočet souřadnic na poměr vůči rozměrům okna
int windowWidth, windowHeight;
SDL_GetWindowSize(window, &windowWidth, &windowHeight);
float normalizedX = (float)mouseX / windowWidth;
float normalizedY = (float)mouseY / windowHeight;
std::cout << "Mouse moved to: (" << mouseX << ", " << mouseY << ") -> Normalized: ("
<< normalizedX << ", " << normalizedY << ")" << std::endl;
} else if (e.type == SDL_MOUSEBUTTONDOWN || e.type == SDL_MOUSEBUTTONUP) {
int mouseX = e.button.x, mouseY = e.button.y;
int button = e.button.button;
if (e.type == SDL_MOUSEBUTTONDOWN) {
std::cout << "Mouse button pressed at: (" << mouseX << ", " << mouseY << ") button " << button << std::endl;
} else {
std::cout << "Mouse button released at: (" << mouseX << ", " << mouseY << ") button " << button << std::endl;
}
} else if (e.type == SDL_MOUSEWHEEL) {
if (e.wheel.y > 0) {
std::cout << "Mouse wheel scrolled up." << std::endl;
} else if (e.wheel.y < 0) {
std::cout << "Mouse wheel scrolled down." << std::endl;
}
} else if (e.type == SDL_KEYDOWN) {
if (e.key.keysym.sym == SDLK_RETURN && (e.key.keysym.mod & KMOD_ALT)) {
// Přepnutí mezi fullscreen a oknem
isFullscreen = !isFullscreen;
SDL_SetWindowFullscreen(window, isFullscreen ? SDL_WINDOW_FULLSCREEN_DESKTOP : 0);
}
}
}
// Renderování a další logika hry
SDL_RenderClear(renderer);
SDL_RenderPresent(renderer);
}
SDL_DestroyRenderer(renderer);
SDL_DestroyWindow(window);
SDL_Quit();
return 0;
}

View file

@ -4,7 +4,7 @@
#define WIDTH 640
#define HEIGHT 480
#define PITCH 1024 // Pro optimalizaci paměti (pitch může být širší než WIDTH)
int main(int argc, char *argv[]) {
// Inicializace SDL
@ -14,14 +14,14 @@ int main(int argc, char *argv[]) {
}
// Vytvoření SDL okna
SDL_Window *window = SDL_CreateWindow("DOS Game Port", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, WIDTH, HEIGHT, 0);
SDL_Window *window = SDL_CreateWindow("DOS Game Port", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, WIDTH, HEIGHT, SDL_WINDOW_RESIZABLE);
if (!window) {
fprintf(stderr, "Chyba při vytváření okna: %s\n", SDL_GetError());
SDL_Quit();
return 1;
}
// Vytvoření rendereru (pouze pro zobrazení)
// Vytvoření SDL rendereru
SDL_Renderer *renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_ACCELERATED);
if (!renderer) {
fprintf(stderr, "Chyba při vytváření rendereru: %s\n", SDL_GetError());
@ -30,9 +30,9 @@ int main(int argc, char *argv[]) {
return 1;
}
// Vytvoření SDL Surface (backbuffer)
SDL_Texture *texture = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_RGB565,SDL_TEXTUREACCESS_STREAMING, WIDTH, HEIGHT);
if (!texture) {
// Vytvoření softwarového backbufferu (surface)
SDL_Surface *backbuffer = SDL_CreateRGBSurfaceWithFormat(0, PITCH, HEIGHT, 16, SDL_PIXELFORMAT_RGB565);
if (!backbuffer) {
fprintf(stderr, "Chyba při vytváření surface: %s\n", SDL_GetError());
SDL_DestroyRenderer(renderer);
SDL_DestroyWindow(window);
@ -40,31 +40,56 @@ int main(int argc, char *argv[]) {
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
}
// Vytvoření textury pro zobrazení backbufferu
SDL_Texture *texture = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_RGB565, SDL_TEXTUREACCESS_STREAMING, WIDTH, HEIGHT);
if (!texture) {
fprintf(stderr, "Chyba při vytváření textury: %s\n", SDL_GetError());
SDL_FreeSurface(backbuffer);
SDL_DestroyRenderer(renderer);
SDL_DestroyWindow(window);
SDL_Quit();
return 1;
}
SDL_UnlockTexture(texture);
// Hlavní smyčka
int running = 1;
int frame = 0;
while (running) {
frame++;
SDL_Event event;
while (SDL_PollEvent(&event)) {
if (event.type == SDL_QUIT) {
running = 0;
}
}
SDL_RenderClear(renderer);
SDL_RenderCopy(renderer, texture, NULL, NULL);
SDL_RenderPresent(renderer);
// Přímý přístup do paměti backbufferu
Uint16 *pixels = (Uint16 *)backbuffer->pixels;
int pitch = backbuffer->pitch / 2; // Pitch v počtu pixelů (ne bajtů)
SDL_Delay(3000); // Zobrazení okna na 3 sekundy
// Software rendering - příklad (čtení a zápis do backbufferu)
for (int y = 0; y < HEIGHT; y++) {
for (int x = 0; x < WIDTH; x++) {
Uint16 color = (x ^ y ^ frame) & 0xFFFF; // Vzor barvy (testovací)
pixels[y * pitch + x] = color; // Zápis pixelu
}
}
// Kopírování backbufferu do textury
SDL_UpdateTexture(texture, NULL, backbuffer->pixels, backbuffer->pitch);
// Vykreslení textury na obrazovku
SDL_RenderClear(renderer);
SDL_RenderCopy(renderer, texture, NULL, NULL);
SDL_RenderPresent(renderer);
// Zpoždění pro demonstraci (30 FPS)
SDL_Delay(1000 / 30);
}
// Uvolnění zdrojů
SDL_DestroyTexture(texture);
SDL_FreeSurface(backbuffer);
SDL_DestroyRenderer(renderer);
SDL_DestroyWindow(window);
SDL_Quit();

View file

@ -0,0 +1,91 @@
#include <SDL2/SDL.h>
#include <stdio.h>
#include <stdlib.h>
#define WIDTH 640
#define HEIGHT 480
#define PITCH 1024 // Pro optimalizaci paměti (pitch může být širší než WIDTH)
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, SDL_WINDOW_RESIZABLE);
if (!window) {
fprintf(stderr, "Chyba při vytváření okna: %s\n", SDL_GetError());
SDL_Quit();
return 1;
}
// Vytvoření SDL rendereru
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í textury pro zobrazení backbufferu
SDL_Texture *texture = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_RGB565, SDL_TEXTUREACCESS_STREAMING, WIDTH, HEIGHT);
if (!texture) {
fprintf(stderr, "Chyba při vytváření textury: %s\n", SDL_GetError());
SDL_DestroyRenderer(renderer);
SDL_DestroyWindow(window);
SDL_Quit();
return 1;
}
uint16_t *pixels = new uint16_t[HEIGHT*WIDTH];
int pitch = WIDTH;
// Hlavní smyčka
int running = 1;
int frame = 0;
while (running) {
frame++;
SDL_Event event;
while (SDL_PollEvent(&event)) {
if (event.type == SDL_QUIT) {
running = 0;
}
}
// Přímý přístup do paměti backbufferu
// Software rendering - příklad (čtení a zápis do backbufferu)
for (int y = 0; y < HEIGHT; y++) {
for (int x = 0; x < WIDTH; x++) {
Uint16 color = (x ^ y ^ frame) & 0xFFFF; // Vzor barvy (testovací)
pixels[y * pitch + x] = color; // Zápis pixelu
}
}
// Kopírování backbufferu do textury
SDL_UpdateTexture(texture, NULL, pixels, pitch*2);
// Vykreslení textury na obrazovku
SDL_RenderClear(renderer);
SDL_RenderCopy(renderer, texture, NULL, NULL);
SDL_RenderPresent(renderer);
// Zpoždění pro demonstraci (30 FPS)
SDL_Delay(1000 / 30);
}
// Uvolnění zdrojů
SDL_DestroyTexture(texture);
SDL_DestroyRenderer(renderer);
SDL_DestroyWindow(window);
SDL_Quit();
delete [] pixels;
return 0;
}