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

@ -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>