mirror of
https://github.com/ondra-novak/gates_of_skeldal.git
synced 2025-07-13 01:41:59 -04:00
libs compiles
This commit is contained in:
parent
1b0f7fe0c2
commit
a7278bac40
121 changed files with 1528 additions and 1731 deletions
20
libs/CMakeLists.txt
Normal file
20
libs/CMakeLists.txt
Normal file
|
@ -0,0 +1,20 @@
|
|||
SET(files basicobj.c
|
||||
bgraph2.c
|
||||
bgraph2a.c
|
||||
bmouse.c
|
||||
devices.c
|
||||
event.c
|
||||
gui.c
|
||||
inicfg.c
|
||||
memman.c
|
||||
mgifmapmem.c
|
||||
mgifmem.c
|
||||
mgifplaya.c
|
||||
pcx.c
|
||||
strlite.c
|
||||
wav_mem.c
|
||||
strlists.c
|
||||
swaper.c )
|
||||
|
||||
add_library(skeldal_libs ${files})
|
||||
|
331
libs/basicobj.c
331
libs/basicobj.c
|
@ -14,7 +14,7 @@
|
|||
#include "gui.h"
|
||||
#include "basicobj.h"
|
||||
|
||||
#define MEMTEXT "Pamˆt: "
|
||||
#define MEMTEXT "Pam<EFBFBD>t: "
|
||||
|
||||
#define E_STATUS_LINE 60
|
||||
|
||||
|
@ -51,9 +51,9 @@ CTL3D *def_border(int btype,int color)
|
|||
return &ctl;
|
||||
}
|
||||
|
||||
void sample_init(OBJREC *o,char *title)
|
||||
void sample_init(OBJREC *o,va_list params)
|
||||
{
|
||||
title=get_title(title);
|
||||
char *title=va_arg(params, char *);
|
||||
o->userptr=(void *)getmem(strlen(title)+1);
|
||||
strcpy((char *)o->userptr,title);
|
||||
}
|
||||
|
@ -89,17 +89,17 @@ void sample_event(EVENT_MSG *msg,OBJREC *o)
|
|||
|
||||
void sample(OBJREC *o)
|
||||
{
|
||||
o->runs[0]=sample_init;
|
||||
o->runs[1]=sample_draw;
|
||||
o->runs[2]=sample_event;
|
||||
//o->runs[3]=sample_done;
|
||||
o->call_init=sample_init;
|
||||
o->call_draw=sample_draw;
|
||||
o->call_event=sample_event;
|
||||
//o->call_done=sample_done;
|
||||
}
|
||||
|
||||
//------------------------------------------
|
||||
void button_init(OBJREC *o,char *title)
|
||||
void button_init(OBJREC *o,va_list params)
|
||||
{
|
||||
char *v;
|
||||
title=get_title(title);
|
||||
char *title=va_arg(params, char *);
|
||||
o->userptr=(void *)getmem(strlen(title)+1);
|
||||
strcpy((char *)o->userptr,title);
|
||||
v=(char *)o->data;
|
||||
|
@ -176,19 +176,19 @@ void button_event(EVENT_MSG *msg,OBJREC *o)
|
|||
|
||||
void button(OBJREC *o)
|
||||
{
|
||||
o->runs[0]=button_init;
|
||||
o->runs[1]=button_draw;
|
||||
o->runs[2]=button_event;
|
||||
//o->runs[3]=button_done;
|
||||
o->call_init=button_init;
|
||||
o->call_draw=button_draw;
|
||||
o->call_event=button_event;
|
||||
//o->call_done=button_done;
|
||||
o->datasize=1;
|
||||
}
|
||||
|
||||
void button2(OBJREC *o)
|
||||
{
|
||||
o->runs[0]=button_init;
|
||||
o->runs[1]=button_draw2;
|
||||
o->runs[2]=button_event;
|
||||
//o->runs[3]=button_done;
|
||||
o->call_init=button_init;
|
||||
o->call_draw=button_draw2;
|
||||
o->call_event=button_event;
|
||||
//o->call_done=button_done;
|
||||
o->datasize=1;
|
||||
}
|
||||
|
||||
|
@ -242,20 +242,6 @@ void draw_status_line(char *c)
|
|||
|
||||
void *status_mem_info(EVENT_MSG *msg)
|
||||
{
|
||||
char *c;
|
||||
long l;
|
||||
static char memtext[]=MEMTEXT;
|
||||
MEMORYSTATUS mem;
|
||||
|
||||
if (msg->msg==E_INIT) return &status_mem_info;
|
||||
c=(char *)msg->data;
|
||||
strcpy(c,memtext);
|
||||
c+=strlen(memtext);
|
||||
get_mem_info(&mem);
|
||||
l=mem.dwAvailPageFile;
|
||||
sprintf(c,"%d KB ",l/1024);
|
||||
c=strchr(c,'\0');
|
||||
msg->data=(void *)c;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -266,78 +252,72 @@ void *status_idle(EVENT_MSG *msg)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
void status_line(EVENT_MSG *msg,T_EVENT_ROOT **user_data)
|
||||
{
|
||||
T_EVENT_ROOT **p;
|
||||
static char st_line[256],oldline[256]={"\0"};
|
||||
EVENT_MSG tg;
|
||||
static char recurse=1;
|
||||
static int enter_event_msg_to(EVENT_MSG *msg, void *ctx) {
|
||||
T_EVENT_ROOT **p = (T_EVENT_ROOT **)ctx;
|
||||
enter_event(p, msg);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if(msg->msg==E_INIT)
|
||||
if (recurse)
|
||||
{
|
||||
T_EVENT_ROOT *p;
|
||||
recurse=0;
|
||||
send_message(E_ADD,E_IDLE,status_idle);
|
||||
send_message(E_ADD,E_REDRAW,status_idle);
|
||||
p=NULL;
|
||||
*user_data=p;
|
||||
draw_status_line(NULL);
|
||||
recurse=1;
|
||||
return;
|
||||
}
|
||||
else return;
|
||||
shift_msg(msg,tg);
|
||||
if (tg.msg==E_REDRAW)
|
||||
{
|
||||
void status_line(EVENT_MSG *msg, T_EVENT_ROOT **user_data) {
|
||||
T_EVENT_ROOT **p;
|
||||
static char st_line[256], oldline[256] = { "\0" };
|
||||
static char recurse = 1;
|
||||
|
||||
if (msg->msg == E_INIT)
|
||||
if (recurse) {
|
||||
T_EVENT_ROOT *p;
|
||||
recurse = 0;
|
||||
send_message(E_ADD, E_IDLE, status_idle);
|
||||
send_message(E_ADD, E_REDRAW, status_idle);
|
||||
p = NULL;
|
||||
*user_data = p;
|
||||
draw_status_line(NULL);
|
||||
recurse = 1;
|
||||
return;
|
||||
} else
|
||||
return;
|
||||
|
||||
msg->msg = va_arg(msg->data, int);
|
||||
if (msg->msg == E_REDRAW) {
|
||||
draw_status_line(oldline);
|
||||
return;
|
||||
}
|
||||
p = user_data;
|
||||
if (msg->msg == E_IDLE) {
|
||||
char *c = st_line;
|
||||
send_message_to(enter_event_msg_to, p, E_IDLE, &c);
|
||||
if (strcmp(st_line, oldline)) {
|
||||
draw_status_line(st_line);
|
||||
strcpy(oldline, st_line);
|
||||
}
|
||||
p=user_data;
|
||||
if (tg.msg==E_IDLE)
|
||||
{
|
||||
EVENT_MSG msg;
|
||||
|
||||
msg.msg=E_IDLE;
|
||||
msg.data=&st_line;
|
||||
enter_event(p,&msg);
|
||||
if (strcmp(st_line,oldline))
|
||||
{
|
||||
draw_status_line(st_line);
|
||||
strcpy(oldline,st_line);
|
||||
}
|
||||
}
|
||||
else
|
||||
tree_basics(p,&tg);
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
tree_basics(p, msg);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
void *mouse_xy(EVENT_MSG *msg)
|
||||
{
|
||||
char *c;
|
||||
char **c = va_arg(msg->data, char **);
|
||||
|
||||
if (msg->msg==E_INIT) return &mouse_xy;
|
||||
c=(char *)msg->data;
|
||||
sprintf(c," X: %d Y: %d",ms_last_event.x,ms_last_event.y);
|
||||
c=strchr(c,'\0');
|
||||
msg->data=(void *)c;
|
||||
sprintf(*c," X: %d Y: %d",ms_last_event.x,ms_last_event.y);
|
||||
*c=strchr(*c,'\0');
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void *show_time(EVENT_MSG *msg)
|
||||
{
|
||||
char *c;
|
||||
char **c = va_arg(msg->data, char **);
|
||||
time_t t;
|
||||
struct tm cas;
|
||||
|
||||
if (msg->msg==E_INIT) return &show_time;
|
||||
c=(char *)msg->data;
|
||||
t=time(NULL);
|
||||
cas=*localtime(&t);
|
||||
|
||||
sprintf(c,"%02d:%02d:%02d ",cas.tm_hour,cas.tm_min,cas.tm_sec);
|
||||
c=strchr(c,'\0');
|
||||
msg->data=(void *)c;
|
||||
sprintf(*c,"%02d:%02d:%02d ",cas.tm_hour,cas.tm_min,cas.tm_sec);
|
||||
*c=strchr(*c,'\0');
|
||||
return NULL;
|
||||
}
|
||||
//------------------------------------------
|
||||
|
@ -380,8 +360,8 @@ void win_label_move(EVENT_MSG *msg,OBJREC *o)
|
|||
static char run=0;
|
||||
static word xref,yref;
|
||||
static WINDOW w;
|
||||
static moved=0;
|
||||
static drawed=0;
|
||||
static int moved=0;
|
||||
static int drawed=0;
|
||||
|
||||
o;
|
||||
if (msg->msg==E_INIT) return;
|
||||
|
@ -454,10 +434,10 @@ return;
|
|||
|
||||
void win_label(OBJREC *o)
|
||||
{
|
||||
o->runs[0]=sample_init;
|
||||
o->runs[1]=win_label_draw;
|
||||
o->runs[2]=win_label_move;
|
||||
//o->runs[3]=button_done;
|
||||
o->call_init=sample_init;
|
||||
o->call_draw=win_label_draw;
|
||||
o->call_event=win_label_move;
|
||||
//o->call_done=button_done;
|
||||
o->datasize=0;
|
||||
}
|
||||
|
||||
|
@ -524,50 +504,53 @@ void check_box_event(EVENT_MSG *msg,OBJREC *o)
|
|||
|
||||
void check_box(OBJREC *o)
|
||||
{
|
||||
o->runs[0]=sample_init;
|
||||
o->runs[1]=check_box_draw;
|
||||
o->runs[2]=check_box_event;
|
||||
o->call_init=sample_init;
|
||||
o->call_draw=check_box_draw;
|
||||
o->call_event=check_box_event;
|
||||
o->datasize=4;
|
||||
}
|
||||
|
||||
//------------------------------------------
|
||||
void radio_butts_init(OBJREC *o,long *params)
|
||||
void radio_butts_init(OBJREC *o,va_list params)
|
||||
{
|
||||
char *c,*z;
|
||||
long cnt=0,*q,*d;
|
||||
int32_t cnt=0,*q;
|
||||
int i;
|
||||
va_list d;
|
||||
|
||||
d=params;
|
||||
for (i=0;i<*params;i++)
|
||||
va_copy(d, params);
|
||||
int rcount = va_arg(d, int);
|
||||
for (i=0;i<rcount;i++)
|
||||
{
|
||||
d+=1;
|
||||
c=get_title(d);
|
||||
c=va_arg(d, char *);
|
||||
cnt+=strlen(c);cnt++;
|
||||
}
|
||||
q=(long *)getmem(cnt+8);
|
||||
va_end(d);
|
||||
q=(int32_t *)getmem(cnt+8);
|
||||
o->userptr=(void *)q;
|
||||
*q++=1;*q++=*params;
|
||||
d=params;
|
||||
z=(char *)q;
|
||||
for (i=0;i<*params;i++)
|
||||
*q++=1;*q++=rcount;
|
||||
va_copy(d, params);
|
||||
va_arg(d, int);
|
||||
for (i=0;i<rcount;i++)
|
||||
{
|
||||
d+=1;
|
||||
c=get_title(d);
|
||||
c=va_arg(d, char *);
|
||||
strcpy(z,c);
|
||||
z=strchr(z,'\0');z++;
|
||||
}
|
||||
va_end(d);
|
||||
}
|
||||
|
||||
|
||||
void radio_butts_draw(int x1,int y1,int x2,int y2,OBJREC *o)
|
||||
{
|
||||
int step,size,sizpul,i,cr;
|
||||
long *params;
|
||||
int32_t *params;
|
||||
char *texts;
|
||||
CTL3D ctl;
|
||||
|
||||
cr=curcolor;
|
||||
highlight(&ctl,curcolor);
|
||||
params=(long *)o->userptr;
|
||||
params=(int32_t *)o->userptr;
|
||||
if (*params) bar(x1,y1,x2,y2);
|
||||
step=(y2-y1)/(*(params+1));
|
||||
size=(step*9)/10;
|
||||
|
@ -583,7 +566,7 @@ void radio_butts_draw(int x1,int y1,int x2,int y2,OBJREC *o)
|
|||
curcolor=ctl.light;
|
||||
line(x1+sizpul+1,y1,x1+size,y1+sizpul);
|
||||
line(x1+size,y1+sizpul,x1+sizpul+1,y1+size-1);
|
||||
if (*(long *)o->data==i) curcolor=0;else curcolor=cr;
|
||||
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);
|
||||
|
@ -609,12 +592,12 @@ void radio_butts_event(EVENT_MSG *msg,OBJREC *o)
|
|||
ms=get_mouse(msg);
|
||||
if (ms->event_type & 0x02)
|
||||
{
|
||||
sel=(ms->y-o->locy)/(o->ys/(*((long *)o->userptr+1)));
|
||||
if (sel>=*((long *)o->userptr+1)) sel=*((long *)o->userptr+1)-1;
|
||||
*(long *)o->data=sel;
|
||||
*(long *)o->userptr=0;
|
||||
sel=(ms->y-o->locy)/(o->ys/(*((int32_t *)o->userptr+1)));
|
||||
if (sel>=*((int32_t *)o->userptr+1)) sel=*((int32_t *)o->userptr+1)-1;
|
||||
*(int32_t *)o->data=sel;
|
||||
*(int32_t *)o->userptr=0;
|
||||
redraw_object(o);
|
||||
*(long *)o->userptr=1;
|
||||
*(int32_t *)o->userptr=1;
|
||||
set_change();
|
||||
}
|
||||
}
|
||||
|
@ -624,9 +607,9 @@ void radio_butts_event(EVENT_MSG *msg,OBJREC *o)
|
|||
|
||||
void radio_butts(OBJREC *o)
|
||||
{
|
||||
o->runs[0]=radio_butts_init;
|
||||
o->runs[1]=radio_butts_draw;
|
||||
o->runs[2]=radio_butts_event;;
|
||||
o->call_init=radio_butts_init;
|
||||
o->call_draw=radio_butts_draw;
|
||||
o->call_event=radio_butts_event;;
|
||||
o->datasize=4;
|
||||
}
|
||||
|
||||
|
@ -670,21 +653,32 @@ void toggle_button_event(EVENT_MSG *msg,OBJREC *o)
|
|||
|
||||
void toggle_button(OBJREC *o)
|
||||
{
|
||||
o->runs[0]=button_init;
|
||||
o->runs[1]=button_draw;
|
||||
o->runs[2]=toggle_button_event;
|
||||
o->call_init=button_init;
|
||||
o->call_draw=button_draw;
|
||||
o->call_event=toggle_button_event;
|
||||
o->datasize=1;
|
||||
}
|
||||
|
||||
//------------------------------------------
|
||||
|
||||
void input_line_init(OBJREC *o,int *len)
|
||||
typedef struct input_line_state_st {
|
||||
int len;
|
||||
int start;
|
||||
int minimum;
|
||||
int maximum;
|
||||
char *format;
|
||||
} input_line_state;
|
||||
|
||||
void input_line_init(OBJREC *o,va_list len)
|
||||
{
|
||||
o->datasize=(*len)+1;
|
||||
o->userptr=malloc(20);
|
||||
memset(o->userptr,0,20);
|
||||
memcpy(o->userptr,len,4);
|
||||
memcpy((int *)o->userptr+2,len+1,12);
|
||||
input_line_state *st = malloc(sizeof(input_line_state));
|
||||
st->len = va_arg(len, int);;
|
||||
st->start = 0;
|
||||
st->minimum = va_arg(len, int);
|
||||
st->maximum = va_arg(len, int);
|
||||
st->format = va_arg(len, char * );
|
||||
o->datasize=st->len;
|
||||
o->userptr = st;
|
||||
}
|
||||
|
||||
void input_line_draw(int x1,int y1, int x2, int y2, OBJREC *o)
|
||||
|
@ -700,7 +694,8 @@ void input_line_draw(int x1,int y1, int x2, int y2, OBJREC *o)
|
|||
c=(char *)o->data;
|
||||
if (!*c) return;
|
||||
len=strlen(c);
|
||||
shift=*((int *)o->userptr+1);
|
||||
input_line_state *st = o->userptr;
|
||||
shift=st->start;
|
||||
if (shift>=len) shift=0;
|
||||
c+=shift;
|
||||
d[0]=*c++;x=x1+text_width(d);
|
||||
|
@ -714,14 +709,14 @@ void input_line_draw(int x1,int y1, int x2, int y2, OBJREC *o)
|
|||
|
||||
void input_line_event(EVENT_MSG *msg,OBJREC *o)
|
||||
{
|
||||
static cursor=0;
|
||||
static int cursor=0;
|
||||
int *len,*start,slen;
|
||||
char *c;
|
||||
static char *save;
|
||||
static char clear_kontext;
|
||||
|
||||
len=(int *)o->userptr;
|
||||
start=len+1;
|
||||
input_line_state *st = o->userptr;
|
||||
start=&st->start;
|
||||
c=(char *)o->data;
|
||||
slen=strlen(c);
|
||||
switch (msg->msg)
|
||||
|
@ -771,12 +766,14 @@ void input_line_event(EVENT_MSG *msg,OBJREC *o)
|
|||
break;
|
||||
case E_KEYBOARD:
|
||||
{
|
||||
char key;
|
||||
|
||||
int code = va_arg(msg->data, int);
|
||||
char key;
|
||||
|
||||
cancel_event();
|
||||
key=(*(int *)msg->data) & 0xff;
|
||||
key= code & 0xff;
|
||||
if (!key)
|
||||
switch (*(int *)msg->data >> 8)
|
||||
switch (code >> 8)
|
||||
{
|
||||
case 'M':if (cursor<slen) cursor++;break;
|
||||
case 'K':if (cursor>0) cursor--;break;
|
||||
|
@ -813,28 +810,31 @@ void input_line_event(EVENT_MSG *msg,OBJREC *o)
|
|||
}
|
||||
|
||||
|
||||
|
||||
void input_line_done(OBJREC *o) {
|
||||
free(o->userptr);
|
||||
}
|
||||
|
||||
|
||||
void input_line(OBJREC *o)
|
||||
{
|
||||
o->runs[0]=input_line_init;
|
||||
o->runs[1]=input_line_draw;
|
||||
o->runs[2]=input_line_event;
|
||||
o->call_init=input_line_init;
|
||||
o->call_draw=input_line_draw;
|
||||
o->call_event=input_line_event;
|
||||
o->call_done = input_line_done;
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------------------
|
||||
void label(OBJREC *o)
|
||||
{
|
||||
o->runs[0]=sample_init;
|
||||
o->runs[1]=sample_draw;
|
||||
o->call_init=sample_init;
|
||||
o->call_draw=sample_draw;
|
||||
}
|
||||
|
||||
void mid_label(OBJREC *o)
|
||||
{
|
||||
o->runs[0]=sample_init;
|
||||
o->runs[1]=mid_label_draw;
|
||||
o->call_init=sample_init;
|
||||
o->call_draw=mid_label_draw;
|
||||
}
|
||||
//-------------------------------------------------------------
|
||||
|
||||
|
@ -845,16 +845,16 @@ typedef struct scr_button
|
|||
char *title;
|
||||
}SCR_BUTTON;
|
||||
|
||||
void scroll_button_init(OBJREC *o,int *param)
|
||||
void scroll_button_init(OBJREC *o,va_list param)
|
||||
{ // int step, int maxvalue,char *title
|
||||
char *v;
|
||||
SCR_BUTTON *p;
|
||||
|
||||
o->userptr=getmem(sizeof(SCR_BUTTON));
|
||||
p=(SCR_BUTTON *)o->userptr;
|
||||
p->step=*param++;
|
||||
p->maxvalue=*param++;
|
||||
p->title=(char *)*param++;
|
||||
p->step=va_arg(param, int);
|
||||
p->maxvalue=va_arg(param, int);
|
||||
p->title=va_arg(param, char *);
|
||||
v=(char *)o->data;
|
||||
*v=0;
|
||||
}
|
||||
|
@ -912,9 +912,9 @@ void scroll_button_event(EVENT_MSG *msg,OBJREC *o)
|
|||
|
||||
void scroll_button(OBJREC *o)
|
||||
{
|
||||
o->runs[0]=scroll_button_init;
|
||||
o->runs[1]=scroll_button_draw;
|
||||
o->runs[2]=scroll_button_event;
|
||||
o->call_init=scroll_button_init;
|
||||
o->call_draw=scroll_button_draw;
|
||||
o->call_event=scroll_button_event;
|
||||
o->datasize=1;
|
||||
}
|
||||
|
||||
|
@ -930,16 +930,16 @@ typedef struct scr_bar
|
|||
int stepsize;
|
||||
}SCR_BAR;
|
||||
|
||||
void scroll_bar_init(OBJREC *o,int *param)
|
||||
void scroll_bar_init(OBJREC *o,va_list param)
|
||||
{
|
||||
SCR_BAR *p;
|
||||
|
||||
o->userptr=getmem(sizeof(SCR_BAR));
|
||||
p=(SCR_BAR *)o->userptr;
|
||||
p->minvalue=*param++;
|
||||
p->maxvalue=*param++;
|
||||
p->parview=*param++;
|
||||
p->bgcolor=*param++;
|
||||
p->minvalue=va_arg(param, int);
|
||||
p->maxvalue=va_arg(param, int);
|
||||
p->parview=va_arg(param, int);
|
||||
p->bgcolor=va_arg(param, int);
|
||||
p->barsize=10;
|
||||
p->stepsize=10;
|
||||
}
|
||||
|
@ -1010,9 +1010,8 @@ void scroll_bar_v_event(EVENT_MSG *msg,OBJREC *o)
|
|||
break;
|
||||
case E_CONTROL:
|
||||
{
|
||||
int *q;
|
||||
int *q = va_arg(msg->data, int *);
|
||||
|
||||
q=msg->data;
|
||||
p->minvalue=*q++;
|
||||
p->maxvalue=*q++;
|
||||
p->parview=*q++;
|
||||
|
@ -1024,9 +1023,9 @@ void scroll_bar_v_event(EVENT_MSG *msg,OBJREC *o)
|
|||
|
||||
void scroll_bar_v(OBJREC *o)
|
||||
{
|
||||
o->runs[0]=scroll_bar_init;
|
||||
o->runs[1]=scroll_bar_v_draw;
|
||||
o->runs[2]=scroll_bar_v_event;
|
||||
o->call_init=scroll_bar_init;
|
||||
o->call_draw=scroll_bar_v_draw;
|
||||
o->call_event=scroll_bar_v_event;
|
||||
o->datasize=4;
|
||||
}
|
||||
|
||||
|
@ -1053,7 +1052,7 @@ void scroll_support()
|
|||
set_value(0,id,&x);
|
||||
r=o_aktual;
|
||||
o_aktual=o;
|
||||
o->events[3]();
|
||||
o->on_change();
|
||||
o_aktual=r;
|
||||
}
|
||||
//-------------------------------------------------------------
|
||||
|
@ -1130,9 +1129,9 @@ void scroll_bar_h_event(EVENT_MSG *msg,OBJREC *o)
|
|||
|
||||
void scroll_bar_h(OBJREC *o)
|
||||
{
|
||||
o->runs[0]=scroll_bar_init;
|
||||
o->runs[1]=scroll_bar_h_draw;
|
||||
o->runs[2]=scroll_bar_h_event;
|
||||
o->call_init=scroll_bar_init;
|
||||
o->call_draw=scroll_bar_h_draw;
|
||||
o->call_event=scroll_bar_h_event;
|
||||
o->datasize=4;
|
||||
|
||||
}
|
||||
|
@ -1214,7 +1213,7 @@ int msg_box(char *title, char icone, char *text, ... )
|
|||
sz=(winx/(temp2+1))>>1;
|
||||
if (sz<text_width(*c)) sz=text_width(*c);
|
||||
define((i),i*winx/(temp2+1)-(sz>>1),10,sz+5,20,3,button,*c);
|
||||
property(ctl,NULL,flat_color(0),RGB555(24,24,24));on_change(terminate);
|
||||
property(ctl,NULL,flat_color(0),RGB555(24,24,24));on_control_change(terminate_gui);
|
||||
c++;
|
||||
}
|
||||
set_window_modal();
|
||||
|
@ -1254,8 +1253,8 @@ void resizer_event(EVENT_MSG *msg,OBJREC *o)
|
|||
static char run=0;
|
||||
static word xref,yref;
|
||||
static WINDOW w;
|
||||
static moved=0;
|
||||
static drawed=0;
|
||||
static int moved=0;
|
||||
static int drawed=0;
|
||||
|
||||
o;
|
||||
if (msg->msg==E_INIT) return;
|
||||
|
@ -1326,7 +1325,7 @@ if (msg->msg!=E_TIMER) msg->msg=-1;
|
|||
|
||||
void resizer(OBJREC *o)
|
||||
{
|
||||
//o->runs[0]=resizer_init;
|
||||
o->runs[1]=resizer_draw;
|
||||
o->runs[2]=resizer_event;
|
||||
//o->call_init=resizer_init;
|
||||
o->call_draw=resizer_draw;
|
||||
o->call_event=resizer_event;
|
||||
}
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
#define MEMTEXT "Pamˆt: "
|
||||
|
||||
#define E_STATUS_LINE 60
|
||||
|
||||
|
|
|
@ -17,12 +17,12 @@ byte fontdsize=0;
|
|||
byte *palmem,*xlatmem;
|
||||
void (*showview)(word,word,word,word);
|
||||
char line480=0;
|
||||
long screen_buffer_size=512000;
|
||||
int32_t screen_buffer_size=512000;
|
||||
|
||||
void *mscursor,*mssavebuffer=NULL;
|
||||
integer mscuroldx=0,mscuroldy=0;
|
||||
integer msshowx=0,msshowy=0;
|
||||
long pictlen; // Tato promenna je pouze pouzita v BGRAPH1.ASM
|
||||
int32_t pictlen; // Tato promenna je pouze pouzita v BGRAPH1.ASM
|
||||
|
||||
void line32(word x1,word y1, word x2, word y2)
|
||||
{
|
||||
|
@ -68,7 +68,7 @@ int initmode32()
|
|||
if (!(data.modeattr & MA_SUPP)) return -1;
|
||||
if (!(data.modeattr & MA_LINEARFBUF)) return -2;
|
||||
setvesamode(0x411e-line480*0xe,-1);
|
||||
lbuffer=(word *)physicalalloc((long)data.linearbuffer,screen_buffer_size);
|
||||
lbuffer=(word *)physicalalloc((int32_t)data.linearbuffer,screen_buffer_size);
|
||||
screen=lbuffer;
|
||||
linelen=640*2;
|
||||
showview=showview32;
|
||||
|
@ -83,7 +83,7 @@ int initmode256(void *paletefile)
|
|||
if (!(data.modeattr & MA_SUPP)) return -1;
|
||||
if (!(data.modeattr & MA_LINEARFBUF)) return -2;
|
||||
setvesamode(0x4100+line480,-1);
|
||||
lbuffer=(word *)physicalalloc((long)data.linearbuffer,screen_buffer_size>>1);
|
||||
lbuffer=(word *)physicalalloc((int32_t)data.linearbuffer,screen_buffer_size>>1);
|
||||
screen=lbuffer;
|
||||
linelen=640*2;
|
||||
palmem=(char *)paletefile;
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
#define point point32
|
||||
|
||||
word *GetScreenAdr();
|
||||
long GetScreenSizeBytes();
|
||||
int32_t GetScreenSizeBytes();
|
||||
word *GetBuffer2nd();
|
||||
void RedirectScreen(word *newaddr);
|
||||
void RestoreScreen();
|
||||
|
@ -14,15 +14,15 @@ void RedirectScreenBufferSecond();
|
|||
|
||||
|
||||
extern word curcolor,charcolors[7];
|
||||
extern long scr_linelen;
|
||||
extern long scr_linelen2;
|
||||
extern long dx_linelen;
|
||||
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;
|
||||
extern void (*showview)(word,word,word,word);
|
||||
extern char line480;
|
||||
extern long screen_buffer_size;
|
||||
extern int32_t screen_buffer_size;
|
||||
extern char banking;
|
||||
extern char __skip_change_line_test;
|
||||
extern char no_restore_mode;
|
||||
|
|
|
@ -8,21 +8,20 @@
|
|||
#include <stdlib.h>
|
||||
#include <malloc.h>
|
||||
//#include <graph.h>
|
||||
#include <conio.h>
|
||||
#include "bgraph.h"
|
||||
#include "memman.h"
|
||||
|
||||
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};
|
||||
long scr_linelen;
|
||||
long scr_linelen2;
|
||||
long dx_linelen;
|
||||
int32_t scr_linelen;
|
||||
int32_t scr_linelen2;
|
||||
int32_t dx_linelen;
|
||||
word *curfont,*writepos,writeposx;
|
||||
byte fontdsize=0;
|
||||
byte *palmem=NULL,*xlatmem=NULL;
|
||||
void (*showview)(word,word,word,word);
|
||||
char line480=0;
|
||||
long screen_buffer_size=0;
|
||||
int32_t screen_buffer_size=0;
|
||||
char banking=0;
|
||||
char screenstate=0;
|
||||
char __skip_change_line_test=0;
|
||||
|
@ -32,7 +31,7 @@ void *mscursor,*mssavebuffer=NULL;
|
|||
integer mscuroldx=0,mscuroldy=0;
|
||||
integer mscuroldxs=1,mscuroldys=1;
|
||||
char write_window=0;
|
||||
long pictlen; // Tato promenna je pouze pouzita v BGRAPH1.ASM
|
||||
int32_t pictlen; // Tato promenna je pouze pouzita v BGRAPH1.ASM
|
||||
|
||||
void text_mode();
|
||||
|
||||
|
@ -104,7 +103,7 @@ void write_vesa_info(int mode)
|
|||
getmodeinfo(&vesadata,mode);
|
||||
if (vesadata[0].modeattr & MA_SUPP)
|
||||
{
|
||||
if (vesadata[0].modeattr & MA_LINEARFBUF) sprintf(c,"%8Xh",(long)vesadata[0].linearbuffer); else strcpy(c,"None");
|
||||
if (vesadata[0].modeattr & MA_LINEARFBUF) sprintf(c,"%8Xh",(int32_t)vesadata[0].linearbuffer); else strcpy(c,"None");
|
||||
printf("Mode: %04X \n"
|
||||
"WinA %02X\n"
|
||||
"WinB %02X\n"
|
||||
|
@ -271,7 +270,7 @@ word *mapvesaadr1(word *a)
|
|||
{
|
||||
word bank;
|
||||
|
||||
bank=(long)a>>16;
|
||||
bank=(int32_t)a>>16;
|
||||
if (bank!=lastbank)
|
||||
{
|
||||
lastbank=bank;
|
||||
|
@ -284,7 +283,7 @@ word *mapvesaadr1(word *a)
|
|||
int386 (0x10,®s,®s); // window A
|
||||
}
|
||||
}
|
||||
return (word *)(((long)a & 0xffff)+0xa0000);
|
||||
return (word *)(((int32_t)a & 0xffff)+0xa0000);
|
||||
}
|
||||
|
||||
void switchvesabank(word bank)
|
||||
|
@ -318,7 +317,7 @@ int initmode256(void *paletefile)
|
|||
if (!(data.modeattr & MA_LINEARFBUF)) return initmode256b(paletefile);
|
||||
//write_vesa_info(0x101);
|
||||
setvesamode(0x4101,-1);
|
||||
if (lbuffer==NULL)lbuffer=(word *)physicalalloc((long)data.linearbuffer,screen_buffer_size>>1);
|
||||
if (lbuffer==NULL)lbuffer=(word *)physicalalloc((int32_t)data.linearbuffer,screen_buffer_size>>1);
|
||||
screen=lbuffer;
|
||||
linelen=640*2;
|
||||
palmem=(char *)paletefile;
|
||||
|
@ -417,7 +416,7 @@ void closemode()
|
|||
|
||||
}
|
||||
|
||||
static void showview_dx(word x,word y,word xs,word ys)
|
||||
void showview_dx(word x,word y,word xs,word ys)
|
||||
{
|
||||
// register longint a;
|
||||
|
||||
|
@ -427,7 +426,7 @@ static void showview_dx(word x,word y,word xs,word ys)
|
|||
xs+=2;ys+=2;
|
||||
if (x+xs>DxGetResX()) xs=DxGetResX()-x;
|
||||
if (y+ys>DxGetResY()) ys=DxGetResY()-y;
|
||||
DXCopyRects64(x,y,xs,ys);
|
||||
DXCopyRects64(x,y,xs,ys);
|
||||
}
|
||||
/*
|
||||
static void showview64b(word x,word y,word xs,word ys)
|
||||
|
@ -595,16 +594,16 @@ void set_aligned_position(int x,int y,char alignx,char aligny,char *text)
|
|||
|
||||
/*void pal_optimize()
|
||||
{
|
||||
long *stattable;
|
||||
int32_t *stattable;
|
||||
word *c;
|
||||
char *d;
|
||||
int i;
|
||||
long maxr,maxg,maxb,max;
|
||||
int32_t maxr,maxg,maxb,max;
|
||||
int j;
|
||||
|
||||
if (palmem==NULL) return;
|
||||
stattable=(long *)getmem(32768*sizeof(long));
|
||||
memset(stattable,0,32768*sizeof(long));
|
||||
stattable=(int32_t *)getmem(32768*sizeof(int32_t));
|
||||
memset(stattable,0,32768*sizeof(int32_t));
|
||||
c=screen;
|
||||
for(i=0;i<screen_buffer_size;i++,c++)
|
||||
stattable[*c & 0x7fff]++;
|
||||
|
@ -797,4 +796,4 @@ int init_empty_mode()
|
|||
screenstate=1;
|
||||
return 0;
|
||||
}
|
||||
*/
|
||||
*/
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
#include <skeldal_win.h>
|
||||
#include "types.h"
|
||||
#include "bgraph.h"
|
||||
#include <debug.h>
|
||||
|
||||
#include <string.h>
|
||||
|
||||
|
||||
void bar32(int x1,int y1, int x2, int y2)
|
||||
|
@ -28,17 +29,17 @@ void hor_line32(int x1,int y1,int x2)
|
|||
{
|
||||
word *begline;
|
||||
int i;
|
||||
unsigned long curcolor2=curcolor | (curcolor<<16);
|
||||
uint32_t curcolor2=curcolor | (curcolor<<16);
|
||||
|
||||
int mx = DxGetResX() - 1;
|
||||
int my = DxGetResY() - 1;
|
||||
|
||||
if (y1<0 || y1>my) return;
|
||||
if (x1>x2) swap_int(x1,x2);
|
||||
if (x1>x2) swap_int(x1,x2);
|
||||
if (x1<0) x1=0;
|
||||
if (x2>mx) x2=mx;
|
||||
begline=GetScreenAdr()+scr_linelen2*y1;
|
||||
for (i=x1;i<x2;i+=2) *(unsigned long *)(begline+i)=curcolor2;
|
||||
for (i=x1;i<x2;i+=2) *(uint32_t *)(begline+i)=curcolor2;
|
||||
if (i==x2) begline[i]=curcolor;
|
||||
}
|
||||
|
||||
|
@ -56,22 +57,22 @@ void ver_line32(int x1,int y1,int y2)
|
|||
begline=GetScreenAdr()+scr_linelen2*y1+x1;
|
||||
for (i=y1;i<=y2;i++,begline+=scr_linelen2) *begline=curcolor;
|
||||
}
|
||||
|
||||
|
||||
void hor_line_xor(int x1,int y1,int x2)
|
||||
{
|
||||
word *begline;
|
||||
int i;
|
||||
unsigned long curcolor2=curcolor | (curcolor<<16);
|
||||
uint32_t curcolor2=curcolor | (curcolor<<16);
|
||||
|
||||
int mx = DxGetResX() - 1;
|
||||
int my = DxGetResY() - 1;
|
||||
|
||||
if (y1<0 || y1>my) return;
|
||||
if (x1>x2) swap_int(x1,x2);
|
||||
if (x1>x2) swap_int(x1,x2);
|
||||
if (x1<0) x1=0;
|
||||
if (x2>mx) x2=mx;
|
||||
begline=GetScreenAdr()+scr_linelen2*y1;
|
||||
for (i=x1;i<x2;i+=2) *(unsigned long *)(begline+i)^=curcolor2;
|
||||
for (i=x1;i<x2;i+=2) *(uint32_t *)(begline+i)^=curcolor2;
|
||||
if (i==x2) begline[i]^=curcolor;
|
||||
}
|
||||
|
||||
|
@ -120,14 +121,14 @@ void char_32(word *posit,word *font,char znak)
|
|||
{
|
||||
|
||||
word *edi = posit;
|
||||
unsigned char *esi = font;
|
||||
unsigned char *esi = (unsigned char *)font;
|
||||
int al = znak;
|
||||
unsigned char dl,cl,ch,dh;
|
||||
word *ebx;
|
||||
|
||||
word ax = esi[al*2]+256*esi[al*2+1];
|
||||
if (ax == 0) goto chrend;
|
||||
esi += ax;
|
||||
esi += ax;
|
||||
dl = 0;
|
||||
cl = *esi++;
|
||||
ch = *esi++;
|
||||
|
@ -155,7 +156,7 @@ chr4: ebx+=scr_linelen2;
|
|||
if (cl!=0) goto chr6;
|
||||
chrend:;
|
||||
|
||||
|
||||
|
||||
/*
|
||||
|
||||
__asm
|
||||
|
@ -218,7 +219,7 @@ void char2_32(word *posit,word *font,char znak)
|
|||
mov edi,posit
|
||||
mov esi,font
|
||||
mov al,znak
|
||||
|
||||
|
||||
;edi - pozice na obrazovce
|
||||
;esi - ukazatel na font
|
||||
;al - znak
|
||||
|
@ -271,13 +272,13 @@ chr2end: ;konec
|
|||
word charsize(word *font,char znak)
|
||||
{
|
||||
|
||||
unsigned char *esi = font;
|
||||
unsigned char *esi = (unsigned char *)font;
|
||||
int al = znak;
|
||||
unsigned char cl,ch;
|
||||
|
||||
word ax = esi[al*2]+256*esi[al*2+1];
|
||||
if (ax == 0) return 0;
|
||||
esi += ax;
|
||||
esi += ax;
|
||||
cl = *esi++;
|
||||
ch = *esi++;
|
||||
ax = (int)cl+256*(int)ch;
|
||||
|
@ -321,9 +322,9 @@ void put_picture(word x,word y,void *p)
|
|||
{
|
||||
int i;
|
||||
int j;
|
||||
|
||||
|
||||
for (i=0;i<yss;i++,adr+=scr_linelen2,data+=(xs-xss))
|
||||
for (j=0;j<xss;j++)
|
||||
for (j=0;j<xss;j++)
|
||||
{
|
||||
adr[j]=((*data & ~0x1f)<<1) | (*data & 0x1f);
|
||||
data++;
|
||||
|
@ -333,9 +334,9 @@ void put_picture(word x,word y,void *p)
|
|||
{
|
||||
int i;
|
||||
int j;
|
||||
|
||||
|
||||
for (i=0;i<yss;i++,adr+=scr_linelen2,data+=(xs-xss))
|
||||
for (j=0;j<xss;j++)
|
||||
for (j=0;j<xss;j++)
|
||||
{
|
||||
adr[j]=*data;
|
||||
data++;
|
||||
|
@ -347,7 +348,7 @@ void put_picture(word x,word y,void *p)
|
|||
char *cdata=(char *)(data+(mode==264?10*256:256));
|
||||
int i;
|
||||
int j;
|
||||
|
||||
|
||||
for (i=0;i<yss;i++,adr+=scr_linelen2,cdata+=(xs-xss))
|
||||
for (j=0;j<xss;j++)
|
||||
{
|
||||
|
@ -362,7 +363,7 @@ void put_picture(word x,word y,void *p)
|
|||
char *cdata=(char *)(data+256);
|
||||
int i;
|
||||
int j;
|
||||
|
||||
|
||||
for (i=0;i<yss;i++,adr+=scr_linelen2,cdata+=(xs-xss))
|
||||
for (j=0;j<xss;j++)
|
||||
{
|
||||
|
@ -381,7 +382,7 @@ void get_picture(word x,word y,word xs,word ys,void *p)
|
|||
|
||||
if (x+xss>=DxGetResX()) xss=DxGetResX()-x;
|
||||
if (y+yss>=DxGetResY()) yss=DxGetResY()-y;
|
||||
|
||||
|
||||
data[0]=xss;
|
||||
data[1]=yss;
|
||||
data[2]=16;
|
||||
|
@ -389,9 +390,9 @@ void get_picture(word x,word y,word xs,word ys,void *p)
|
|||
{
|
||||
int i;
|
||||
int j;
|
||||
|
||||
|
||||
for (i=0;i<yss;i++,adr+=scr_linelen2)
|
||||
for (j=0;j<xss;j++)
|
||||
for (j=0;j<xss;j++)
|
||||
{
|
||||
*data=adr[j];
|
||||
data++;
|
||||
|
@ -408,11 +409,11 @@ void put_image(word *image,word *target,int start_line,int sizex,int sizey)
|
|||
int eax = start_line;
|
||||
int ebx = sizex;
|
||||
int edx = sizey;
|
||||
int ecx = esi[0];
|
||||
int ecx = esi[0];
|
||||
esi = esi + 3 + start_line * ecx;
|
||||
|
||||
while (edx) {
|
||||
memcpy(edi,esi,ecx*2);
|
||||
memcpy(edi,esi,ecx*2);
|
||||
esi += ecx;
|
||||
edi += scr_linelen2;
|
||||
edx--;
|
||||
|
@ -461,7 +462,7 @@ void put_8bit_clipped(void *src,void *trg,int startline,int velx,int vely)
|
|||
word *esi = src;
|
||||
word *edi = trg;
|
||||
word *paleta = esi+3;
|
||||
int cx = esi[0];
|
||||
int cx = esi[0];
|
||||
unsigned char *imgdata = (unsigned char *)(esi + 3 + 256)+ startline * cx;
|
||||
|
||||
while (vely) {
|
||||
|
@ -474,7 +475,7 @@ void put_8bit_clipped(void *src,void *trg,int startline,int velx,int vely)
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*_asm
|
||||
{
|
||||
mov esi,src
|
||||
|
@ -538,7 +539,7 @@ void put_textured_bar_(void *src,void *trg,int xsiz,int ysiz,int xofs,int yofs)
|
|||
int y;
|
||||
|
||||
xofs = xofs % cx;
|
||||
|
||||
|
||||
if (tp != 8) return;
|
||||
|
||||
for (y = 0; y < ysiz; y++) {
|
||||
|
@ -547,7 +548,7 @@ void put_textured_bar_(void *src,void *trg,int xsiz,int ysiz,int xofs,int yofs)
|
|||
int x;
|
||||
for (x = 0; x < xsiz; x++) {
|
||||
unsigned char c = row[(x + xofs) % cx];
|
||||
if (c) target[x] = paleta[c];
|
||||
if (c) target[x] = paleta[c];
|
||||
}
|
||||
target+=scr_linelen2;
|
||||
}
|
||||
|
@ -624,8 +625,8 @@ ptb_skip2:
|
|||
sub edi,edx
|
||||
dec ecx ;odecti 1 od globalniho citace radek
|
||||
jnz ptb_l2 ;konec velke smycky
|
||||
POP EBP
|
||||
}
|
||||
POP EBP
|
||||
}
|
||||
}
|
||||
*/
|
||||
#define MIXTRANSP(a,b) ((((a) & 0xF7DE)+((b) & 0xF7DE))>>1)
|
||||
|
@ -699,7 +700,7 @@ void wait_retrace()
|
|||
void put_picture2picture(word *source,word *target,int xp,int yp)
|
||||
//#pragma aux put_picture2picture parm [ESI][EDI][EAX][EDX] modify [ECX]
|
||||
{
|
||||
|
||||
|
||||
word *srchdr = (word *)source;
|
||||
word *trghdr = (word *)target;
|
||||
word src_cx = srchdr[0];
|
||||
|
@ -707,7 +708,7 @@ void put_picture2picture(word *source,word *target,int xp,int yp)
|
|||
word src_cy = srchdr[1];
|
||||
word trg_cy = trghdr[1];
|
||||
word y;
|
||||
|
||||
|
||||
unsigned char *srcimagedata = (unsigned char *)source+pic_start;
|
||||
unsigned char *trgimagedata = (unsigned char *)target+pic_start;
|
||||
trgimagedata+=trg_cx * yp + xp;
|
||||
|
|
|
@ -25,14 +25,14 @@ void hor_line32(int x1,int y1,int x2)
|
|||
{
|
||||
word *begline;
|
||||
int i;
|
||||
unsigned long curcolor2=curcolor | (curcolor<<16);
|
||||
uint32_t curcolor2=curcolor | (curcolor<<16);
|
||||
|
||||
if (y1<0 || y1>479) return;
|
||||
if (x1>x2) swap_int(x1,x2);
|
||||
if (x1<0) x1=0;
|
||||
if (x2>639) x2=639;
|
||||
begline=screen+scr_linelen2*y1;
|
||||
for (i=x1;i<x2;i+=2) *(unsigned long *)(begline+i)=curcolor2;
|
||||
for (i=x1;i<x2;i+=2) *(uint32_t *)(begline+i)=curcolor2;
|
||||
if (i==x2) begline[i]=curcolor;
|
||||
}
|
||||
|
||||
|
@ -52,14 +52,14 @@ void hor_line_xor(int x1,int y1,int x2)
|
|||
{
|
||||
word *begline;
|
||||
int i;
|
||||
unsigned long curcolor2=curcolor | (curcolor<<16);
|
||||
uint32_t curcolor2=curcolor | (curcolor<<16);
|
||||
|
||||
if (y1<0 || y1>479) return;
|
||||
if (x1>x2) swap_int(x1,x2);
|
||||
if (x1<0) x1=0;
|
||||
if (x2>639) x2=639;
|
||||
begline=screen+scr_linelen2*y1;
|
||||
for (i=x1;i<x2;i+=2) *(unsigned long *)(begline+i)^=curcolor2;
|
||||
for (i=x1;i<x2;i+=2) *(uint32_t *)(begline+i)^=curcolor2;
|
||||
if (i==x2) begline[i]^=curcolor;
|
||||
}
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
#include "devices.h"
|
||||
|
||||
|
||||
#define get_mouse(info) ((MS_EVENT *)(*(long *) info->data))
|
||||
#define get_mouse(info) va_arg(info->data,MS_EVENT *)
|
||||
|
||||
extern MS_EVENT ms_last_event;
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
#include "types.h"
|
||||
|
||||
FILE *bmp;
|
||||
long xsize,ysize,nsize,xcor;
|
||||
int32_t xsize,ysize,nsize,xcor;
|
||||
char bmptype;
|
||||
char *buff,*buff2;
|
||||
char filename[]="sipka.bmp";
|
||||
|
@ -13,7 +13,7 @@ char genshadow=0;
|
|||
|
||||
int load_file(char *filename)
|
||||
{
|
||||
long size;
|
||||
int32_t size;
|
||||
|
||||
bmp=fopen(filename,"rb");
|
||||
if (!bmp) return -1;
|
||||
|
@ -30,11 +30,11 @@ int load_file(char *filename)
|
|||
|
||||
void get_bmp_header()
|
||||
{
|
||||
long *p_long;
|
||||
int32_t *p_long;
|
||||
|
||||
p_long=(long *)(buff+18);
|
||||
p_long=(int32_t *)(buff+18);
|
||||
xsize=*p_long;
|
||||
p_long=(long *)(buff+22);
|
||||
p_long=(int32_t *)(buff+22);
|
||||
ysize=*p_long;
|
||||
bmptype=*(buff+0x1c);
|
||||
if (bmptype==8)
|
||||
|
@ -57,7 +57,7 @@ void conv_hicolor()
|
|||
char r,g,b;
|
||||
short hi;
|
||||
char *s,*s1,*t;
|
||||
long x,y;
|
||||
int32_t x,y;
|
||||
|
||||
s=(buff+0x36+xsize*(ysize-1)*3);
|
||||
t=buff2;
|
||||
|
@ -157,7 +157,7 @@ void palette_shadow(int tr,int tg,int tb)
|
|||
void conv_256color()
|
||||
{
|
||||
char *s,*s1,*t;
|
||||
long x,y;
|
||||
int32_t x,y;
|
||||
|
||||
s=(buff+0x36+1024+xcor*(ysize-1));
|
||||
t=buff2;
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
#include <skeldal_win.h>
|
||||
#include "types.h"
|
||||
#include <stdio.h>
|
||||
#include <dos.h>
|
||||
//#include <i86.h>
|
||||
#include <bios.h>
|
||||
#include "event.h"
|
||||
#include "devices.h"
|
||||
|
@ -19,15 +17,15 @@ TMS_BASIC_INFO ms_basic_info={0};
|
|||
static char ms_keys;
|
||||
|
||||
void get_ms_event(MS_EVENT *event)
|
||||
{
|
||||
{
|
||||
CheckMessageQueue();
|
||||
*event=win_mouseEvent;
|
||||
win_mouseEvent.event=0;
|
||||
}
|
||||
|
||||
char cz_table_1[]=" 1!3457908+,-./‚+ˆ¨‡©‘˜ ¡\"–?=:_2ABCDEFGHIJKLMNOPQRSTUVWXYZ£\\)6=;abcdefghijklmnopqrstuvwxyz/|(; ";
|
||||
char cz_table_2[]=" !\"#$%&'()*+,-./0123456789:;<=>?@<40>BCD<43>FGH‹JKŠMN•PQ«ST—VWX<EFBFBD>Z[\\]^_` bcd‚fgh¡jk<6A>mn¢pqªst£vwx˜z{|}~ ";
|
||||
char cz_table_3[]=" !\"#$%&'()*+,-./0123456789:;<=>?@AB€…‰FGHIJKœM¥§PQž›†¦VWXY’[\\]^_`ab‡ƒˆfghijkŒm¤“pq©¨Ÿ–vwxy‘{|}~ ";
|
||||
char cz_table_1[]=" 1!3457<EFBFBD>908+,-./<2F>+<2B><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>\"<EFBFBD>?=:_2ABCDEFGHIJKLMNOPQRSTUVWXYZ<59>\\)6=;abcdefghijklmnopqrstuvwxyz/|(; ";
|
||||
char cz_table_2[]=" !\"#$%&'()*+,-./0123456789:;<=>?@<40>BCD<43>FGH<EFBFBD>JK<EFBFBD>MN<EFBFBD>PQ<EFBFBD>ST<EFBFBD>VWX<EFBFBD>Z[\\]^_`<60>bcd<63>fgh<67>jk<6A>mn<6D>pq<70>st<73>vwx<77>z{|}~ ";
|
||||
char cz_table_3[]=" !\"#$%&'()*+,-./0123456789:;<=>?@AB<EFBFBD><EFBFBD><EFBFBD>FGHIJK<EFBFBD>M<EFBFBD><EFBFBD>PQ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>VWXY<EFBFBD>[\\]^_`ab<61><62><EFBFBD>fghijk<6A>m<EFBFBD><6D>pq<70><71><EFBFBD><EFBFBD>vwxy<78>{|}~ ";
|
||||
char *cz_key_tabs[]={cz_table_1,cz_table_2,cz_table_3};
|
||||
|
||||
void keyboard(EVENT_MSG *msg,void *user_data)
|
||||
|
|
|
@ -33,8 +33,8 @@
|
|||
typedef struct zoominfo
|
||||
{
|
||||
void *startptr, *texture;
|
||||
long texture_line,line_len;
|
||||
long *xtable;
|
||||
int32_t texture_line,line_len;
|
||||
int32_t *xtable;
|
||||
short *ytable;
|
||||
word *palette;
|
||||
word ycount;
|
||||
|
@ -44,7 +44,7 @@ typedef struct zoominfo
|
|||
|
||||
typedef struct t_info_y
|
||||
{
|
||||
long drawline; //ukazatel na radku na ktere bude stena zacinat
|
||||
int32_t drawline; //ukazatel na radku na ktere bude stena zacinat
|
||||
word vert_size; //konecna velikost steny, pokud ma pocatecni velikost TXT_SIZE_Y
|
||||
word vert_total; //maximalni velikost textury aby jeste nepresahla obrazovku
|
||||
short zoom_table[TAB_SIZE_Y]; //tabulka pro zoomovaci rutiny
|
||||
|
@ -56,7 +56,7 @@ typedef struct t_info_x_3d
|
|||
word xpos; //bod od leveho okraje
|
||||
word txtoffset; //posunuti x vuci texture
|
||||
word point_total; //rozdil mezi levym prednim a levym zadnim okrajem postranni steny (v adresach)
|
||||
long zoom_table[MIDDLE_X]; //zoomovaci tabulka pro osu x pro postranni steny
|
||||
int32_t zoom_table[MIDDLE_X]; //zoomovaci tabulka pro osu x pro postranni steny
|
||||
}T_INFO_X_3D;
|
||||
|
||||
typedef struct t_info_x
|
||||
|
@ -67,12 +67,12 @@ typedef struct t_info_x
|
|||
word txtoffset; //posunuti x vuci texture
|
||||
word max_x; //pocet viditelnych bodu z textury
|
||||
word point_total; //celkovy pocet adres mezi levym a pravym okrajem
|
||||
long zoom_table[VIEW_SIZE_X]; //zoomovaci tabulka pro osu x pro kolme steny
|
||||
int32_t zoom_table[VIEW_SIZE_X]; //zoomovaci tabulka pro osu x pro kolme steny
|
||||
}T_INFO_X;
|
||||
|
||||
typedef struct t_floor_map
|
||||
{
|
||||
long lineofs,linesize,counter;
|
||||
int32_t lineofs,linesize,counter;
|
||||
}T_FLOOR_MAP;
|
||||
|
||||
typedef struct all_view
|
||||
|
@ -127,11 +127,11 @@ void sikma_zleva(void);
|
|||
#pragma aux sikma_zleva parm modify [EAX EBX ECX EDX ESI EDI]
|
||||
void sikma_zprava(void);
|
||||
#pragma aux sikma_zprava parm modify [EAX EBX ECX EDX ESI EDI]
|
||||
void zooming32(void *source,void *target,void *xlat,long xysize);
|
||||
void zooming32(void *source,void *target,void *xlat,int32_t xysize);
|
||||
#pragma aux zooming32 parm [ESI][EDI][EBX][ECX] modify [EAX EDX]
|
||||
void zooming_lo(void *source,void *target,void *xlat,long xysize);
|
||||
void zooming_lo(void *source,void *target,void *xlat,int32_t xysize);
|
||||
#pragma aux zooming_lo parm [ESI][EDI][EBX][ECX] modify [EAX EDX]
|
||||
void zooming256(void *source,void *target,void *xlat,long xysize);
|
||||
void zooming256(void *source,void *target,void *xlat,int32_t xysize);
|
||||
#pragma aux zooming256 parm [ESI][EDI][EBX][ECX] modify [EAX EDX]
|
||||
void scroll_support_32(void *lbuf,void *src1,void *src2,int size1);
|
||||
#pragma aux scroll_support_32 parm [EDI][ESI][EDX][ECX] modify [EAX]
|
||||
|
@ -143,32 +143,32 @@ void fcdraw(void *source,void *target, void *table);
|
|||
|
||||
|
||||
void *p,*p2,*pozadi,*podlaha,*strop,*sit;int i;
|
||||
void (*zooming)(void *source,long target,void *xlat,long xysize);
|
||||
void (*turn)(long lbuf,void *src1,void *src2,int size1);
|
||||
void (*zooming)(void *source,int32_t target,void *xlat,int32_t xysize);
|
||||
void (*turn)(int32_t lbuf,void *src1,void *src2,int size1);
|
||||
word *buffer_2nd;
|
||||
char debug=0,nosides=0,nofloors=0,drwsit=0;
|
||||
|
||||
void zooming1(void *source,long target,void *xlat,long xysize)
|
||||
void zooming1(void *source,int32_t target,void *xlat,int32_t xysize)
|
||||
{
|
||||
zooming32(source,lbuffer+target,xlat,xysize);
|
||||
}
|
||||
|
||||
void zooming2(void *source,long target,void *xlat,long xysize)
|
||||
void zooming2(void *source,int32_t target,void *xlat,int32_t xysize)
|
||||
{
|
||||
zooming256(source,lbuffer+(target>>1),xlat,xysize);
|
||||
}
|
||||
|
||||
void zooming3(void *source,long target,void *xlat,long xysize)
|
||||
void zooming3(void *source,int32_t target,void *xlat,int32_t xysize)
|
||||
{
|
||||
zooming_lo(source,lbuffer+target,xlat,xysize);
|
||||
}
|
||||
|
||||
void turn1(long lbuf,void *src1,void *src2,int size1)
|
||||
void turn1(int32_t lbuf,void *src1,void *src2,int size1)
|
||||
{
|
||||
scroll_support_32(lbuf+lbuffer,src1,src2,size1);
|
||||
}
|
||||
|
||||
void turn2(long lbuf,void *src1,void *src2,int size1)
|
||||
void turn2(int32_t lbuf,void *src1,void *src2,int size1)
|
||||
{
|
||||
scroll_support_256((lbuf>>1)+lbuffer,src1,src2,size1,xlatmem);
|
||||
}
|
||||
|
@ -202,7 +202,7 @@ void calc_points(void)
|
|||
}
|
||||
}
|
||||
|
||||
void calc_x_buffer(long *ptr,long txt_size_x, long len,long total)
|
||||
void calc_x_buffer(int32_t *ptr,int32_t txt_size_x, int32_t len,int32_t total)
|
||||
{
|
||||
int i,j,old;
|
||||
|
||||
|
@ -215,7 +215,7 @@ void calc_x_buffer(long *ptr,long txt_size_x, long len,long total)
|
|||
}
|
||||
}
|
||||
|
||||
void calc_y_buffer(short *ptr,long txt_size_y, long len,long total)
|
||||
void calc_y_buffer(short *ptr,int32_t txt_size_y, int32_t len,int32_t total)
|
||||
{
|
||||
int i,j,old;
|
||||
|
||||
|
@ -403,7 +403,7 @@ void zooming_forward(void)
|
|||
int i;
|
||||
for (i=0;i<ZOOM_PHASES;i+=zooming_step)
|
||||
{
|
||||
zoom.xtable=(long *)&zooming_xtable[i];
|
||||
zoom.xtable=(int32_t *)&zooming_xtable[i];
|
||||
zoom.ytable=(short *)&zooming_ytable[i];
|
||||
zoom.texture_line=0;
|
||||
zooming(screen+zooming_points[i][2]+zooming_points[i][3]*640+SCREEN_OFFSET,SCREEN_OFFSET,xlatmem,(360<<16)+320);
|
||||
|
@ -414,22 +414,22 @@ void zooming_backward(void)
|
|||
int i;
|
||||
for (i=ZOOM_PHASES-1;i>=0;i-=zooming_step)
|
||||
{
|
||||
zoom.xtable=(long *)&zooming_xtable[i];
|
||||
zoom.xtable=(int32_t *)&zooming_xtable[i];
|
||||
zoom.ytable=(short *)&zooming_ytable[i];
|
||||
zoom.texture_line=0;
|
||||
zooming(screen+zooming_points[i][2]+zooming_points[i][3]*640+SCREEN_OFFSET,SCREEN_OFFSET,xlatmem,(360<<16)+320);
|
||||
}
|
||||
}
|
||||
|
||||
/* zoom.xtable=(long *)&zooming_xtable[0];
|
||||
/* zoom.xtable=(int32_t *)&zooming_xtable[0];
|
||||
zoom.ytable=(short *)&zooming_ytable[0];
|
||||
zoom.texture_line=0;
|
||||
zooming(screen+35+25*640+SCREEN_OFFSET,lbuffer+SCREEN_OFFSET,xlatmem,(360<<16)+320);
|
||||
zoom.xtable=(long *)&zooming_xtable[1];
|
||||
zoom.xtable=(int32_t *)&zooming_xtable[1];
|
||||
zoom.ytable=(short *)&zooming_ytable[1];
|
||||
zoom.texture_line=0;
|
||||
zooming(screen+70+40*640+SCREEN_OFFSET,lbuffer+SCREEN_OFFSET,xlatmem,(360<<16)+320);
|
||||
zoom.xtable=(long *)&zooming_xtable[2];
|
||||
zoom.xtable=(int32_t *)&zooming_xtable[2];
|
||||
zoom.ytable=(short *)&zooming_ytable[2];
|
||||
zoom.texture_line=0;
|
||||
zooming(screen+95+60*640+SCREEN_OFFSET,lbuffer+SCREEN_OFFSET,xlatmem,(360<<16)+320);
|
||||
|
|
162
libs/event.c
162
libs/event.c
|
@ -40,7 +40,7 @@ static jmp_buf jmpenv;
|
|||
char exit_wait=0;
|
||||
T_EVENT_ROOT *ev_tree=NULL;
|
||||
char freeze_on_exit=0;
|
||||
long ev_buff_msg[EVENT_BUFF_SIZE]={0};
|
||||
int32_t ev_buff_msg[EVENT_BUFF_SIZE]={0};
|
||||
void *ev_buff_dta[EVENT_BUFF_SIZE]={NULL};
|
||||
int ev_poz=0;
|
||||
char *otevri_zavoru;
|
||||
|
@ -53,9 +53,9 @@ char *task_info;
|
|||
int taskcount=0;
|
||||
int foretask=0;
|
||||
int nexttask=0;
|
||||
long taskparam;
|
||||
int32_t taskparam;
|
||||
|
||||
long err_last_stack;
|
||||
int32_t err_last_stack;
|
||||
void *err_to_go;
|
||||
|
||||
|
||||
|
@ -226,7 +226,11 @@ void enter_event(T_EVENT_ROOT **tree,EVENT_MSG *msg)
|
|||
p->nezavora=p->nezavirat;
|
||||
otevri_zavoru=&p->nezavora;
|
||||
p->calls++;
|
||||
z->proc(msg,&(z->user_data));
|
||||
EVENT_MSG cpy;
|
||||
cpy.msg = msg->msg;
|
||||
va_copy(cpy.data, msg->data);
|
||||
z->proc(&cpy,&(z->user_data));
|
||||
va_end(cpy.data);
|
||||
p->calls--;
|
||||
p->nezavora=1;
|
||||
if (msg->msg==-2)
|
||||
|
@ -267,25 +271,32 @@ void enter_event(T_EVENT_ROOT **tree,EVENT_MSG *msg)
|
|||
unsuspend_task(msg);
|
||||
}
|
||||
|
||||
T_EVENT_POINT *install_event(T_EVENT_ROOT **tree,long ev_num,EV_PROC proc,void *procdata,char end)
|
||||
typedef struct call_proc_context_t {
|
||||
EV_PROC proc;
|
||||
void **user;
|
||||
}call_proc_context;
|
||||
|
||||
static int call_proc(EVENT_MSG *msg, void *ctx) {
|
||||
call_proc_context *c = ctx;
|
||||
c->proc(msg, c->user);
|
||||
return 0;
|
||||
}
|
||||
|
||||
T_EVENT_POINT *install_event(T_EVENT_ROOT **tree,int32_t ev_num,EV_PROC proc,void *procdata,char end)
|
||||
//instaluje novou udalost;
|
||||
{
|
||||
EVENT_MSG x;
|
||||
void **user=NULL;
|
||||
void *user=NULL;
|
||||
T_EVENT_POINT *p;
|
||||
call_proc_context ctx = {proc, &user};
|
||||
|
||||
x.msg=E_INIT;
|
||||
x.data=procdata;
|
||||
proc(&x,&user);
|
||||
if (x.data!=NULL)
|
||||
{
|
||||
p=add_event(tree,ev_num,proc,end);
|
||||
p->user_data=user;
|
||||
}
|
||||
return p;
|
||||
send_message_to(call_proc,&ctx, E_INIT, procdata);
|
||||
p=add_event(tree,ev_num,proc,end);
|
||||
p->user_data=user;
|
||||
return p;
|
||||
}
|
||||
|
||||
void deinstall_event(T_EVENT_ROOT **tree,long ev_num,EV_PROC proc,void *procdata)
|
||||
void deinstall_event(T_EVENT_ROOT **tree,int32_t ev_num,EV_PROC proc,void *procdata)
|
||||
//deinstaluje udalost;
|
||||
{
|
||||
EVENT_MSG x;
|
||||
|
@ -296,9 +307,8 @@ void deinstall_event(T_EVENT_ROOT **tree,long ev_num,EV_PROC proc,void *procdata
|
|||
if (r==NULL) return;
|
||||
find_event_proc(r->list,proc,p);
|
||||
if (p==NULL) return;
|
||||
x.msg=E_DONE;
|
||||
x.data=procdata;
|
||||
proc(&x,&p->user_data);
|
||||
call_proc_context ctx = {proc, &p->user_data};
|
||||
send_message_to(call_proc, &ctx, E_DONE, procdata);
|
||||
if (p->user_data!=NULL) free(p->user_data);
|
||||
p->proc=NULL;
|
||||
p->user_data=NULL;
|
||||
|
@ -308,46 +318,62 @@ void deinstall_event(T_EVENT_ROOT **tree,long ev_num,EV_PROC proc,void *procdata
|
|||
void tree_basics(T_EVENT_ROOT **ev_tree,EVENT_MSG *msg)
|
||||
{
|
||||
char *p;
|
||||
void *(*q)();
|
||||
void (*q)();
|
||||
EVENT_MSG tg;
|
||||
|
||||
if (msg->msg==E_ADD || msg->msg==E_ADDEND)
|
||||
{
|
||||
T_EVENT_POINT *r;
|
||||
shift_msg(msg,tg);
|
||||
p=(char *)(tg.data);
|
||||
p+=4;
|
||||
find_event_msg_proc(*ev_tree,tg.msg,tg.data,r);
|
||||
shift_message(msg);
|
||||
EV_PROC proc = va_arg(msg->data, EV_PROC);
|
||||
void *procdata = va_arg(msg->data, void *);
|
||||
find_event_msg_proc(*ev_tree,msg->msg,proc,r);
|
||||
assert(r==NULL);
|
||||
if (r==NULL)
|
||||
install_event(ev_tree,tg.msg,*(EV_PROC *)tg.data,p,msg->msg==E_ADDEND);
|
||||
install_event(ev_tree,msg->msg,proc,procdata,msg->msg==E_ADDEND);
|
||||
return;
|
||||
}
|
||||
if (msg->msg==E_INIT)
|
||||
{
|
||||
memcpy(&q,msg->data,4);
|
||||
q();
|
||||
q = va_arg(msg->data, void (*)());
|
||||
q();
|
||||
return;
|
||||
}
|
||||
if (msg->msg==E_DONE)
|
||||
{
|
||||
shift_msg(msg,tg);
|
||||
p=(char *)(tg.data);
|
||||
p+=4;
|
||||
deinstall_event(ev_tree,tg.msg,*(EV_PROC *) tg.data,p);
|
||||
shift_message(msg);
|
||||
EV_PROC proc = va_arg(msg->data, EV_PROC);
|
||||
void *procdata = va_arg(msg->data, void *);
|
||||
deinstall_event(ev_tree,msg->msg,proc,procdata);
|
||||
return;
|
||||
}
|
||||
if (msg->msg==E_GROUP)
|
||||
/* if (msg->msg==E_GROUP)
|
||||
{
|
||||
int pocet,i,addev;
|
||||
T_EVENT_POINT *pp;
|
||||
EVENT_MSG *tgm=&tg;
|
||||
|
||||
long *p;void *proc;
|
||||
shift_msg(msg,tg);addev=tg.msg; if (addev!=E_ADD || addev!=E_ADDEND) return;
|
||||
shift_message(msg);
|
||||
addev = msg->msg;
|
||||
if (addev!=E_ADD || addev!=E_ADDEND) return;
|
||||
shift_message(msg);
|
||||
int pocet = msg->msg;
|
||||
va_list va_procdata;
|
||||
va_copy(tmp, msg->data);
|
||||
for (int i = 0; i < pocet; ++i) va_arg(va_procdata, EV_PROC);
|
||||
for (int i = 0; i < pocet; ++i) {
|
||||
EV_PROC proc = va_arg(msg->data, EV_PROC);
|
||||
void *procdata = va_arg(va_procdata, void *)
|
||||
if (i == 0) {
|
||||
pp=install_event(ev_tree,proc,procdata,((int32_t *)proc+1),addev==E_ADDEND);
|
||||
}
|
||||
}
|
||||
|
||||
int32_t *p;void *proc;
|
||||
shift_msg(msg,tg);addev=tg.msg;
|
||||
shift_msg(tgm,tg);
|
||||
pocet=tg.msg;
|
||||
p=tg.data;proc=p+pocet*sizeof(long);
|
||||
p=tg.data;proc=p+pocet*sizeof(int32_t);
|
||||
for(i=0;i<pocet;i++,p++) if (i!=0)
|
||||
{
|
||||
T_EVENT_POINT *q;
|
||||
|
@ -356,23 +382,36 @@ void tree_basics(T_EVENT_ROOT **ev_tree,EVENT_MSG *msg)
|
|||
q->proc=PROC_GROUP;
|
||||
}
|
||||
else
|
||||
pp=install_event(ev_tree,*p,proc,((long *)proc+1),addev==E_ADDEND);
|
||||
pp=install_event(ev_tree,*p,proc,((int32_t *)proc+1),addev==E_ADDEND);
|
||||
}
|
||||
|
||||
*/
|
||||
|
||||
}
|
||||
|
||||
void send_message(long message,...)
|
||||
{
|
||||
long *p;
|
||||
EVENT_MSG x;
|
||||
int send_message_to(int (*cb)(EVENT_MSG *, void *), void *ctx, int message, ...) {
|
||||
EVENT_MSG x;
|
||||
x.msg = message;
|
||||
va_start(x.data, message);
|
||||
int r = cb(&x, ctx);
|
||||
va_end(x.data);
|
||||
}
|
||||
|
||||
p=&message;
|
||||
x.msg=*p++;
|
||||
x.data=(void *)p;
|
||||
if (x.msg==E_ADD || x.msg==E_INIT || x.msg==E_DONE) tree_basics(&ev_tree,&x);
|
||||
else
|
||||
enter_event(&ev_tree,&x);
|
||||
static void send_message_to_tree(EVENT_MSG *x) {
|
||||
if (x->msg==E_ADD || x->msg==E_INIT || x->msg==E_DONE) {
|
||||
tree_basics(&ev_tree,x);
|
||||
}
|
||||
else {
|
||||
enter_event(&ev_tree,x);
|
||||
}
|
||||
}
|
||||
|
||||
void send_message(int message,...)
|
||||
{
|
||||
EVENT_MSG x;
|
||||
x.msg = message;
|
||||
va_start(x.data, message);
|
||||
send_message_to_tree(&x);
|
||||
va_end(x.data);
|
||||
}
|
||||
|
||||
|
||||
|
@ -380,10 +419,10 @@ void send_message(long message,...)
|
|||
|
||||
void timer(EVENT_MSG *msg)
|
||||
{
|
||||
static unsigned long lasttime=0;
|
||||
static uint32_t lasttime=0;
|
||||
if (msg->msg==E_WATCH)
|
||||
{
|
||||
unsigned long tm=GetTickCount()/TIMERSPEED;
|
||||
uint32_t tm=get_game_tick_count()/TIMERSPEED;
|
||||
if (tm==lasttime) return;
|
||||
lasttime=tm;
|
||||
send_message(E_TIMER,tm);
|
||||
|
@ -483,7 +522,7 @@ void error_show(int error_number)
|
|||
|
||||
|
||||
void escape()
|
||||
{
|
||||
{
|
||||
|
||||
exit_wait=0;
|
||||
do
|
||||
|
@ -500,12 +539,11 @@ void escape()
|
|||
T_EVENT_ROOT *gate_basics(EVENT_MSG *msg, void **user_data)
|
||||
{
|
||||
T_EVENT_ROOT *p;
|
||||
EVENT_MSG msg2;
|
||||
|
||||
memcpy(&p,user_data,4);
|
||||
shift_msg(msg,msg2);;
|
||||
if (msg2.msg==E_ADD || msg2.msg==E_INIT || msg2.msg==E_DONE)
|
||||
tree_basics((T_EVENT_ROOT **)user_data,&msg2);
|
||||
shift_message(msg);
|
||||
if (msg->msg==E_ADD || msg->msg==E_INIT || msg->msg==E_DONE)
|
||||
tree_basics((T_EVENT_ROOT **)user_data,msg);
|
||||
return p;
|
||||
}
|
||||
/*
|
||||
|
@ -529,7 +567,7 @@ int create_task()
|
|||
*/
|
||||
void task_terminating();
|
||||
/*
|
||||
long getflags();
|
||||
int32_t getflags();
|
||||
#pragma aux getflags = \
|
||||
"pushfd"\
|
||||
"pop eax"\
|
||||
|
@ -538,7 +576,7 @@ long getflags();
|
|||
int add_task(int stack,void *name,...)
|
||||
{
|
||||
int task,i;
|
||||
long *sp,*spp;
|
||||
int32_t *sp,*spp;
|
||||
|
||||
task=create_task();
|
||||
if (task==-1)
|
||||
|
@ -552,16 +590,16 @@ int add_task(int stack,void *name,...)
|
|||
send_message(E_MEMERROR);
|
||||
return -1;
|
||||
}
|
||||
spp=(long *)((char *)sp+stack-17*4);
|
||||
spp=(int32_t *)((char *)sp+stack-17*4);
|
||||
memset(sp,0,stack);
|
||||
memcpy(spp,&name,17*4);
|
||||
*spp=(long )task_terminating;
|
||||
spp--;*spp=(long)name;
|
||||
*spp=(int32_t )task_terminating;
|
||||
spp--;*spp=(int32_t)name;
|
||||
for(i=0;i<9;i++)
|
||||
{
|
||||
spp--;
|
||||
*spp=0;
|
||||
if (i==5) *spp=(long)((char *)sp+stack);
|
||||
if (i==5) *spp=(int32_t)((char *)sp+stack);
|
||||
}
|
||||
tasklist_low[task]=(void *)sp;
|
||||
tasklist_top[task]=(void *)((char *)sp+stack);
|
||||
|
@ -620,10 +658,10 @@ void shut_down_task(int id_num)
|
|||
}
|
||||
}
|
||||
*/
|
||||
/*void *task_wait_event(long event_number)
|
||||
/*void *task_wait_event(int32_t event_number)
|
||||
{
|
||||
if (!curtask) return NULL;
|
||||
suspend_task(curtask,event_number);
|
||||
return task_sleep(NULL);
|
||||
}
|
||||
*/
|
||||
*/
|
||||
|
|
32
libs/event.h
32
libs/event.h
|
@ -1,3 +1,4 @@
|
|||
#include <stdarg.h>
|
||||
#ifndef __EVENT_H
|
||||
#define __EVENT_H
|
||||
//#define nodebug // 0 znamena ze se nealokuje udalost pro chybu
|
||||
|
@ -11,7 +12,7 @@
|
|||
#define E_ADD 2 //pridani udalosti do stromu
|
||||
#define E_DONE 3 //odebrani udalosti ze stromu
|
||||
#define E_IDLE 4 //udalost volana v dobe necinnosti
|
||||
#define E_GROUP 5 //vytvareni skupin udalosti
|
||||
//#define E_GROUP 5 //vytvareni skupin udalosti
|
||||
#define E_ADDEND 7 //pridani udalosti do stromu na konec.
|
||||
#define E_MEMERROR 8 //udalost je vyvolana pri nedostatku pameti
|
||||
// neni prirazena ZADNA standardni akce!!!
|
||||
|
@ -36,7 +37,8 @@
|
|||
|
||||
#define TASK_EVENT_WAITING 2
|
||||
|
||||
#define shift_msg(msgg,tg) ((tg.msg=*(long *)msgg->data),(tg.data=(void *)((long *)msgg->data+1)))
|
||||
|
||||
//#define shift_msg(msgg,tg) ((tg.msg=*(int32_t *)msgg->data),(tg.data=(void *)((int32_t *)msgg->data+1)))
|
||||
|
||||
#define EVENT_BUFF_SIZE 16
|
||||
|
||||
|
@ -46,12 +48,12 @@ typedef void (*EV_PROC)(void *,void *) ;
|
|||
|
||||
//typedef struct event_list
|
||||
// {
|
||||
// long *table; //tabulka udalosti
|
||||
// int32_t *table; //tabulka udalosti
|
||||
// EV_PROC *procs; //co se ma pri danne udalosti stat
|
||||
// void *(*user_data); //ukazatel na uzivatelska data
|
||||
// char *zavora; //1 znamena ze udalost je povolena
|
||||
// long max_events; // maximalni pocet udalosti, na ktere je system rezervova
|
||||
// long count; //aktualni pocet udalosti
|
||||
// int32_t max_events; // maximalni pocet udalosti, na ktere je system rezervova
|
||||
// int32_t count; //aktualni pocet udalosti
|
||||
// }EVENT_LIST;
|
||||
|
||||
/* event procedura ma dva parametry
|
||||
|
@ -87,8 +89,8 @@ typedef struct t_event_root
|
|||
|
||||
typedef struct event_msg
|
||||
{
|
||||
long msg;
|
||||
void *data;
|
||||
int32_t msg;
|
||||
va_list data;
|
||||
}EVENT_MSG;
|
||||
|
||||
extern char exit_wait; // 1 - opousti aktivni cekaci event;
|
||||
|
@ -99,11 +101,13 @@ extern char *otevri_zavoru;
|
|||
|
||||
void init_events();
|
||||
// inicalizuje zakladni strom udalosto
|
||||
void send_message(long message,...);
|
||||
void send_message(int message,...);
|
||||
|
||||
int send_message_to(int (*cb)(EVENT_MSG *, void *), void *ctx, int message, ...);
|
||||
// posila zpravu do stromu
|
||||
void tree_basics(T_EVENT_ROOT **ev_tree,EVENT_MSG *msg);
|
||||
// pripojuje zakladni funkce brany, jako je instalace listu a jejich deinstalace
|
||||
T_EVENT_ROOT *gate_basics(EVENT_MSG *msg, void *user_data);
|
||||
T_EVENT_ROOT *gate_basics(EVENT_MSG *msg, void **user_data);
|
||||
// implementace brany
|
||||
/* vstupuji informace, jake dostane brana pri zavolani
|
||||
vystupuji informace s jakymi musi vstoupit do stromu.
|
||||
|
@ -113,6 +117,10 @@ T_EVENT_ROOT *gate_basics(EVENT_MSG *msg, void *user_data);
|
|||
void enter_event(T_EVENT_ROOT **tree,EVENT_MSG *msg);
|
||||
//vstupuje do stromu s udalosti (msg)
|
||||
|
||||
static __inline void shift_message(EVENT_MSG *msg) {
|
||||
msg->msg = va_arg(msg->data, int);
|
||||
}
|
||||
|
||||
void do_events();
|
||||
void escape();
|
||||
|
||||
|
@ -129,7 +137,7 @@ void shut_down_task(int id_num);
|
|||
//Nasilne ukonci ulohu
|
||||
void raise_error(int error_number);
|
||||
|
||||
EVENT_MSG *task_wait_event(long event_number);
|
||||
EVENT_MSG *task_wait_event(int32_t event_number);
|
||||
char is_running(int id_num);
|
||||
*/
|
||||
void timer(EVENT_MSG *msg);
|
||||
|
@ -137,8 +145,8 @@ void timer(EVENT_MSG *msg);
|
|||
#define EVENT_PROC(name) void name(EVENT_MSG *msg,void **user_ptr)
|
||||
#define WHEN_MSG(msg_num) if (msg->msg==msg_num)
|
||||
#define UNTIL_MSG(msg_num) if (msg->msg!=msg_num)
|
||||
#define GET_DATA(data_type) (*(data_type *)msg->data)
|
||||
#define GET_DATA_PTR(data_type) ((data_type *)msg->data);
|
||||
#define GET_DATA(data_type) (va_arg(msg->data, data_type))
|
||||
#define GET_DATA_PTR(data_type) (va_arg(msg->data, data_type *))
|
||||
#define GET_USER(data_type) (*(data_type *)user_ptr)
|
||||
#define SAVE_USER_PTR(p) (*user_ptr=p)
|
||||
#define GET_USER_PTR() user_ptr
|
||||
|
|
|
@ -11,7 +11,7 @@ void help()
|
|||
|
||||
main(int argc,char **argv)
|
||||
{
|
||||
void *z;long s;
|
||||
void *z;int32_t s;
|
||||
FILE *f;
|
||||
|
||||
if (argc!=4) help();
|
||||
|
|
|
@ -11,7 +11,7 @@ void help()
|
|||
|
||||
main(int argc,char **argv)
|
||||
{
|
||||
void *z;long s;
|
||||
void *z;int32_t s;
|
||||
FILE *f;
|
||||
|
||||
if (argc==3) help();
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
#define LOAD_BUFFER 4096
|
||||
|
||||
int _fast_load(char *ptr,long size,FILE *f)
|
||||
int _fast_load(char *ptr,int32_t size,FILE *f)
|
||||
{
|
||||
if (size>LOAD_BUFFER) size=4096;
|
||||
return fread(ptr,1,size,f);
|
||||
|
@ -11,7 +11,7 @@ int _fast_load(char *ptr,long size,FILE *f)
|
|||
|
||||
size_t fread(void *ptr,size_t i,size_t j,FILE *f)
|
||||
{
|
||||
long s,z,celk=0;
|
||||
int32_t s,z,celk=0;
|
||||
char *c;
|
||||
|
||||
c=ptr;
|
||||
|
|
144
libs/gui.c
144
libs/gui.c
|
@ -36,6 +36,11 @@ void empty1(OBJREC *o)
|
|||
o;
|
||||
}
|
||||
|
||||
void empty2_p(OBJREC *o, va_list)
|
||||
{
|
||||
o;
|
||||
}
|
||||
|
||||
void empty3(EVENT_MSG *ms,OBJREC *o)
|
||||
{
|
||||
o;ms;
|
||||
|
@ -119,15 +124,15 @@ int send_lost()
|
|||
msg.msg=E_LOST_FOCUS;
|
||||
if (o_aktual!=NULL)
|
||||
{
|
||||
o_aktual->events[2]();
|
||||
o_aktual->on_exit();
|
||||
if (f_cancel_event) return -1;
|
||||
o_aktual->runs[2](&msg,o_aktual);
|
||||
o_aktual->call_event(&msg,o_aktual);
|
||||
o_aktual=NULL;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void select_window(long id)
|
||||
void select_window(int32_t id)
|
||||
{
|
||||
WINDOW *p,*q;
|
||||
|
||||
|
@ -162,9 +167,9 @@ void select_window(long id)
|
|||
|
||||
}
|
||||
|
||||
long desktop_add_window(WINDOW *w)
|
||||
int32_t desktop_add_window(WINDOW *w)
|
||||
{
|
||||
static long id_counter=0;
|
||||
static int32_t id_counter=0;
|
||||
|
||||
w->id=id_counter++;
|
||||
w->next=NULL;
|
||||
|
@ -180,8 +185,8 @@ long desktop_add_window(WINDOW *w)
|
|||
EVENT_MSG msg;
|
||||
|
||||
msg.msg=E_LOST_FOCUS;
|
||||
o_aktual->events[2]();
|
||||
o_aktual->runs[2](&msg,o_aktual);
|
||||
o_aktual->on_exit();
|
||||
o_aktual->call_event(&msg,o_aktual);
|
||||
}
|
||||
waktual->next=w;
|
||||
waktual=w;
|
||||
|
@ -193,7 +198,7 @@ long desktop_add_window(WINDOW *w)
|
|||
}
|
||||
|
||||
|
||||
WINDOW *find_window(long id)
|
||||
WINDOW *find_window(int32_t id)
|
||||
{
|
||||
WINDOW *p;
|
||||
|
||||
|
@ -262,7 +267,7 @@ void absolute_window(WINDOW *w,OBJREC *o, int *x, int *y)
|
|||
memcpy(&charcolors,&o->f_color,sizeof(charcolors));
|
||||
// ws=waktual;
|
||||
// waktual=w;
|
||||
o->runs[1](x,y,x+o->xs,y+o->ys,o);
|
||||
o->call_draw(x,y,x+o->xs,y+o->ys,o);
|
||||
// waktual=ws;
|
||||
if (!o->enabled) disable_bar(x,y,o->xs,o->ys,o->color);
|
||||
ukaz_mysku();
|
||||
|
@ -322,21 +327,21 @@ void add_to_idlist(OBJREC *o)
|
|||
void define(int id,int x,int y,int xs,int ys,char align,void (*initproc)(OBJREC *),...)
|
||||
{
|
||||
OBJREC *o;
|
||||
long *p;
|
||||
int32_t *p;
|
||||
|
||||
o=(OBJREC *)getmem(sizeof(OBJREC));
|
||||
o->x=x;o->y=y;o->xs=xs;o->ys=ys;
|
||||
o->id=id;
|
||||
o->runs[0]=empty1;
|
||||
o->runs[1]=empty2;
|
||||
o->runs[2]=empty3;
|
||||
o->runs[3]=empty1;
|
||||
o->call_init=empty2_p;
|
||||
o->call_draw=empty2;
|
||||
o->call_event=empty3;
|
||||
o->call_done=empty1;
|
||||
o->autoresizex=0;
|
||||
o->autoresizey=0;
|
||||
o->events[0]=empty;
|
||||
o->events[1]=empty;
|
||||
o->events[2]=empty1;
|
||||
o->events[3]=empty3;
|
||||
o->on_event=empty;
|
||||
o->on_enter=empty;
|
||||
o->on_exit=empty1;
|
||||
o->on_change=empty3;
|
||||
o->enabled=1;
|
||||
o->draw_error=0;
|
||||
o->color=waktual->color;memcpy(o->f_color,f_default,sizeof(f_default));
|
||||
|
@ -347,8 +352,10 @@ void define(int id,int x,int y,int xs,int ys,char align,void (*initproc)(OBJREC
|
|||
o->datasize=0;
|
||||
initproc(o);
|
||||
if (o->datasize) o->data=(void *)getmem(o->datasize); else o->data=NULL;
|
||||
p=(long *)&initproc;p++;
|
||||
o->runs[0](o,p);
|
||||
va_list vlst;
|
||||
va_start(vlst, initproc);
|
||||
o->call_init(o,vlst);
|
||||
va_end(vlst);
|
||||
if (o->datasize && o->data==NULL) o->data=(void *)getmem(o->datasize);
|
||||
o->next=NULL;
|
||||
if (o_start==NULL)
|
||||
|
@ -494,7 +501,7 @@ void close_window(WINDOW *w)
|
|||
{
|
||||
q=w->objects;
|
||||
w->objects=q->next;
|
||||
q->runs[3](q);
|
||||
q->call_done(q);
|
||||
if (q->userptr!=NULL) free(q->userptr);
|
||||
if (q->data!=NULL) free(q->data);
|
||||
free(q);
|
||||
|
@ -553,7 +560,7 @@ OBJREC *get_next_id(OBJREC *o)
|
|||
p=p->next;
|
||||
if (p==NULL) p=waktual->idlist;
|
||||
o=p->obj;
|
||||
if (o->enabled && o->runs[2]!=empty3) return o;
|
||||
if (o->enabled && o->call_event!=empty3) return o;
|
||||
}
|
||||
while (1);
|
||||
}
|
||||
|
@ -579,7 +586,7 @@ OBJREC *get_prev_id(OBJREC *o)
|
|||
p=q;
|
||||
}
|
||||
o=p->obj;
|
||||
if (o->enabled && o->runs[2]!=empty3) return o;
|
||||
if (o->enabled && o->call_event!=empty3) return o;
|
||||
}
|
||||
while (1);
|
||||
}
|
||||
|
@ -598,7 +605,7 @@ void do_it_events(EVENT_MSG *msg,void **user_data)
|
|||
if (msg->msg==E_INIT) return;
|
||||
if (desktop==NULL) {exit_wait=1;return;}
|
||||
change_flag=0;f_cancel_event=0;
|
||||
if (o_aktual!=NULL)o_aktual->events[0](msg,o_aktual);
|
||||
if (o_aktual!=NULL)o_aktual->on_event(msg,o_aktual);
|
||||
if (msg->msg==E_MOUSE)
|
||||
{
|
||||
*oz=1;
|
||||
|
@ -608,33 +615,33 @@ void do_it_events(EVENT_MSG *msg,void **user_data)
|
|||
if (o_start!=NULL && (msev->tl1 || msev->tl2 || msev->tl3))
|
||||
{
|
||||
o_aktual=o_start;
|
||||
while (o_aktual!=NULL && (!o_aktual->enabled || !mouse_in_object(msev,o_aktual,waktual) || o_aktual->runs[2]==empty3)) o_aktual=o_aktual->next;
|
||||
while (o_aktual!=NULL && (!o_aktual->enabled || !mouse_in_object(msev,o_aktual,waktual) || o_aktual->call_event==empty3)) o_aktual=o_aktual->next;
|
||||
if (o_aktual==NULL) return;
|
||||
msg2.msg=E_GET_FOCUS;
|
||||
o_aktual->runs[2](&msg2,o_aktual);
|
||||
o_aktual->events[1]();
|
||||
o_aktual->runs[2](msg,o_aktual);
|
||||
o_aktual->call_event(&msg2,o_aktual);
|
||||
o_aktual->on_enter();
|
||||
o_aktual->call_event(msg,o_aktual);
|
||||
}
|
||||
else return;
|
||||
else
|
||||
{
|
||||
if (o_aktual->enabled) b=mouse_in_object(msev,o_aktual,waktual);else b=0;
|
||||
if (b)
|
||||
o_aktual->runs[2](msg,o_aktual);
|
||||
o_aktual->call_event(msg,o_aktual);
|
||||
if ((msev->tl1 || msev->tl2 || msev->tl3)&& !b)
|
||||
{
|
||||
o_aktual->events[2]();
|
||||
o_aktual->on_exit();
|
||||
if (f_cancel_event) return;
|
||||
msg2.msg=E_LOST_FOCUS;
|
||||
o_aktual->runs[2](&msg2,o_aktual);
|
||||
o_aktual->call_event(&msg2,o_aktual);
|
||||
p=o_start;
|
||||
while (p!=NULL && (!p->enabled || !mouse_in_object(msev,p,waktual) || p->runs[2]==empty3))
|
||||
while (p!=NULL && (!p->enabled || !mouse_in_object(msev,p,waktual) || p->call_event==empty3))
|
||||
p=p->next;
|
||||
if (p!=NULL) o_aktual=p;
|
||||
msg2.msg=E_GET_FOCUS;
|
||||
o_aktual->runs[2](&msg2,o_aktual);
|
||||
o_aktual->events[1]();
|
||||
if (p!=NULL) o_aktual->runs[2](msg,o_aktual);
|
||||
o_aktual->call_event(&msg2,o_aktual);
|
||||
o_aktual->on_enter();
|
||||
if (p!=NULL) o_aktual->call_event(msg,o_aktual);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -643,59 +650,62 @@ void do_it_events(EVENT_MSG *msg,void **user_data)
|
|||
*oz=1;
|
||||
if (o_aktual!=NULL)
|
||||
{
|
||||
o_aktual->runs[2](msg,o_aktual);
|
||||
o_aktual->call_event(msg,o_aktual);
|
||||
}
|
||||
if ((*(int *)msg->data>>8)==0xf && waktual->idlist!=NULL)
|
||||
int code = va_arg(msg->data, int);
|
||||
if ((code>>8)==0xf && waktual->idlist!=NULL)
|
||||
{
|
||||
if (o_aktual==NULL) o_aktual=get_last_id();
|
||||
if (o_aktual!=NULL)
|
||||
{
|
||||
f_cancel_event=0;
|
||||
o_aktual->events[2]();
|
||||
o_aktual->on_exit();
|
||||
if (f_cancel_event) return;
|
||||
msg2.msg=E_LOST_FOCUS;
|
||||
o_aktual->runs[2](&msg2,o_aktual);
|
||||
o_aktual->call_event(&msg2,o_aktual);
|
||||
}
|
||||
if((*(int *)msg->data & 0xff)==9) o_aktual=get_next_id(o_aktual);
|
||||
if((code & 0xff)==9) o_aktual=get_next_id(o_aktual);
|
||||
else o_aktual=get_prev_id(o_aktual);
|
||||
if (o_aktual!=NULL)
|
||||
{
|
||||
msg2.msg=E_GET_FOCUS;
|
||||
o_aktual->runs[2](&msg2,o_aktual);
|
||||
o_aktual->events[1]();
|
||||
o_aktual->call_event(&msg2,o_aktual);
|
||||
o_aktual->on_enter();
|
||||
}
|
||||
}
|
||||
}
|
||||
if (msg->msg==E_TIMER && o_aktual!=NULL)
|
||||
{
|
||||
o_aktual->runs[2](msg,o_aktual);
|
||||
o_aktual->call_event(msg,o_aktual);
|
||||
if (!(cursor_tick--))
|
||||
{
|
||||
msg->msg=E_CURSOR_TICK;
|
||||
o_aktual->runs[2](msg,o_aktual);
|
||||
o_aktual->events[0](msg,o_aktual);
|
||||
o_aktual->call_event(msg,o_aktual);
|
||||
o_aktual->on_event(msg,o_aktual);
|
||||
cursor_tick=CURSOR_SPEED;
|
||||
}
|
||||
}
|
||||
if (msg->msg==E_GUI)
|
||||
{
|
||||
OBJREC *o;
|
||||
EVENT_MSG msg2;
|
||||
int *p;
|
||||
int control = va_arg(msg->data, int);
|
||||
msg->msg = va_arg(msg->data, int);
|
||||
o=find_object(waktual,control);
|
||||
|
||||
EVENT_MSG msg2;
|
||||
|
||||
p=msg->data;
|
||||
o=find_object(waktual,*p++);
|
||||
if (o!=NULL)
|
||||
{
|
||||
msg2.msg=*p++;
|
||||
msg2.data=p;
|
||||
o->runs[2](&msg2,o);
|
||||
o->events[0](&msg,o_aktual);
|
||||
msg2.msg=msg->msg;
|
||||
va_copy(msg2.data,msg->data);
|
||||
o->call_event(&msg2,o);
|
||||
o->on_event(msg,o_aktual);
|
||||
va_end(msg2.data);
|
||||
}
|
||||
|
||||
}
|
||||
if (msg->msg==E_CHANGE)
|
||||
run_background(o_aktual->events[3]);
|
||||
run_background(o_aktual->on_change);
|
||||
if (change_flag) send_message(E_CHANGE);
|
||||
}
|
||||
|
||||
|
@ -726,24 +736,24 @@ void uninstall_gui(void)
|
|||
//send_message(E_GUI,cislo,E_UDALOST,data....)
|
||||
|
||||
|
||||
void on_change(void (*proc)())
|
||||
void on_control_change(void (*proc)())
|
||||
{
|
||||
o_end->events[3]=proc;
|
||||
o_end->on_change=proc;
|
||||
}
|
||||
|
||||
void on_enter(void (*proc)())
|
||||
void on_control_enter(void (*proc)())
|
||||
{
|
||||
o_end->events[1]=proc;
|
||||
o_end->on_enter=proc;
|
||||
}
|
||||
void on_exit(void (*proc)())
|
||||
void on_control_exit(void (*proc)())
|
||||
{
|
||||
o_end->events[2]=proc;
|
||||
o_end->on_exit=proc;
|
||||
}
|
||||
void on_event(void (*proc)())
|
||||
void on_control_event(void (*proc)(EVENT_MSG *msg, struct objrec *))
|
||||
{
|
||||
o_end->events[0]=proc;
|
||||
o_end->on_event=proc;
|
||||
}
|
||||
void terminate(void)
|
||||
void terminate_gui(void)
|
||||
{
|
||||
exit_wait=1;
|
||||
}
|
||||
|
@ -810,8 +820,8 @@ void goto_control(int obj_id)
|
|||
if (send_lost()) return;
|
||||
o_aktual=find_object(waktual,obj_id);
|
||||
msg.msg=E_GET_FOCUS;
|
||||
o_aktual->events[0](&msg,o_aktual);
|
||||
o_aktual->runs[2](&msg,o_aktual);
|
||||
o_aktual->on_event(&msg,o_aktual);
|
||||
o_aktual->call_event(&msg,o_aktual);
|
||||
}
|
||||
|
||||
void c_set_value(int win_id,int obj_id,int cnst)
|
||||
|
@ -880,12 +890,12 @@ void close_current()
|
|||
|
||||
void background_runner(EVENT_MSG *msg,void **prog)
|
||||
{
|
||||
register void (*p)();
|
||||
void (*p)();
|
||||
char i=1;
|
||||
|
||||
if (msg->msg==E_INIT)
|
||||
{
|
||||
memcpy(prog,msg->data,4);
|
||||
*prog = va_arg(msg->data, void (*)());
|
||||
return;
|
||||
}
|
||||
if (msg->msg==E_DONE)
|
||||
|
|
33
libs/gui.h
33
libs/gui.h
|
@ -1,3 +1,8 @@
|
|||
#include <stdarg.h>
|
||||
|
||||
#ifndef SKELDAL_LIB_GUI
|
||||
#define SKELDAL_LIB_GUI
|
||||
|
||||
#define E_MS_CLICK 50
|
||||
#define E_MS_MOVE 51
|
||||
#define E_GET_FOCUS 52
|
||||
|
@ -10,7 +15,7 @@
|
|||
#define E_CONTROL 59 //User defined feature, enables direct controling desktop objects
|
||||
|
||||
#define CURSOR_SPEED 5;
|
||||
#define get_title(title) (char *)*(long *)(title);
|
||||
#define get_title(title) (char *)*(int32_t *)(title);
|
||||
#define DESK_TOP_COLOR RGB555(0,15,15);
|
||||
#define MINSIZX 60
|
||||
#define MINSIZY 40
|
||||
|
@ -48,7 +53,9 @@ typedef FC_TABLE FC_PALETTE[16];
|
|||
DONE(OBJREC *object);
|
||||
*/
|
||||
|
||||
typedef void (*RUN_ROUTS[4])();
|
||||
typedef struct objrec OBJREC;
|
||||
|
||||
typedef void (*RUN_ROUTS[4])(OBJREC *, va_list);
|
||||
|
||||
typedef struct objrec
|
||||
{
|
||||
|
@ -59,13 +66,19 @@ typedef struct objrec
|
|||
char align,autoresizex,autoresizey;
|
||||
char enabled;
|
||||
short locx,locy;
|
||||
long datasize;
|
||||
int32_t datasize;
|
||||
void *data;
|
||||
FC_TABLE f_color;
|
||||
word *font;
|
||||
void *userptr;
|
||||
RUN_ROUTS runs;
|
||||
RUN_ROUTS events;
|
||||
void (*call_init)(struct objrec *, va_list);
|
||||
void (*call_draw)(int , int, int, int, struct objrec *);
|
||||
void (*call_event)(EVENT_MSG *msg, struct objrec *);
|
||||
void (*call_done)(struct objrec *);
|
||||
void (*on_event)(EVENT_MSG *msg, struct objrec *);
|
||||
void (*on_enter)();
|
||||
void (*on_exit)();
|
||||
void (*on_change)();
|
||||
char draw_error; //1 znamena ze objekt zpusobil chybu a nebude vykreslovan
|
||||
struct objrec *next;
|
||||
}OBJREC;
|
||||
|
@ -94,7 +107,7 @@ typedef struct window
|
|||
CTL3D border3d;
|
||||
word color;
|
||||
OBJREC *objects;
|
||||
long id;
|
||||
int32_t id;
|
||||
char modal,minimized,popup;
|
||||
word minsizx,minsizy;
|
||||
char *window_name;
|
||||
|
@ -117,9 +130,9 @@ extern void *gui_background;
|
|||
|
||||
void draw_border(integer x,integer y,integer xs,integer ys,CTL3D *btype);
|
||||
WINDOW *create_window(int x,int y, int xs, int ys, word color, CTL3D *okraj);
|
||||
long desktop_add_window(WINDOW *w);
|
||||
void select_window(long id);
|
||||
WINDOW *find_window(long id);
|
||||
int32_t desktop_add_window(WINDOW *w);
|
||||
void select_window(int32_t id);
|
||||
WINDOW *find_window(int32_t id);
|
||||
void redraw_object(OBJREC *o);
|
||||
void redraw_window();
|
||||
void define(int id,int x,int y,int xs,int ys,char align,void (*initproc)(OBJREC *),...);
|
||||
|
@ -154,7 +167,7 @@ void disable_bar(int x,int y,int xs,int ys,word color);
|
|||
void movesize_win(WINDOW *w, int newx,int newy, int newxs, int newys);
|
||||
void goto_control(int obj_id);
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
#include <skeldal_win.h>
|
||||
#include <stdio.h>
|
||||
#include <malloc.h>
|
||||
#include <stdlib.h>
|
||||
|
@ -99,7 +100,7 @@ void add_field_txt(TSTR_LIST *ls,const char *name,const char *text)
|
|||
str_replace(ls,i,d);
|
||||
}
|
||||
|
||||
void add_field_num(TSTR_LIST *ls,const char *name,long number)
|
||||
void add_field_num(TSTR_LIST *ls,const char *name,int32_t number)
|
||||
{
|
||||
char buff[20];
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
TSTR_LIST read_config(const char *filename);
|
||||
void add_field_txt(TSTR_LIST *ls,const char *name,const char *text);
|
||||
void add_field_num(TSTR_LIST *ls,const char *name,long number);
|
||||
void add_field_num(TSTR_LIST *ls,const char *name,int32_t number);
|
||||
int save_config(TSTR_LIST ls,const char *filename);
|
||||
const char *get_text_field(TSTR_LIST ls,const char *name);
|
||||
int get_num_field(TSTR_LIST ls,const char *name,int *num);
|
||||
|
|
220
libs/memman.c
220
libs/memman.c
|
@ -1,7 +1,6 @@
|
|||
#include <skeldal_win.h>
|
||||
#include "types.h"
|
||||
#include <mem.h>
|
||||
#include <dos.h>
|
||||
#include <stdio.h>
|
||||
#include <malloc.h>
|
||||
#include <stdlib.h>
|
||||
|
@ -10,8 +9,8 @@
|
|||
//#include <i86.h>
|
||||
#include "swaper.c"
|
||||
#include <fcntl.h>
|
||||
#include <io.h>
|
||||
#include <SYS\STAT.H>
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#define DPMI_INT 0x31
|
||||
#define LOAD_BUFFER 4096
|
||||
|
@ -24,7 +23,7 @@ void bonz_table();
|
|||
char **mman_pathlist=NULL;
|
||||
static char swap_status=0;
|
||||
|
||||
static int swap;
|
||||
static FILE *swap = NULL;
|
||||
char mman_patch=0;
|
||||
|
||||
int memman_handle;
|
||||
|
@ -33,12 +32,7 @@ static int max_handle=0;
|
|||
|
||||
void (*mman_action)(int action)=NULL;
|
||||
|
||||
long last_load_size;
|
||||
void get_mem_info(MEMORYSTATUS *mem)
|
||||
{
|
||||
mem->dwLength=sizeof(*mem);
|
||||
GlobalMemoryStatus(mem);
|
||||
}
|
||||
int32_t last_load_size;
|
||||
|
||||
|
||||
void standard_mem_error(size_t size)
|
||||
|
@ -46,8 +40,8 @@ void standard_mem_error(size_t size)
|
|||
char buff[256];
|
||||
SEND_LOG("(ERROR) Memory allocation error detected, %u bytes missing",size,0);
|
||||
DXCloseMode();
|
||||
sprintf(buff,"Memory allocation error\n Application can't allocate %u bytes of memory (%xh)\n",size,memman_handle);
|
||||
MessageBox(NULL,buff,NULL,MB_OK|MB_ICONSTOP);
|
||||
sprintf(buff,"Memory allocation error\n Application can't allocate %lu bytes of memory (%xh)\n",size,memman_handle);
|
||||
display_error(buff);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
@ -60,7 +54,7 @@ void load_error(char *filename)
|
|||
#endif
|
||||
DXCloseMode();
|
||||
sprintf(buff,"Load error while loading file: %s", filename);
|
||||
MessageBox(NULL,buff,NULL,MB_OK|MB_ICONSTOP);
|
||||
display_error(buff);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
@ -69,7 +63,7 @@ void standard_swap_error()
|
|||
char buff[256];
|
||||
DXCloseMode();
|
||||
sprintf(buff,"Swap error. Maybe disk is full");
|
||||
MessageBox(NULL,buff,NULL,MB_OK|MB_ICONSTOP);
|
||||
display_error(buff);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
@ -77,7 +71,7 @@ void standard_swap_error()
|
|||
void (*mem_error)(size_t)=standard_mem_error;
|
||||
void (*swap_error)()=standard_swap_error;
|
||||
|
||||
void *getmem(long size)
|
||||
void *getmem(int32_t size)
|
||||
{
|
||||
void *p,*res;
|
||||
|
||||
|
@ -94,24 +88,29 @@ void *getmem(long size)
|
|||
if (p==NULL) mem_error(size);
|
||||
}
|
||||
while (p==NULL);
|
||||
// SEND_LOG("(ALLOC) **** Alloc: %p size %d",p,*((long *)p-1));
|
||||
// SEND_LOG("(ALLOC) **** Alloc: %p size %d",p,*((int32_t *)p-1));
|
||||
return p;
|
||||
}
|
||||
|
||||
|
||||
void *load_file(char *filename)
|
||||
{
|
||||
int f;
|
||||
long size,*p;
|
||||
FILE *f;
|
||||
int32_t size,*p;
|
||||
|
||||
if (mman_action!=NULL) mman_action(MMA_READ);
|
||||
SEND_LOG("(LOAD) Loading file '%s'",filename,0);
|
||||
f=open(filename,O_BINARY | O_RDONLY);
|
||||
if (f==-1) load_error(filename);
|
||||
size=filelength(f);
|
||||
f=fopen(filename, "rb");
|
||||
if (f==NULL) {
|
||||
load_error(filename);
|
||||
return NULL;
|
||||
}
|
||||
fseek(f,0, SEEK_END);
|
||||
size=ftell(f);
|
||||
fseek(f,0, SEEK_SET);
|
||||
p=(void *)getmem(size);
|
||||
if (read(f,p,size)!=size) load_error(filename);
|
||||
close(f);
|
||||
if (fread(p,1,size,f)!=size) load_error(filename);
|
||||
fclose(f);
|
||||
last_load_size=size;
|
||||
return p;
|
||||
}
|
||||
|
@ -121,11 +120,11 @@ void *load_file(char *filename)
|
|||
typedef struct tnametable
|
||||
{
|
||||
char name[12];
|
||||
long seek;
|
||||
int32_t seek;
|
||||
}TNAMETABLE;
|
||||
|
||||
|
||||
static long *grptable,grptabsiz;
|
||||
static int32_t *grptable,grptabsiz;
|
||||
static TNAMETABLE *nametable;
|
||||
static int nmtab_size;
|
||||
static int next_name_read=0;
|
||||
|
@ -133,9 +132,9 @@ static int last_group;
|
|||
|
||||
char *main_file_name=NULL;
|
||||
handle_groups _handles;
|
||||
static int bmf=-1;
|
||||
static int patch=-1;
|
||||
unsigned long bk_global_counter=0;
|
||||
static FILE *bmf=NULL;
|
||||
static FILE *patch=NULL;
|
||||
uint32_t bk_global_counter=0;
|
||||
char *swap_path;
|
||||
|
||||
#ifdef LOGFILE
|
||||
|
@ -164,14 +163,14 @@ static int test_file_exist_DOS(int group,char *filename)
|
|||
|
||||
void load_grp_table()
|
||||
{
|
||||
long i;
|
||||
int32_t i;
|
||||
|
||||
SEND_LOG("(LOAD) Loading Group Table",0,0);
|
||||
lseek(bmf,4,SEEK_SET);
|
||||
read(bmf,&i,4);
|
||||
grptable=(long *)getmem(i+4);
|
||||
lseek(bmf,0,SEEK_SET);
|
||||
read(bmf,grptable,i);
|
||||
fseek(bmf,4,SEEK_SET);
|
||||
fread(&i,4,1,bmf);
|
||||
grptable=(int32_t *)getmem(i+4);
|
||||
fseek(bmf,0,SEEK_SET);
|
||||
fread(grptable,i,1,bmf);
|
||||
grptabsiz=i;
|
||||
for(i=0;i<(grptabsiz>>3);i++) grptable[i*2+1]=(grptable[i*2+1]-grptabsiz)>>4;
|
||||
SEND_LOG("(LOAD) Group Table Loaded",0,0);
|
||||
|
@ -183,13 +182,13 @@ void load_file_table()
|
|||
void *p;
|
||||
|
||||
SEND_LOG("(LOAD) Loading File Table",0,0);
|
||||
lseek(bmf,grptabsiz,SEEK_SET);
|
||||
lseek(bmf,12,SEEK_CUR);
|
||||
read(bmf,&strsize,4);
|
||||
fseek(bmf,grptabsiz,SEEK_SET);
|
||||
fseek(bmf,12,SEEK_CUR);
|
||||
fread(&strsize,4,1,bmf);
|
||||
strsize-=grptabsiz;
|
||||
lseek(bmf,grptabsiz,SEEK_SET);
|
||||
fseek(bmf,grptabsiz,SEEK_SET);
|
||||
p=getmem(strsize);memcpy(&nametable,&p,4);
|
||||
read(bmf,nametable,strsize);
|
||||
fread(nametable,1,strsize,bmf);
|
||||
nmtab_size=strsize/sizeof(*nametable);
|
||||
SEND_LOG("(LOAD) File Table Loaded",0,0);
|
||||
}
|
||||
|
@ -224,17 +223,16 @@ int get_file_entry(int group,char *name)
|
|||
}
|
||||
int swap_block(THANDLE_DATA *h)
|
||||
{
|
||||
long wsize,pos;
|
||||
int32_t wsize,pos;
|
||||
|
||||
if (mman_action!=NULL) mman_action(MMA_SWAP);
|
||||
if (swap==-1) return -1;
|
||||
if (!swap) return -1;
|
||||
if (h->flags & BK_HSWAP) pos=h->seekpos; else pos=swap_add_block(h->size);
|
||||
lseek(swap,0,SEEK_END);
|
||||
wsize=tell(swap);
|
||||
if (wsize<pos) write(swap,NULL,pos-wsize);
|
||||
lseek(swap,pos,SEEK_SET);
|
||||
fseek(swap,0,SEEK_END);
|
||||
wsize=ftell(swap);
|
||||
fseek(swap,pos,SEEK_SET);
|
||||
SEND_LOG("(SWAP) Swaping block '%-.12hs'",h->src_file,0);
|
||||
wsize=write(swap,h->blockdata,h->size);
|
||||
wsize=fwrite(h->blockdata,1,h->size,swap);
|
||||
swap_status=1;
|
||||
if ((unsigned)wsize==h->size)
|
||||
{
|
||||
|
@ -271,7 +269,7 @@ void heap_error(size_t size) //heap system
|
|||
{
|
||||
int i,j;
|
||||
char swaped=0;
|
||||
unsigned long maxcounter=0;
|
||||
uint32_t maxcounter=0;
|
||||
THANDLE_DATA *sh;
|
||||
char repeat=0,did=0;
|
||||
THANDLE_DATA *lastblock=NULL;
|
||||
|
@ -285,7 +283,7 @@ void heap_error(size_t size) //heap system
|
|||
for(i=0;i<BK_MAJOR_HANDLES;i++)
|
||||
if (_handles[i]!=NULL)
|
||||
{
|
||||
unsigned long c,max=0xffffffff,d;
|
||||
uint32_t c,max=0xffffffff,d;
|
||||
for (j=0;j<BK_MINOR_HANDLES;j++)
|
||||
{
|
||||
THANDLE_DATA *h;
|
||||
|
@ -375,7 +373,7 @@ THANDLE_DATA *zneplatnit_block(int handle)
|
|||
return h;
|
||||
}
|
||||
|
||||
void init_manager(char *filename,char *swp) // filename= Jmeno datoveho souboru nebo NULL pak
|
||||
void init_manager(char *filename,char */*swap is not supported*/) // filename= Jmeno datoveho souboru nebo NULL pak
|
||||
// se pouzije DOS
|
||||
// swp je cesta do TEMP adresare
|
||||
{
|
||||
|
@ -384,8 +382,8 @@ void init_manager(char *filename,char *swp) // filename= Jmeno datoveho souboru
|
|||
memset(_handles,0,sizeof(_handles));
|
||||
if (filename!=NULL)
|
||||
{
|
||||
bmf=open(filename,O_BINARY | O_RDONLY);
|
||||
if (bmf!=-1)
|
||||
bmf=fopen(filename,"rb");
|
||||
if (bmf)
|
||||
{
|
||||
main_file_name=(char *)getmem(strlen(filename)+1);
|
||||
strcpy(main_file_name,filename);
|
||||
|
@ -398,13 +396,7 @@ void init_manager(char *filename,char *swp) // filename= Jmeno datoveho souboru
|
|||
else
|
||||
main_file_name=NULL;
|
||||
mem_error=heap_error;
|
||||
if (swp!=NULL)
|
||||
{
|
||||
swap=open(swp,O_BINARY | O_RDWR | O_CREAT | O_TRUNC,_S_IREAD | _S_IWRITE);
|
||||
swap_init();
|
||||
}
|
||||
else
|
||||
swap=-1;
|
||||
swap=NULL;
|
||||
}
|
||||
|
||||
void *load_swaped_block(THANDLE_DATA *h)
|
||||
|
@ -414,8 +406,8 @@ void *load_swaped_block(THANDLE_DATA *h)
|
|||
if (mman_action!=NULL) mman_action(MMA_SWAP_READ);
|
||||
i=getmem(h->size);
|
||||
SEND_LOG("(LOAD)(SWAP) Loading block from swap named '%-.12hs'",h->src_file,0);
|
||||
lseek(swap,h->seekpos,SEEK_SET);
|
||||
read(swap,i,h->size);
|
||||
fseek(swap,h->seekpos,SEEK_SET);
|
||||
fread(i,1,h->size,swap);
|
||||
h->status=BK_PRESENT;
|
||||
return i;
|
||||
}
|
||||
|
@ -430,7 +422,7 @@ int find_same(char *name,void *decomp)
|
|||
if (name[0]==0) return -1;
|
||||
for(i=0;i<BK_MAJOR_HANDLES;i++)
|
||||
if (_handles[i]!=NULL)
|
||||
{
|
||||
{
|
||||
p=(THANDLE_DATA *)(_handles[i]);
|
||||
for(j=0;j<BK_MINOR_HANDLES;j++)
|
||||
if ((!strncmp(p[j].src_file,name,12))&& (p[j].loadproc==decomp)) return i*BK_MINOR_HANDLES+j;
|
||||
|
@ -483,10 +475,10 @@ THANDLE_DATA *def_handle(int handle,char *filename,void *decompress,char path)
|
|||
return h;
|
||||
}
|
||||
|
||||
void *afile(char *filename,int group,long *blocksize)
|
||||
void *afile(char *filename,int group,int32_t *blocksize)
|
||||
{
|
||||
char *c,*d;
|
||||
long entr;
|
||||
int32_t entr;
|
||||
void *p;
|
||||
|
||||
d=alloca(strlen(filename)+1);
|
||||
|
@ -496,13 +488,13 @@ void *afile(char *filename,int group,long *blocksize)
|
|||
else entr=get_file_entry(group,d);
|
||||
if (entr!=0)
|
||||
{
|
||||
int hnd;
|
||||
FILE *hnd;
|
||||
SEND_LOG("(LOAD) Afile is loading file '%s' from group %d",d,group);
|
||||
if (entr<0) entr=-entr,hnd=patch;else hnd=bmf;
|
||||
lseek(hnd,entr,SEEK_SET);
|
||||
read(hnd,blocksize,4);
|
||||
fseek(hnd,entr,SEEK_SET);
|
||||
fread(blocksize,1,4,hnd);
|
||||
p=getmem(*blocksize);
|
||||
read(hnd,p,*blocksize);
|
||||
fread(p,1,*blocksize,hnd);
|
||||
}
|
||||
else if (mman_pathlist!=NULL)
|
||||
{
|
||||
|
@ -536,7 +528,7 @@ void *ablock(int handle)
|
|||
}
|
||||
if (h->status==BK_NOT_LOADED)
|
||||
{
|
||||
void *p;long s;
|
||||
void *p;int32_t s;
|
||||
char c[200];
|
||||
|
||||
SEND_LOG("(LOAD) Loading file as block '%-.12hs' %04X",h->src_file,handle);
|
||||
|
@ -563,13 +555,14 @@ void *ablock(int handle)
|
|||
}
|
||||
else
|
||||
{
|
||||
int entr=h->seekpos,hnd;
|
||||
int entr=h->seekpos;
|
||||
FILE *hnd;
|
||||
if (mman_action!=NULL) mman_action(MMA_READ);
|
||||
if (entr<0) entr=-entr,hnd=patch;else hnd=bmf;
|
||||
lseek(hnd,entr,SEEK_SET);
|
||||
read(hnd,&s,4);
|
||||
fseek(hnd,entr,SEEK_SET);
|
||||
fread(&s,1,4,hnd);
|
||||
p=getmem(s);
|
||||
read(hnd,p,s);
|
||||
fread(p,1,s,hnd);
|
||||
if (h->loadproc!=NULL) h->loadproc(&p,&s);
|
||||
h->blockdata=p;
|
||||
h->status=BK_PRESENT;
|
||||
|
@ -642,16 +635,16 @@ void apreload(int handle)
|
|||
}
|
||||
}
|
||||
|
||||
static long *apr_sign=NULL;
|
||||
static long max_sign;
|
||||
static int32_t *apr_sign=NULL;
|
||||
static int32_t max_sign;
|
||||
|
||||
void apreload_sign(int handle,int max_handle)
|
||||
{
|
||||
THANDLE_DATA *h;
|
||||
if (apr_sign==NULL)
|
||||
{
|
||||
apr_sign=NewArr(long,max_handle);
|
||||
memset(apr_sign,0x7f,sizeof(long)*max_handle);
|
||||
apr_sign=NewArr(int32_t,max_handle);
|
||||
memset(apr_sign,0x7f,sizeof(int32_t)*max_handle);
|
||||
max_sign=max_handle;
|
||||
}
|
||||
if (handle>=max_sign)
|
||||
|
@ -664,9 +657,9 @@ void apreload_sign(int handle,int max_handle)
|
|||
if (!(h->flags & BK_PRELOAD) || !(h->flags & BK_HSWAP)) apr_sign[handle]=h->seekpos;
|
||||
}
|
||||
|
||||
static int apreload_sort(const void *val1,const void *val2)
|
||||
int apreload_sort(const void *val1,const void *val2)
|
||||
{
|
||||
long vl1,vl2;
|
||||
int32_t vl1,vl2;
|
||||
|
||||
vl1=apr_sign[*(word *)val1];
|
||||
vl2=apr_sign[*(word *)val2];
|
||||
|
@ -728,9 +721,9 @@ void close_manager()
|
|||
free(_handles[i]);
|
||||
}
|
||||
free(main_file_name);
|
||||
close(bmf);
|
||||
if (swap!=-1) close(swap);
|
||||
// fclose(log);
|
||||
if (bmf) fclose(bmf);
|
||||
if (patch) fclose(patch);
|
||||
if (swap) fclose(swap);
|
||||
free(grptable); grptable=NULL;
|
||||
free(nametable); nametable=NULL;
|
||||
max_handle=0;
|
||||
|
@ -761,9 +754,8 @@ void display_status()
|
|||
char flags[]={"LS*PH"};
|
||||
char copys[6]=" ";
|
||||
char nname[14];
|
||||
long total_data=0;
|
||||
long total_mem=0;
|
||||
MEMORYSTATUS mem;
|
||||
int32_t total_data=0;
|
||||
int32_t total_mem=0;
|
||||
int ln=0;
|
||||
|
||||
//block();
|
||||
|
@ -781,9 +773,9 @@ void display_status()
|
|||
|
||||
for(k=0;k<5;k++) copys[k]=h->flags & (1<<k)?flags[k]:'.';
|
||||
if (h->src_file[0]) strncpy(nname,h->src_file,12);else strcpy(nname,"<local>");
|
||||
printf("%04Xh ... %12s %s %s %08Xh %6d %10d %6d \n",i*BK_MINOR_HANDLES+j,
|
||||
printf("%04Xh ... %12s %s %s %08lXh %6d %10d %6d \n",i*BK_MINOR_HANDLES+j,
|
||||
nname,names[h->status-1],
|
||||
copys,(int)h->blockdata,h->size,h->counter,h->lockcount);
|
||||
copys,(uintptr_t)h->blockdata,h->size,h->counter,h->lockcount);
|
||||
ln++;
|
||||
total_data+=h->size;
|
||||
if(h->status==BK_PRESENT)total_mem+=h->size;
|
||||
|
@ -802,33 +794,29 @@ void display_status()
|
|||
}
|
||||
|
||||
}
|
||||
get_mem_info(&mem);
|
||||
printf("Data: %7d KB, Loaded: %7d KB, Largest free: %7d KB",total_data/1024,total_mem/1024,mem.dwAvailPageFile/1024);
|
||||
printf("Data: %7d KB, Loaded: %7d KB",total_data/1024,total_mem/1024);
|
||||
while (getchar()!='\n');
|
||||
}
|
||||
|
||||
void *grealloc(void *p,long size)
|
||||
void *grealloc(void *p,int32_t size)
|
||||
{
|
||||
void *q;
|
||||
long scop;
|
||||
int32_t scop;
|
||||
|
||||
if (!size)
|
||||
{
|
||||
free(p);
|
||||
return NULL;
|
||||
}
|
||||
/*q=realloc(p,size);
|
||||
q=realloc(p,size);
|
||||
if (q!=NULL)
|
||||
{
|
||||
SEND_LOG("(ALLOC) **** Realloc: New %p size %d\n",q,*((long *)q-1));
|
||||
SEND_LOG("(ALLOC) **** Realloc: New %p size %d\n",q,*((int32_t *)q-1));
|
||||
return q;
|
||||
}*/
|
||||
}
|
||||
q=getmem(size);
|
||||
if (p==NULL) return q;
|
||||
scop=_msize(p);
|
||||
if (scop>size) scop=size;
|
||||
memmove(q,p,scop);
|
||||
free(p);
|
||||
free(q);
|
||||
q=realloc(p,size);
|
||||
return q;
|
||||
}
|
||||
|
||||
|
@ -847,25 +835,25 @@ int read_group(int index)
|
|||
|
||||
char add_patch_file(char *filename)
|
||||
{
|
||||
long l;
|
||||
long poc;
|
||||
int32_t l;
|
||||
int32_t poc;
|
||||
int i,cc=0;
|
||||
TNAMETABLE p;
|
||||
SEND_LOG("Adding patch: %s",filename,0);
|
||||
if (patch!=-1) return 2;
|
||||
if (bmf==-1) return 3;
|
||||
patch=open(filename,O_BINARY|O_RDONLY);
|
||||
if (patch==-1) return 1;
|
||||
lseek(patch,4,SEEK_SET);
|
||||
read(patch,&l,4);
|
||||
lseek(patch,l,SEEK_SET);
|
||||
read(patch,&p,sizeof(p));
|
||||
if (!patch) return 2;
|
||||
if (!bmf) return 3;
|
||||
patch=fopen(filename,"rb");
|
||||
if (!patch) return 1;
|
||||
fseek(patch,4,SEEK_SET);
|
||||
fread(&l,1,4,patch);
|
||||
fseek(patch,l,SEEK_SET);
|
||||
fread(&p,1,sizeof(p),patch);
|
||||
poc=(p.seek-l)/sizeof(p);
|
||||
lseek(patch,l,SEEK_SET);
|
||||
fseek(patch,l,SEEK_SET);
|
||||
for(i=0;i<poc;i++)
|
||||
{
|
||||
int j;
|
||||
read(patch,&p,sizeof(p));
|
||||
fread(&p,1,sizeof(p),patch);
|
||||
j=find_name(read_group(0),p.name);
|
||||
if (j==-1)
|
||||
{
|
||||
|
@ -883,7 +871,7 @@ char add_patch_file(char *filename)
|
|||
void free(void *c)
|
||||
{
|
||||
if (c==NULL) return;
|
||||
SEND_LOG("(ALLOC)úúú Dealloc: %p size %d",c,*((long *)c-1));
|
||||
SEND_LOG("(ALLOC)<EFBFBD><EFBFBD><EFBFBD> Dealloc: %p size %d",c,*((int32_t *)c-1));
|
||||
free(c);
|
||||
}
|
||||
*/
|
||||
|
@ -914,7 +902,7 @@ char *get_time_str()
|
|||
static char text[20];
|
||||
|
||||
|
||||
time( &long_time ); /* Get time as long integer. */
|
||||
time( &long_time ); /* Get time as int32_t integer. */
|
||||
newtime = localtime( &long_time ); /* Convert to local time. */
|
||||
|
||||
sprintf(text,"%02d:%02d:%02d",newtime->tm_hour,newtime->tm_min,newtime->tm_sec);
|
||||
|
@ -924,7 +912,7 @@ char *get_time_str()
|
|||
|
||||
#endif
|
||||
|
||||
long get_handle_size(int handle)
|
||||
int32_t get_handle_size(int handle)
|
||||
{
|
||||
THANDLE_DATA *h;
|
||||
|
||||
|
@ -942,7 +930,7 @@ long get_handle_size(int handle)
|
|||
if (log!=NULL && zavora)
|
||||
{
|
||||
zavora=0;
|
||||
fprintf(log,"Alloc: %p size %d\n",c,*((long *)c-1));
|
||||
fprintf(log,"Alloc: %p size %d\n",c,*((int32_t *)c-1));
|
||||
zavora=1;
|
||||
}
|
||||
return c;
|
||||
|
@ -951,7 +939,7 @@ long get_handle_size(int handle)
|
|||
|
||||
FILE *afiletemp(char *filename, int group)
|
||||
{
|
||||
long size;
|
||||
int32_t size;
|
||||
void *p=afile(filename,group,&size);
|
||||
FILE *f;
|
||||
if (p==NULL) return NULL;
|
||||
|
@ -960,4 +948,4 @@ FILE *afiletemp(char *filename, int group)
|
|||
fwrite(p,size,1,f);
|
||||
fseek(f,0,SEEK_SET);
|
||||
return f;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,15 +27,15 @@ typedef struct meminfo {
|
|||
typedef struct thandle_data
|
||||
{
|
||||
char src_file[12]; //12
|
||||
long seekpos; //16
|
||||
int32_t seekpos; //16
|
||||
void *blockdata; //20
|
||||
char flags; //21
|
||||
char path; //22
|
||||
short status;
|
||||
void (*loadproc)(void **data,long *size);//28
|
||||
void (*loadproc)(void **data,int32_t *size);//28
|
||||
unsigned short lockcount; //32
|
||||
unsigned long counter;
|
||||
unsigned long size;
|
||||
uint32_t counter;
|
||||
uint32_t size;
|
||||
}THANDLE_DATA;
|
||||
|
||||
#define BK_MAJOR_HANDLES 256 // maximalni pocet skupin rukojeti
|
||||
|
@ -64,8 +64,8 @@ extern void (*mem_error)(size_t); //pokud neni NULL je tato funkce volana vzd
|
|||
extern void (*swap_error)();
|
||||
extern int memman_handle; //cislo handle naposled zpracovavaneho prikazem ablock
|
||||
extern char mman_patch; //jednicka zapina moznost pouziti patchu
|
||||
void *getmem(long size); //alokace pameti pres memman. alokovat pomoci malloc lze ale hrozi nebezpeci ze vrati NULL
|
||||
void *grealloc(void *m,long size); //realokace pameti pres memman
|
||||
void *getmem(int32_t size); //alokace pameti pres memman. alokovat pomoci malloc lze ale hrozi nebezpeci ze vrati NULL
|
||||
void *grealloc(void *m,int32_t size); //realokace pameti pres memman
|
||||
void *load_file(char *filename); //obycejne natahne soubor do pameti a vrati ukazatel.
|
||||
void init_manager(char *filename,char *swp); //inicializuje manager. Jmeno filename i swapname nejsou povinne (musi byt NULL kdyz nejsou pouzity)
|
||||
THANDLE_DATA *def_handle(int handle,char *filename,void *decompress,char path); //deklaruje rukojet. promenna decompress je ukazatel na funkci ktera upravi data pred vracenim ukazatele
|
||||
|
@ -82,8 +82,8 @@ THANDLE_DATA *zneplatnit_block(int handle); //zneplatni data bloku
|
|||
THANDLE_DATA *get_handle(int handle); //vraci informace o rukojeti
|
||||
int find_handle(char *name,void *decomp); //hleda mezi rukojeti stejnou definici
|
||||
int test_file_exist(int group,char *filename); //testuje zda soubor existuje v ramci mmanageru
|
||||
void *afile(char *filename,int group,long *blocksize); //nahraje do pameti soubor registrovany v ramci mmanageru
|
||||
long get_handle_size(int handle);
|
||||
void *afile(char *filename,int group,int32_t *blocksize); //nahraje do pameti soubor registrovany v ramci mmanageru
|
||||
int32_t get_handle_size(int handle);
|
||||
//void get_mem_info(MEMORYSTATUS *mem);
|
||||
|
||||
void apreload_sign(int handle,int max_handle); //pripravi preloading pro nacteni dat z CD (sekvencne)
|
||||
|
|
|
@ -92,7 +92,7 @@ static char bankmode=0;
|
|||
static char colr64=0;
|
||||
|
||||
static void *bufpos;
|
||||
long vals_save=0x80008000;
|
||||
int32_t vals_save=0x80008000;
|
||||
|
||||
static void *f,*temp;
|
||||
static int posyb,posyl;
|
||||
|
@ -112,7 +112,7 @@ static char screen_mode=SMD_256;
|
|||
char year[2];
|
||||
char eof;
|
||||
word ver;
|
||||
long frames;
|
||||
int32_t frames;
|
||||
word snd_chans;
|
||||
int snd_freq;
|
||||
short ampl_table[256];
|
||||
|
@ -167,8 +167,8 @@ static void close_mgf_file()
|
|||
|
||||
static void load_frame(void *f)
|
||||
{
|
||||
long frame_head;
|
||||
long frame_size;
|
||||
int32_t frame_head;
|
||||
int32_t frame_size;
|
||||
|
||||
bread(&frame_head,4);
|
||||
chunks=frame_head & 0xff;
|
||||
|
@ -248,7 +248,7 @@ static void show_frame(void *fr,void *temp)
|
|||
{
|
||||
int x;
|
||||
char *p,a;
|
||||
long siz;
|
||||
int32_t siz;
|
||||
int frmode=0,i;
|
||||
void *sound=NULL;int ssize;
|
||||
static last_counter=-1;
|
||||
|
@ -257,7 +257,7 @@ static void show_frame(void *fr,void *temp)
|
|||
|
||||
for(x=0;x<chunks;x++)
|
||||
{
|
||||
a=*p;siz=*(long *)p>>8;p+=4;
|
||||
a=*p;siz=*(int32_t *)p>>8;p+=4;
|
||||
switch(a)
|
||||
{
|
||||
case MGIF_LZW:
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
#include <skeldal_win.h>
|
||||
#include <bgraph.h>
|
||||
#include <bgraph2dx.h>
|
||||
#include <stdio.h>
|
||||
#include "types.h"
|
||||
#include "memman.h"
|
||||
|
@ -8,21 +7,11 @@
|
|||
#include "mgifmem.h"
|
||||
#include <zvuk.h>
|
||||
|
||||
static HANDLE mapped_mgif;
|
||||
static HANDLE mgif_file;
|
||||
static MGIF_HEADER_T *mgif_header;
|
||||
|
||||
static short mgif_accnums[2];
|
||||
static long mgif_writepos;
|
||||
static int32_t mgif_writepos;
|
||||
|
||||
static void *OpenMGFFile(const char *filename)
|
||||
{
|
||||
mgif_file=CreateFile(filename,GENERIC_READ,FILE_SHARE_READ,NULL,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL|FILE_FLAG_SEQUENTIAL_SCAN,NULL);
|
||||
if (mgif_file==INVALID_HANDLE_VALUE) return NULL;
|
||||
mapped_mgif=CreateFileMapping(mgif_file,NULL,PAGE_READONLY,0,0,NULL);
|
||||
if (mapped_mgif==INVALID_HANDLE_VALUE) return NULL;
|
||||
return MapViewOfFile(mapped_mgif,FILE_MAP_READ,0,0,0);
|
||||
}
|
||||
|
||||
static word *paleta;
|
||||
|
||||
|
@ -30,14 +19,14 @@ static word *picture;
|
|||
static word *anim_render_buffer;
|
||||
static void *sound;
|
||||
|
||||
static void StretchImageHQ(word *src, word *trg, unsigned long linelen, char full)
|
||||
static void StretchImageHQ(word *src, word *trg, uint32_t linelen, char full)
|
||||
{
|
||||
word xs=src[0],ys=src[1];
|
||||
word *s,*t;
|
||||
int x,y;
|
||||
src+=3;
|
||||
for (y=0,s=src,t=trg;y<ys;y++,t+=linelen*2,s+=xs)
|
||||
for (x=0;x<xs;x++)
|
||||
src+=3;
|
||||
for (y=0,s=src,t=trg;y<ys;y++,t+=linelen*2,s+=xs)
|
||||
for (x=0;x<xs;x++)
|
||||
{
|
||||
word val;
|
||||
t[x*2]=s[x]+(s[x]&0x7fe0);
|
||||
|
@ -77,37 +66,25 @@ static void PlayMGFFile(void *file, MGIF_PROC proc,int ypos,char full)
|
|||
mgif_header=(MGIF_HEADER_T *)file;
|
||||
file=open_mgif(file);
|
||||
if (file==NULL) return;
|
||||
while (file)
|
||||
while (file)
|
||||
{
|
||||
__try
|
||||
{
|
||||
file=mgif_play(file);
|
||||
}
|
||||
__except(1)
|
||||
{
|
||||
SEND_LOG("(PLAYANIM) Exception raised",0,0);
|
||||
file=NULL;
|
||||
}
|
||||
StretchImageHQ(picture, GetScreenAdr()+ypos*scr_linelen2, scr_linelen2,full);
|
||||
showview(0,ypos,0,360);
|
||||
if (_bios_keybrd(_KEYBRD_READY)==0) mix_back_sound(0);
|
||||
else
|
||||
{
|
||||
_bios_keybrd(_KEYBRD_READ);
|
||||
break;
|
||||
file=mgif_play(file);
|
||||
StretchImageHQ(picture, GetScreenAdr()+ypos*scr_linelen2, scr_linelen2,full);
|
||||
showview(0,ypos,0,360);
|
||||
if (_bios_keybrd(_KEYBRD_READY)==0) {
|
||||
mix_back_sound(0);
|
||||
}
|
||||
else
|
||||
{
|
||||
_bios_keybrd(_KEYBRD_READ);
|
||||
break;
|
||||
}
|
||||
}
|
||||
close_mgif();
|
||||
close_mgif();
|
||||
DoneVideoSound(sound);
|
||||
free(picture);
|
||||
}
|
||||
|
||||
static void CloseMGFFile(void *file)
|
||||
{
|
||||
UnmapViewOfFile(file);
|
||||
CloseHandle(mapped_mgif);
|
||||
CloseHandle(mgif_file);
|
||||
}
|
||||
|
||||
void show_full_lfb12e(void *target,void *buff,void *paleta);
|
||||
void show_delta_lfb12e(void *target,void *buff,void *paleta);
|
||||
|
@ -123,18 +100,19 @@ void BigPlayProc(int act,void *data,int csize)
|
|||
case MGIF_COPY:show_full_lfb12e(anim_render_buffer,data,paleta);break;
|
||||
case MGIF_DELTA:show_delta_lfb12e(anim_render_buffer,data,paleta);break;
|
||||
case MGIF_PAL:paleta=data;break;
|
||||
case MGIF_SOUND:
|
||||
case MGIF_SOUND:
|
||||
while (LoadNextVideoFrame(sound,data,csize,mgif_header->ampl_table,mgif_accnums,&mgif_writepos)==0);
|
||||
}
|
||||
}
|
||||
|
||||
void play_animation(char *filename,char mode,int posy,char sound)
|
||||
{
|
||||
void *mgf=OpenMGFFile(filename);
|
||||
size_t sz;
|
||||
void *mgf=map_file_to_memory(filename, &sz);
|
||||
change_music(NULL);
|
||||
if (mgf==NULL) return;
|
||||
PlayMGFFile(mgf,BigPlayProc,posy,mode & 0x80);
|
||||
CloseMGFFile(mgf);
|
||||
unmap_file(mgf, sz);
|
||||
}
|
||||
|
||||
void set_title_list(char **titles)
|
||||
|
|
|
@ -98,8 +98,17 @@ void close_mgif() //dealokuje buffery pro prehravani
|
|||
}
|
||||
|
||||
|
||||
int input_code(void *source,long *bitepos,int bitsize,int mask)
|
||||
int input_code(void *source,int32_t *bitepos,int bitsize,int mask)
|
||||
{
|
||||
int32_t ofs = *bitepos >> 3;
|
||||
int32_t shf = *bitepos & 0x7;
|
||||
uint8_t *src = source;
|
||||
uint8_t val1 = src[ofs];
|
||||
uint8_t val2 = src[ofs+1];
|
||||
uint16_t val = val1 + val2 * 256;
|
||||
*bitepos+=bitsize;
|
||||
return val >> shf;
|
||||
/*
|
||||
__asm
|
||||
{
|
||||
mov esi,source
|
||||
|
@ -116,6 +125,7 @@ int input_code(void *source,long *bitepos,int bitsize,int mask)
|
|||
and eax,edx
|
||||
add [edi],ebx
|
||||
}
|
||||
*/
|
||||
}
|
||||
//#pragma aux input_code parm [esi][edi][ebx][edx]=\ value[eax] modify [ecx];
|
||||
|
||||
|
@ -135,9 +145,44 @@ int de_add_code(int group,int chr,int mask)
|
|||
}
|
||||
|
||||
|
||||
char fast_expand_code(int code,char **target)
|
||||
//#pragma aux fast_expand_code parm[eax][edi] modify [esi ecx] value [bl]
|
||||
int fast_expand_code(DOUBLE_S *compress_dic, int code,uint8_t **target, uint8_t *old_value)
|
||||
{
|
||||
|
||||
uint8_t out;
|
||||
uint8_t w;
|
||||
if (code >= 256) {
|
||||
|
||||
DOUBLE_S *pos = compress_dic+code;
|
||||
uint8_t *t = *target + pos->first;
|
||||
(**target) += pos->first+1;
|
||||
short len = pos->first;
|
||||
short group = pos->group;
|
||||
do{
|
||||
*t = pos->chr;
|
||||
--t;
|
||||
group = pos->group;
|
||||
pos = compress_dic+group;
|
||||
} while (group >= 256);
|
||||
w=(uint8_t)group;
|
||||
out = w;
|
||||
w += *old_value;
|
||||
*t = w;
|
||||
while (len) {
|
||||
++t;
|
||||
w = w + *t;
|
||||
*t = w;
|
||||
--len;
|
||||
}
|
||||
*old_value = w;
|
||||
} else {
|
||||
out = (uint8_t) code;
|
||||
w = out + *old_value;
|
||||
*old_value = w;
|
||||
**target = out;
|
||||
(*target)++;
|
||||
return code;
|
||||
}
|
||||
/*
|
||||
_asm
|
||||
{
|
||||
mov eax,code
|
||||
|
@ -149,20 +194,20 @@ char fast_expand_code(int code,char **target)
|
|||
inc dword ptr [edi]
|
||||
mov bl,al
|
||||
add al,old_value
|
||||
mov [esi],al
|
||||
mov [esi],al //esi - target ptr
|
||||
mov old_value,al
|
||||
jmp end
|
||||
expand:
|
||||
mov ebx,compress_dic
|
||||
lea ecx,[eax*8+ebx]
|
||||
movzx eax,short ptr [ecx+4]
|
||||
movzx eax,short ptr [ecx+4] // first
|
||||
add [edi],eax
|
||||
push eax
|
||||
mov esi,[edi]
|
||||
eloop:movzx eax,short ptr [ecx+2]
|
||||
mov esi,[edi] //esi - target ptr
|
||||
eloop:movzx eax,short ptr [ecx+2] // chr
|
||||
mov [esi],al
|
||||
dec esi
|
||||
movzx eax,short ptr [ecx]
|
||||
movzx eax,short ptr [ecx] //group
|
||||
lea ecx,[eax*8+ebx]
|
||||
cmp eax,256
|
||||
jnc eloop
|
||||
|
@ -180,12 +225,13 @@ elp2:inc esi
|
|||
end:
|
||||
movzx eax,bl
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
void lzw_decode(void *source,char *target)
|
||||
{
|
||||
long bitpos=0;
|
||||
int32_t bitpos=0;
|
||||
register int code;
|
||||
int old,i;
|
||||
//int group,chr;
|
||||
|
@ -195,12 +241,13 @@ void lzw_decode(void *source,char *target)
|
|||
|
||||
for(i=0;i<LZW_MAX_CODES;i++) compress_dic[i].first=0;
|
||||
clear:
|
||||
old_value=0;
|
||||
uint8_t old_value=0;
|
||||
nextgroup=free_code;
|
||||
bitsize=init_bitsize;
|
||||
mask=(1<<bitsize)-1;
|
||||
code=input_code(source,&bitpos,bitsize,mask);
|
||||
old_first=fast_expand_code(code,&target);
|
||||
uint8_t *t = target;
|
||||
old_first=fast_expand_code(compress_dic,code,&t,&old_value);
|
||||
old=code;
|
||||
while ((code=input_code(source,&bitpos,bitsize,mask))!=end_code)
|
||||
{
|
||||
|
@ -210,7 +257,7 @@ void lzw_decode(void *source,char *target)
|
|||
}
|
||||
else if (code<nextgroup)
|
||||
{
|
||||
old_first=fast_expand_code(code,&target);
|
||||
old_first=fast_expand_code(compress_dic,code,&t,&old_value);
|
||||
//group=old;
|
||||
//chr=old_first;
|
||||
mask=de_add_code(old,old_first,mask);
|
||||
|
@ -221,7 +268,7 @@ void lzw_decode(void *source,char *target)
|
|||
//p.group=old;
|
||||
//p.chr=old_first;
|
||||
mask=de_add_code(old,old_first,mask);
|
||||
old_first=fast_expand_code(code,&target);
|
||||
old_first=fast_expand_code(compress_dic,code,&t, &old_value);
|
||||
old=code;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@ typedef struct mgif_header
|
|||
char year[2];
|
||||
char eof;
|
||||
word ver;
|
||||
long frames;
|
||||
int32_t frames;
|
||||
word snd_chans;
|
||||
int snd_freq;
|
||||
short ampl_table[256];
|
||||
|
|
405
libs/mgifplaya.c
405
libs/mgifplaya.c
|
@ -4,105 +4,25 @@
|
|||
#include <bgraph.h>
|
||||
|
||||
|
||||
void show_full_lfb12e(void *target, void *buff, void *paleta) {
|
||||
uint16_t *edi = (uint16_t *)target;
|
||||
uint8_t *esi = (uint8_t *)buff;
|
||||
uint16_t *ebx = (uint16_t *)paleta;
|
||||
uint8_t dl = 180;
|
||||
|
||||
void show_full_interl_lfb(void *source,void *target,void *palette, long linelen)
|
||||
{
|
||||
int sslinelen=2*linelen-1280;
|
||||
__asm
|
||||
{
|
||||
mov edi,target
|
||||
mov esi,source
|
||||
mov ebx,palette
|
||||
;edi - target
|
||||
;esi - source
|
||||
;ebx - palette
|
||||
push ebp
|
||||
push sslinelen;
|
||||
mov dl,180
|
||||
shfif2: mov ecx,320
|
||||
shfif1: lodsb
|
||||
movzx eax,al
|
||||
movzx eax,short ptr [eax*2+ebx]
|
||||
mov ebp,eax
|
||||
shl eax,16
|
||||
or eax,ebp
|
||||
stosd
|
||||
dec ecx
|
||||
jnz shfif1
|
||||
add edi,[esp]
|
||||
dec dl
|
||||
jnz shfif2
|
||||
pop eax
|
||||
pop ebp
|
||||
}
|
||||
}
|
||||
//#pragma aux show_full_interl_lfb parm [esi][edi][ebx] modify [eax ecx edx]
|
||||
void show_delta_interl_lfb(void *source,void *target,void *palette, long linelen)
|
||||
{
|
||||
int sslinelen=2*linelen;
|
||||
__asm
|
||||
{
|
||||
mov edi,target
|
||||
mov esi,source
|
||||
mov ebx,palette
|
||||
;edi - target
|
||||
;esi - source
|
||||
;ebx - palette
|
||||
push ebp ;uchovej ebp
|
||||
push sslinelen
|
||||
mov cl,180 ;cl pocet zbyvajicich radek
|
||||
add esi,4 ;preskoc ukazatel
|
||||
mov edx,esi ;edx - zacatek delta mapy
|
||||
add esi,[esi-4] ;esi - zacatek dat
|
||||
shdif6: push edi ;uloz adresu radku
|
||||
shdif2: mov ch,[edx] ;cti _skip_ hodnotu
|
||||
mov al,ch
|
||||
inc edx
|
||||
or al,03fh ;test zda jsou 2 nejvyssi bity nastaveny
|
||||
inc al
|
||||
jz shdif3 ;ano - preskakovani radku
|
||||
movzx eax,ch ;expanduj _skip_ hodnotu do eax
|
||||
lea edi,[eax*8+edi] ;vypocti novou pozici na obrazovce
|
||||
mov ch,[edx] ;cti _copy_ hodnotu
|
||||
inc edx
|
||||
shdif1: lodsb ;vem bajt z datove oblasti
|
||||
movzx eax,al ;expanduj do eax
|
||||
movzx eax,short ptr[eax*2+ebx] ;expanduj hicolor barvu
|
||||
mov ebp,eax ;rozdvoj barvy
|
||||
shl ebp,16
|
||||
or eax,ebp
|
||||
stosd ;zapis dva body
|
||||
lodsb ;opakuj pro dalsi bod jeste jednou
|
||||
movzx eax,al
|
||||
movzx eax,short ptr[eax*2+ebx]
|
||||
mov ebp,eax
|
||||
shl ebp,16
|
||||
or eax,ebp
|
||||
stosd
|
||||
dec ch ;odecti _copy_ hodnotu
|
||||
jnz shdif1 ;dokud neni 0
|
||||
jmp shdif2 ;pokracuj _skip_ hodnotou
|
||||
shdif3: and ch,3fh ;odmaskuj hodni 2 bity
|
||||
pop edi ;obnov edi
|
||||
jnz shdif4 ;pokud je ch=0 preskoc jen jeden radek;
|
||||
add edi,[esp] ;preskoc radek
|
||||
dec cl ;odecti citac radku
|
||||
jnz shdif6 ;skok pokud neni konec
|
||||
pop ebp
|
||||
jmp konec ;navrat
|
||||
shdif4: inc ch ;pocet radek je ch+1
|
||||
sub cl,ch ;odecti ch od zbyvajicich radek
|
||||
jz shdif5 ;je-li nula tak konec
|
||||
shdif7: add edi,[esp] ;preskoc radek
|
||||
dec ch ;odecti ch
|
||||
jnz shdif7 ;preskakuj dokud neni 0
|
||||
jmp shdif6 ;cti dalsi _skip_
|
||||
shdif5: pop ebp
|
||||
konec:
|
||||
}
|
||||
}
|
||||
//#pragma aux show_delta_interl_lfb parm [esi][edi][ebx] modify [eax ecx edx]
|
||||
do {
|
||||
uint32_t ecx = 320;
|
||||
do {
|
||||
uint8_t value = *esi++;
|
||||
*edi++ = ebx[value];
|
||||
ecx--;
|
||||
} while (ecx != 0);
|
||||
dl--;
|
||||
} while (dl != 0);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
void show_full_lfb12e(void *target,void *buff,void *paleta)
|
||||
{
|
||||
__asm
|
||||
|
@ -130,164 +50,147 @@ shfl1: lodsw
|
|||
jnz shfl2
|
||||
pop ebp
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
/*
|
||||
void show_delta_lfb12e(void *target, void *buff, void *paleta) {
|
||||
uint8_t *edi = (uint8_t *)target;
|
||||
uint8_t *esi = (uint8_t *)buff + 4; // skip pointer
|
||||
uint8_t *ebx = (uint8_t *)paleta;
|
||||
uint8_t cl = 180; // remaining lines
|
||||
uint8_t ch, al;
|
||||
uint16_t *edx = (uint16_t *)esi; // start of delta map
|
||||
esi += *(uint32_t *)(esi - 4); // start of data
|
||||
|
||||
while (cl > 0) {
|
||||
uint8_t *line_address = edi; // save line address
|
||||
ch = *edx++; // read _skip_ value
|
||||
al = ch;
|
||||
al |= 0x3F; // test if the two highest bits are set
|
||||
al++;
|
||||
if (al == 0) { // if yes - skip lines
|
||||
ch &= 0x3F; // mask the upper 2 bits
|
||||
edi += (ch == 0) ? 640 : 0; // skip line if ch is 0
|
||||
cl--; // decrement line counter
|
||||
continue; // continue to next iteration
|
||||
}
|
||||
|
||||
uint32_t eax = (uint32_t)ch; // expand _skip_ value to eax
|
||||
edi += eax * 4; // calculate new position on screen
|
||||
ch = *edx++; // read _copy_ value
|
||||
|
||||
for (uint8_t i = 0; i < ch; i++) {
|
||||
uint16_t ebp = *(uint16_t *)(ebx + (al * 2)); // get color from palette
|
||||
uint16_t color = *(uint16_t *)(ebx + (eax * 2)); // get color from palette
|
||||
eax = (color << 16) | ebp; // combine colors
|
||||
*(uint32_t *)edi = eax; // store the color
|
||||
edi += 4; // move to the next pixel
|
||||
}
|
||||
edi += 640; // skip line
|
||||
cl--; // decrement line counter
|
||||
}
|
||||
}
|
||||
*/
|
||||
static __inline uint32_t read_uint32(uint8_t *from) {
|
||||
uint32_t a = from[0];
|
||||
uint32_t b = from[1];
|
||||
uint32_t c = from[2];
|
||||
uint32_t d = from[2];
|
||||
return a | (b << 8) | (c << 16) | (d << 24);
|
||||
}
|
||||
|
||||
//#pragma aux show_full_lfb12e parm[edi][esi][ebx] modify [eax ecx]
|
||||
void show_delta_lfb12e(void *target,void *buff,void *paleta)
|
||||
{
|
||||
__asm
|
||||
{
|
||||
mov edi,target
|
||||
mov esi,buff
|
||||
mov ebx,paleta
|
||||
;edi - target
|
||||
;esi - buff
|
||||
;ebx - paleta
|
||||
push ebp ;uchovej ebp
|
||||
mov cl,180 ;cl pocet zbyvajicich radek
|
||||
add esi,4 ;preskoc ukazatel
|
||||
mov edx,esi ;edx - zacatek delta mapy
|
||||
add esi,[esi-4] ;esi - zacatek dat
|
||||
shdl6: push edi ;uloz adresu radku
|
||||
shdl2: mov ch,[edx] ;cti _skip_ hodnotu
|
||||
mov al,ch
|
||||
inc edx
|
||||
or al,03fh ;test zda jsou 2 nejvyssi bity nastaveny
|
||||
inc al
|
||||
jz shdl3 ;ano - preskakovani radku
|
||||
movzx eax,ch ;expanduj _skip_ hodnotu do eax
|
||||
lea edi,[eax*4+edi] ;vypocti novou pozici na obrazovce
|
||||
mov ch,[edx] ;cti _copy_ hodnotu
|
||||
inc edx
|
||||
shdl1: lodsw
|
||||
movzx ebp,al
|
||||
movzx ebp,short ptr ds:[ebp*2+ebx]
|
||||
movzx eax,ah
|
||||
movzx eax,short ptr ds:[eax*2+ebx]
|
||||
shl eax,16
|
||||
or eax,ebp
|
||||
stosd
|
||||
dec ch ;odecti _copy_ hodnotu
|
||||
jnz shdl1 ;dokud neni 0
|
||||
jmp shdl2 ;pokracuj _skip_ hodnotou
|
||||
shdl3: and ch,3fh ;odmaskuj hodni 2 bity
|
||||
pop edi ;obnov edi
|
||||
jnz shdl4 ;pokud je ch=0 preskoc jen jeden radek;
|
||||
add edi,640 ;preskoc radek
|
||||
dec cl ;odecti citac radku
|
||||
jnz shdl6 ;skok pokud neni konec
|
||||
pop ebp
|
||||
jmp konec
|
||||
shdl4: inc ch ;pocet radek je ch+1
|
||||
sub cl,ch ;odecti ch od zbyvajicich radek
|
||||
jz shdl5 ;je-li nula tak konec
|
||||
shdl7: add edi,640 ;preskoc radek
|
||||
dec ch ;odecti ch
|
||||
jnz shdl7 ;preskakuj dokud neni 0
|
||||
jmp shdl6 ;cti dalsi _skip_
|
||||
shdl5: pop ebp
|
||||
konec:
|
||||
}
|
||||
}
|
||||
//#pragma aux show_delta_lfb12e parm[edi][esi][ebx] modify [eax ecx]
|
||||
{
|
||||
// __asm
|
||||
// {
|
||||
uint16_t *edi = target;
|
||||
// mov edi,target
|
||||
uint8_t *esi = buff;
|
||||
// mov esi,buff
|
||||
uint16_t *ebx = paleta;
|
||||
// mov ebx,paleta
|
||||
// ;edi - target
|
||||
// ;esi - buff
|
||||
// ;ebx - paleta
|
||||
// push ebp ;uchovej ebp
|
||||
uint8_t cl = 180;
|
||||
// mov cl,180 ;cl pocet zbyvajicich radek
|
||||
uint32_t offset = read_uint32(esi);
|
||||
// add esi,4 ;preskoc ukazatel
|
||||
esi += 4;
|
||||
uint8_t *edx = esi;
|
||||
// mov edx,esi ;edx - zacatek delta mapy
|
||||
uint8_t *data = (esi + offset);
|
||||
// add esi,[esi-4] ;esi - zacatek dat
|
||||
uint16_t *line_beg = edi;
|
||||
//shdl6: push edi ;uloz adresu radku
|
||||
while (cl>0) {
|
||||
uint8_t ch = *edx++;
|
||||
//shdl2: mov ch,[edx] ;cti _skip_ hodnotu
|
||||
// mov al,ch
|
||||
// inc edx
|
||||
// or al,03fh ;test zda jsou 2 nejvyssi bity nastaveny
|
||||
// inc al
|
||||
if ((ch & 0xC0) == 0) {
|
||||
// jz shdl3 ;ano - preskakovani radku
|
||||
edi += ((uint32_t)ch) << 1;
|
||||
// movzx eax,ch ;expanduj _skip_ hodnotu do eax
|
||||
// lea edi,[eax*4+edi] ;vypocti novou pozici na obrazovce
|
||||
ch = *edx++;
|
||||
// mov ch,[edx] ;cti _copy_ hodnotu
|
||||
// inc edx
|
||||
|
||||
void show_full_lfb12e_dx(void *target,void *buff,void *paleta)
|
||||
{
|
||||
__asm
|
||||
{
|
||||
mov edi,target
|
||||
mov esi,buff
|
||||
mov ebx,paleta
|
||||
;edi - target
|
||||
;esi - source
|
||||
;ebx - palette
|
||||
push ebp
|
||||
mov eax,scr_linelen
|
||||
sub eax,640
|
||||
push eax
|
||||
mov dl,180
|
||||
shfl2: mov ecx,160
|
||||
shfl1: lodsw
|
||||
movzx ebp,al
|
||||
movzx ebp,short ptr ds:[ebp*2+ebx]
|
||||
movzx eax,ah
|
||||
movzx eax,short ptr ds:[eax*2+ebx]
|
||||
shl eax,16
|
||||
or eax,ebp
|
||||
mov ebp,eax
|
||||
and ebp,0x7fe07fe0
|
||||
add eax,ebp
|
||||
stosd
|
||||
dec ecx
|
||||
jnz shfl1
|
||||
add edi,[esp]
|
||||
dec dl
|
||||
jnz shfl2
|
||||
pop eax
|
||||
pop ebp
|
||||
while (ch) {
|
||||
uint8_t a = *data++;
|
||||
*edi++ = ebx[a];
|
||||
a = *data++;
|
||||
*edi++ = ebx[a];
|
||||
--ch;
|
||||
}
|
||||
|
||||
//shdl1: lodsw
|
||||
// movzx ebp,al
|
||||
// movzx ebp,short ptr ds:[ebp*2+ebx]
|
||||
// movzx eax,ah
|
||||
// movzx eax,short ptr ds:[eax*2+ebx]
|
||||
// shl eax,16
|
||||
// or eax,ebp
|
||||
// stosd
|
||||
// dec ch ;odecti _copy_ hodnotu
|
||||
// jnz shdl1 ;dokud neni 0
|
||||
// jmp shdl2 ;pokracuj _skip_ hodnotou
|
||||
} else {
|
||||
ch &= 0x3F;
|
||||
++ch;
|
||||
if (ch > cl) ch = cl;
|
||||
line_beg += 320*ch;
|
||||
cl -= ch;
|
||||
edi = line_beg;
|
||||
}
|
||||
|
||||
//shdl3: and ch,3fh ;odmaskuj hodni 2 bity
|
||||
// pop edi ;obnov edi
|
||||
// jnz shdl4 ;pokud je ch=0 preskoc jen jeden radek;
|
||||
// add edi,640 ;preskoc radek
|
||||
// dec cl ;odecti citac radku
|
||||
// jnz shdl6 ;skok pokud neni konec
|
||||
// pop ebp
|
||||
// jmp konec
|
||||
//shdl4: inc ch ;pocet radek je ch+1
|
||||
// sub cl,ch ;odecti ch od zbyvajicich radek
|
||||
// jz shdl5 ;je-li nula tak konec
|
||||
//shdl7: add edi,640 ;preskoc radek
|
||||
// dec ch ;odecti ch
|
||||
// jnz shdl7 ;preskakuj dokud neni 0
|
||||
// jmp shdl6 ;cti dalsi _skip_
|
||||
//shdl5: pop ebp
|
||||
}
|
||||
}
|
||||
//#pragma aux show_full_lfb12e parm[edi][esi][ebx] modify [eax ecx]
|
||||
void show_delta_lfb12e_dx(void *target,void *buff,void *paleta,unsigned long Pitch)
|
||||
{
|
||||
__asm
|
||||
{
|
||||
mov edi,target
|
||||
mov esi,buff
|
||||
mov ebx,paleta
|
||||
;edi - target
|
||||
;esi - buff
|
||||
;ebx - paleta
|
||||
push ebp ;uchovej ebp
|
||||
mov eax,scr_linelen
|
||||
sub eax,640
|
||||
push eax
|
||||
mov cl,180 ;cl pocet zbyvajicich radek
|
||||
add esi,4 ;preskoc ukazatel
|
||||
mov edx,esi ;edx - zacatek delta mapy
|
||||
add esi,[esi-4] ;esi - zacatek dat
|
||||
shdl6: push edi ;uloz adresu radku
|
||||
shdl2: mov ch,[edx] ;cti _skip_ hodnotu
|
||||
mov al,ch
|
||||
inc edx
|
||||
or al,03fh ;test zda jsou 2 nejvyssi bity nastaveny
|
||||
inc al
|
||||
jz shdl3 ;ano - preskakovani radku
|
||||
movzx eax,ch ;expanduj _skip_ hodnotu do eax
|
||||
lea edi,[eax*4+edi] ;vypocti novou pozici na obrazovce
|
||||
mov ch,[edx] ;cti _copy_ hodnotu
|
||||
inc edx
|
||||
shdl1: lodsw
|
||||
movzx ebp,al
|
||||
movzx ebp,short ptr ds:[ebp*2+ebx]
|
||||
movzx eax,ah
|
||||
movzx eax,short ptr ds:[eax*2+ebx]
|
||||
shl eax,16
|
||||
or eax,ebp
|
||||
mov ebp,eax
|
||||
and ebp,0x7fe07fe0
|
||||
add eax,ebp
|
||||
stosd
|
||||
dec ch ;odecti _copy_ hodnotu
|
||||
jnz shdl1 ;dokud neni 0
|
||||
jmp shdl2 ;pokracuj _skip_ hodnotou
|
||||
shdl3: and ch,3fh ;odmaskuj hodni 2 bity
|
||||
pop edi ;obnov edi
|
||||
jnz shdl4 ;pokud je ch=0 preskoc jen jeden radek;
|
||||
add edi,scr_linelen ;preskoc radek
|
||||
dec cl ;odecti citac radku
|
||||
jnz shdl6 ;skok pokud neni konec
|
||||
jmp shdl5
|
||||
shdl4: inc ch ;pocet radek je ch+1
|
||||
sub cl,ch ;odecti ch od zbyvajicich radek
|
||||
jz shdl5 ;je-li nula tak konec
|
||||
shdl7: add edi,scr_linelen ;preskoc radek
|
||||
dec ch ;odecti ch
|
||||
jnz shdl7 ;preskakuj dokud neni 0
|
||||
jmp shdl6 ;cti dalsi _skip_
|
||||
shdl5: pop eax
|
||||
pop ebp
|
||||
}
|
||||
}
|
||||
//konec:
|
||||
// }
|
||||
// }
|
||||
}
|
||||
//#pragma aux show_delta_lfb12e parm[edi][esi][ebx] modify [eax ecx]
|
||||
|
||||
char test_next_frame(void *bufpos,int size)
|
||||
{
|
||||
|
|
|
@ -16,7 +16,7 @@ char load_rm_proc(void);
|
|||
char purge_rm_proc(void);
|
||||
#pragma aux purge_rm_proc modify [edx eax] value [al]
|
||||
|
||||
void pc_speak_run(long s_freq,long sim_freq);
|
||||
void pc_speak_run(int32_t s_freq,int32_t sim_freq);
|
||||
#pragma aux pc_speak_run parm[eax][edx] modify [ecx ebx]
|
||||
|
||||
void pc_speak_stop(void);
|
||||
|
@ -28,10 +28,10 @@ void pc_speak_enable(void);
|
|||
void pc_speak_disable(void);
|
||||
#pragma aux pc_speak_enable modify [eax]
|
||||
|
||||
long pc_speak_position(void);
|
||||
int32_t pc_speak_position(void);
|
||||
#pragma aux pc_speak_position modify[eax ebx] value [eax]
|
||||
|
||||
void pc_speak_set_proc(long *c);
|
||||
void pc_speak_set_proc(int32_t *c);
|
||||
#pragma aux pc_speak_set_proc parm [edi]
|
||||
|
||||
/* Zde jsou nejake komentare */
|
||||
|
@ -101,18 +101,18 @@ void pc_speak_disable;
|
|||
|
||||
-------------------------------------------------------------------
|
||||
|
||||
long pc_speak_position(void);
|
||||
int32_t pc_speak_position(void);
|
||||
|
||||
Vstup: -
|
||||
Vystup: long offset do bufferu. Vraci prave preravanou pozici
|
||||
Komentar: sice vraci long, ale offset je v rozsahu <0-64Kb>. Vzhledem k
|
||||
Vystup: int32_t offset do bufferu. Vraci prave preravanou pozici
|
||||
Komentar: sice vraci int32_t, ale offset je v rozsahu <0-64Kb>. Vzhledem k
|
||||
casovym ztratam muze vracena pozice byt starsi uz v dobe
|
||||
predavani vysledku. Presnost zavisi na rychlosti pocitace.
|
||||
|
||||
-------------------------------------------------------------------
|
||||
|
||||
void pc_speak_set_proc;
|
||||
Vstup: Ukazatel na ukazatel na void (ackoliv je tam long *)
|
||||
Vstup: Ukazatel na ukazatel na void (ackoliv je tam int32_t *)
|
||||
Vystup:-
|
||||
Komentar: Procedura modifikuje promennou kam ukazuje parametr tak aby
|
||||
obsahovala adresu na proceduru pc_speak_position.
|
||||
|
|
|
@ -90,7 +90,7 @@ void palette_shadow(char *pal1,unsigned short pal2[][256],int tr,int tg,int tb)
|
|||
}
|
||||
|
||||
|
||||
int load_pcx(char *pcx,long fsize,int conv_type,char **buffer, ... )
|
||||
int load_pcx(char *pcx,int32_t fsize,int conv_type,char **buffer, ... )
|
||||
//dale nasleduji int hodnoty poctu prechodu a R,G,B barvy
|
||||
{
|
||||
unsigned short paleta2[256];
|
||||
|
@ -176,7 +176,7 @@ int open_pcx(char *filename,int type,char **buffer,...)
|
|||
{
|
||||
FILE *pcx;
|
||||
char *src;
|
||||
long fsize;
|
||||
int32_t fsize;
|
||||
|
||||
pcx=fopen(filename,"rb");
|
||||
if (pcx==NULL) return -1;
|
||||
|
|
|
@ -31,7 +31,7 @@ extern "C" {
|
|||
|
||||
|
||||
//returns <0 error, >0 allocated size
|
||||
int load_pcx(char *pcx,long fsize,int conv_type,char **buffer, ... );
|
||||
int load_pcx(char *pcx,int32_t fsize,int conv_type,char **buffer, ... );
|
||||
int open_pcx(char *filename,int type,char **buffer,...);
|
||||
void palette_shadow(char *pal1,unsigned short pal2[][256],int tr,int tg,int tb);
|
||||
extern void *get_palette_ptr;
|
||||
|
|
112
libs/strlists.c
112
libs/strlists.c
|
@ -1,5 +1,4 @@
|
|||
#include <skeldal_win.h>
|
||||
#include <debug.h>
|
||||
#include "strlite.c"
|
||||
|
||||
#include "devices.h"
|
||||
|
@ -10,87 +9,11 @@
|
|||
#include "strlists.h"
|
||||
|
||||
|
||||
#define SEC(t) (((t) & 0x1f)<<1)
|
||||
#define MIN(t) (((t)>>5)& 0x3f)
|
||||
#define HOUR(t) ((t)>>11)
|
||||
#define DAY(t) ((t) & 0x1f)
|
||||
#define MONTH(t) (((t)>>5)& 0x0f)
|
||||
#define YEAR(t) ((t)>>9)
|
||||
|
||||
TSTR_LIST read_directory(char *mask,int view_type,int attrs)
|
||||
TSTR_LIST read_directory(const char *mask,int view_type,int attrs)
|
||||
{
|
||||
TSTR_LIST flist;
|
||||
int index=0;
|
||||
char c[2*MAX_PATH];
|
||||
WIN32_FIND_DATA s;
|
||||
HANDLE h;
|
||||
char rc;
|
||||
|
||||
flist=create_list(256);
|
||||
if (flist==NULL) return flist;
|
||||
h=FindFirstFile(mask,&s);
|
||||
if (h!=INVALID_HANDLE_VALUE)
|
||||
{
|
||||
do
|
||||
{
|
||||
char d[MAX_PATH],*p;
|
||||
int i=0;
|
||||
|
||||
if (attrs==_A_NORMAL || s.dwFileAttributes & attrs)
|
||||
{
|
||||
p=d;d[MAX_PATH-1]=0;
|
||||
/* if (view_type!=DIR_NAMES)
|
||||
{
|
||||
while (s.cFileName[i]!='.' && s.cFileName[i]!='\0' ) *p++=s.cFileName[i++];
|
||||
if (s.cFileName[i]!='\0') j=i+1;else j=i;
|
||||
while (i<8)
|
||||
{
|
||||
*p++=32;i++;
|
||||
}
|
||||
i=3;
|
||||
*p++='.';
|
||||
while (s.name[j]!='\0')
|
||||
{
|
||||
*p++=s.name[j++];
|
||||
i--;
|
||||
}
|
||||
while (i>0)
|
||||
{
|
||||
*p++=32;
|
||||
i--;
|
||||
}
|
||||
}
|
||||
else */strncpy(d,s.cFileName,MAX_PATH-1);
|
||||
switch (view_type)
|
||||
{
|
||||
case DIR_FULL:sprintf(c,"%s %10d",
|
||||
d,
|
||||
s.nFileSizeLow
|
||||
);
|
||||
break;
|
||||
case DIR_SHORT:sprintf(c,"%s %10d",d,s.nFileSizeLow);break;
|
||||
case DIR_NAMES:
|
||||
case DIR_BREIF:sprintf(c,"%s",d);break;
|
||||
}
|
||||
if (str_replace(&flist,index++,c)==NULL)
|
||||
{
|
||||
release_list(flist);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
rc=FindNextFile(h,&s);
|
||||
}
|
||||
while (rc);
|
||||
}
|
||||
FindClose(h);
|
||||
if (flist[0]==NULL)
|
||||
{
|
||||
release_list(flist);
|
||||
return NULL;
|
||||
}
|
||||
sort_list(flist,-1);
|
||||
str_delfreelines(&flist);
|
||||
return flist;
|
||||
TSTR_LIST flist = create_list(256);
|
||||
return flist;
|
||||
}
|
||||
|
||||
void name_conv(char *c)
|
||||
|
@ -112,15 +35,15 @@ typedef struct string_list_data
|
|||
}
|
||||
STRING_LIST_DATA;
|
||||
|
||||
void string_list_init(OBJREC *o,int *params)
|
||||
void string_list_init(OBJREC *o,va_list params)
|
||||
{
|
||||
STRING_LIST_DATA *p;
|
||||
|
||||
p=(STRING_LIST_DATA *)getmem(sizeof(STRING_LIST_DATA));
|
||||
p->topline=0;
|
||||
p->list=(TSTR_LIST)*params++;
|
||||
p->selcolor=*params++;
|
||||
p->skipshow=*params++;
|
||||
p->list=va_arg(params,TSTR_LIST);
|
||||
p->selcolor=va_arg(params, int);
|
||||
p->skipshow=va_arg(params, int);
|
||||
o->userptr=p;
|
||||
p->obj_win=waktual->id;
|
||||
}
|
||||
|
@ -217,7 +140,7 @@ void string_list_draw(int x1,int y1,int x2,int y2,OBJREC *o)
|
|||
i++;
|
||||
}
|
||||
while (y+znh<y2 && i<p->maxitems);
|
||||
if (p->topline && y+2*znh<y2 && znh)
|
||||
if (p->topline && y+2*znh<y2 && znh)
|
||||
{
|
||||
int dif=y2-(y+znh);
|
||||
p->topline-=(dif*2/3)/znh+1;
|
||||
|
@ -235,7 +158,7 @@ void string_list_draw(int x1,int y1,int x2,int y2,OBJREC *o)
|
|||
if (ob!=NULL)
|
||||
{
|
||||
send_message(E_GUI,o->id+1,E_CONTROL,0,max-p->maxview,p->maxview);
|
||||
ob->events[3]=string_list_change;
|
||||
ob->on_change=string_list_change;
|
||||
}
|
||||
c_set_value(p->obj_win,o->id+1,p->topline);
|
||||
}
|
||||
|
@ -318,18 +241,17 @@ void string_list_event(EVENT_MSG *msg,OBJREC *o)
|
|||
}
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
case E_CONTROL:
|
||||
{
|
||||
int *q;
|
||||
int q = va_arg(msg->data, int);
|
||||
|
||||
q=msg->data;
|
||||
switch (*q++)
|
||||
switch (q)
|
||||
{
|
||||
case 1:p->list=(TSTR_LIST)*q;
|
||||
case 1:p->list=va_arg(msg->data, TSTR_LIST);
|
||||
redraw_object(o);
|
||||
break;
|
||||
case 0:*(void **)*q=p->list;
|
||||
case 0:*va_arg(msg->data, char ***)=p->list;
|
||||
break;
|
||||
case 2:
|
||||
i=get_to_topline(ls,p->topline,NULL);
|
||||
|
@ -347,9 +269,9 @@ void string_list_event(EVENT_MSG *msg,OBJREC *o)
|
|||
void listbox(OBJREC *o)
|
||||
{
|
||||
o->datasize=sizeof(int);
|
||||
o->runs[0]=string_list_init;
|
||||
o->runs[1]=string_list_draw;
|
||||
o->runs[2]=string_list_event;
|
||||
o->call_init=string_list_init;
|
||||
o->call_draw=string_list_draw;
|
||||
o->call_event=string_list_event;
|
||||
//o->done=string_list_done;
|
||||
}
|
||||
|
||||
|
|
213
libs/strlite.c
213
libs/strlite.c
|
@ -4,38 +4,27 @@
|
|||
#include <stdio.h>
|
||||
#include <mem.h>
|
||||
#include <malloc.h>
|
||||
#include <dos.h>
|
||||
#include "types.h"
|
||||
#include "memman.h"
|
||||
|
||||
TSTR_LIST create_list(int count)
|
||||
{
|
||||
register TSTR_LIST p;int i,j;
|
||||
TSTR_LIST p;int i,j;
|
||||
|
||||
p=(TSTR_LIST)malloc(count*sizeof(*p));
|
||||
size_t *s=(size_t *)malloc(count*sizeof(*p)+sizeof(size_t));
|
||||
if (p==NULL) return NULL;
|
||||
j=_msize(p)/sizeof(*p);
|
||||
for(i=0;i<j;i++) p[i]=NULL;
|
||||
*s = count;
|
||||
p = (TSTR_LIST)s;
|
||||
for(i=0;i<count;i++) p[i]=NULL;
|
||||
return p;
|
||||
}
|
||||
|
||||
TSTR_LIST find_ptr(TSTR_LIST source,void *_ptr,int _size)
|
||||
int find_ptr(TSTR_LIST source,void *_ptr,int _size)
|
||||
{
|
||||
__asm
|
||||
{
|
||||
mov edi, source
|
||||
mov eax, _ptr
|
||||
mov ecx, _size
|
||||
|
||||
cld
|
||||
repnz scasd
|
||||
jnz skok
|
||||
sub edi,4
|
||||
skok:
|
||||
mov eax, edi
|
||||
}
|
||||
for (int i = 0; i < _size; ++i)
|
||||
if (source[i] ==_ptr) return i;
|
||||
return _size;
|
||||
}
|
||||
//parm [edi][eax][ecx] value[edi];
|
||||
|
||||
const char *str_replace(TSTR_LIST *list,int line,const char *text)
|
||||
{
|
||||
|
@ -46,18 +35,15 @@ const char *str_replace(TSTR_LIST *list,int line,const char *text)
|
|||
count=str_count(*list);
|
||||
if (line>=count)
|
||||
{
|
||||
int plus;
|
||||
|
||||
plus=count-line;
|
||||
plus=(plus/STR_REALLOC_STEP+1)*STR_REALLOC_STEP;
|
||||
p=getmem((count+plus)*sizeof(*p));
|
||||
memcpy(p,*list,count*sizeof(*p));
|
||||
free(*list);
|
||||
j=_msize(p)/sizeof(*p);
|
||||
i=count;
|
||||
for(;i<j;i++) p[i]=NULL;
|
||||
i=count;count=j;
|
||||
*list=p;
|
||||
int new_count = count * 2;
|
||||
if (new_count <= line) new_count = line+1;
|
||||
TSTR_LIST new_list = create_list(new_count);
|
||||
for (int i = 0; i < count; ++i) {
|
||||
new_list[i] = (*list)[i];
|
||||
(*list)[i] = NULL;
|
||||
}
|
||||
release_list(*list);
|
||||
*list = new_list;
|
||||
}
|
||||
if ((*list)[line]!=NULL) free((*list)[line]);
|
||||
if (text!=NULL)
|
||||
|
@ -78,8 +64,7 @@ int str_add(TSTR_LIST *list,const char *text)
|
|||
TSTR_LIST p;
|
||||
|
||||
count=str_count(*list);
|
||||
p=find_ptr(*list,NULL,count);
|
||||
i=p-*list;
|
||||
i=find_ptr(*list,NULL,count);
|
||||
str_replace(list,i,text);
|
||||
return i;
|
||||
}
|
||||
|
@ -90,8 +75,7 @@ const char *str_insline(TSTR_LIST *list,int before,const char *text)
|
|||
TSTR_LIST p;
|
||||
|
||||
count=str_count(*list);
|
||||
p=find_ptr(*list,NULL,count);
|
||||
punkt=p-*list;
|
||||
punkt=find_ptr(*list,NULL,count);
|
||||
str_replace(list,punkt,NULL);
|
||||
for(i=punkt;i>before;i--) (*list)[i]=(*list)[i-1];
|
||||
(*list)[before]=NULL;
|
||||
|
@ -108,14 +92,10 @@ void str_delfreelines(TSTR_LIST *list)
|
|||
int count,i,j;
|
||||
TSTR_LIST p;
|
||||
|
||||
count=_msize(*list)/sizeof(*p);
|
||||
count=str_count(*list);
|
||||
j=0;
|
||||
for(i=0;i<count;i++)
|
||||
if ((*list)[i]!=NULL) (*list)[j++]=(*list)[i];
|
||||
if (j==0) j++;
|
||||
p=(TSTR_LIST)realloc(*list,j*sizeof(*p));
|
||||
if (p!=NULL) *list=p;
|
||||
count=_msize(*list)/sizeof(*p);
|
||||
for(i=j;i<count;i++) (*list)[i]=NULL;
|
||||
}
|
||||
|
||||
|
@ -124,8 +104,7 @@ int str_count(TSTR_LIST p)
|
|||
int count;
|
||||
|
||||
if (p==NULL) return 0;
|
||||
count=_msize(p)/sizeof(*p);
|
||||
return count;
|
||||
return *((size_t *)p-1);
|
||||
}
|
||||
|
||||
void release_list(TSTR_LIST list)
|
||||
|
@ -136,146 +115,26 @@ void release_list(TSTR_LIST list)
|
|||
j=str_count(list);
|
||||
for(i=0;i<j;i++)
|
||||
str_remove(&list, i);
|
||||
free(list);
|
||||
size_t *s = (size_t *)list-1;
|
||||
free(s);
|
||||
}
|
||||
|
||||
typedef struct tuzel
|
||||
{
|
||||
char *data;
|
||||
struct tuzel *levy,*pravy,*spatky;
|
||||
}
|
||||
TUZEL;
|
||||
|
||||
|
||||
int sort_add_to_tree(TUZEL *uzel,const char *text, int dir)
|
||||
{
|
||||
TUZEL *q;
|
||||
if (uzel->data==NULL)
|
||||
{
|
||||
uzel->data=text;
|
||||
return 0;
|
||||
}
|
||||
q=(TUZEL *)getmem(sizeof(TUZEL));
|
||||
if (q==NULL) return -1;
|
||||
q->data=text;
|
||||
q->levy=NULL;q->pravy=NULL;
|
||||
while (uzel!=NULL)
|
||||
if (strcmp(text,uzel->data)==dir)
|
||||
{
|
||||
if (uzel->levy==NULL)
|
||||
{
|
||||
uzel->levy=q;
|
||||
q->spatky=uzel;
|
||||
uzel=NULL;
|
||||
}
|
||||
else
|
||||
uzel=uzel->levy;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (uzel->pravy==NULL)
|
||||
{
|
||||
uzel->pravy=q;
|
||||
q->spatky=uzel;
|
||||
uzel=NULL;
|
||||
}
|
||||
else
|
||||
uzel=uzel->pravy;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
static int cmp_list_forward(const void *pa, const void *pb) {
|
||||
return strcmp(*(char *const *)pa, *(char *const *)pb);
|
||||
}
|
||||
static int cmp_list_backward(const void *pa, const void *pb) {
|
||||
return -strcmp(*(char *const *)pa, *(char * const *)pb);
|
||||
}
|
||||
|
||||
void sort_read_list(TUZEL *uzel,TSTR_LIST list)
|
||||
{
|
||||
int counter=0;
|
||||
TUZEL *ptr,*last;
|
||||
int c;
|
||||
|
||||
if (uzel->data==NULL) return;
|
||||
last=NULL;
|
||||
while (uzel!=NULL)
|
||||
{
|
||||
if (last==NULL)
|
||||
{
|
||||
ptr=uzel;
|
||||
uzel=uzel->levy;
|
||||
last=NULL;
|
||||
c=1;
|
||||
}
|
||||
else if (last==uzel->levy || (int)last==1)
|
||||
{
|
||||
ptr=uzel;
|
||||
list[counter++]=uzel->data;
|
||||
uzel=uzel->pravy;
|
||||
last=NULL;
|
||||
c=2;
|
||||
}
|
||||
else if (last==uzel->pravy || (int)last==2)
|
||||
{
|
||||
last=uzel;
|
||||
uzel=uzel->spatky;
|
||||
continue;
|
||||
}
|
||||
if (uzel==NULL)
|
||||
{
|
||||
last=(TUZEL *)c;
|
||||
uzel=ptr;
|
||||
}
|
||||
}
|
||||
}
|
||||
void sort_release_tree(TUZEL *uzel)
|
||||
{
|
||||
TUZEL *ptr,*last;
|
||||
int c;
|
||||
|
||||
if (uzel->data==NULL) return;
|
||||
last=NULL;
|
||||
while (uzel!=NULL)
|
||||
{
|
||||
if (last==NULL)
|
||||
{
|
||||
ptr=uzel;
|
||||
uzel=uzel->levy;
|
||||
last=NULL;
|
||||
c=1;
|
||||
}
|
||||
else if (last==uzel->levy || (int)last==1)
|
||||
{
|
||||
ptr=uzel;
|
||||
uzel=uzel->pravy;
|
||||
last=NULL;
|
||||
c=2;
|
||||
}
|
||||
else if (last==uzel->pravy || (int)last==2)
|
||||
{
|
||||
last=uzel;
|
||||
uzel=uzel->spatky;
|
||||
if (last->spatky!=NULL) free(last);
|
||||
continue;
|
||||
}
|
||||
if (uzel==NULL)
|
||||
{
|
||||
last=(TUZEL *)c;
|
||||
uzel=ptr;
|
||||
}
|
||||
}
|
||||
}
|
||||
TSTR_LIST sort_list(TSTR_LIST list,int direction)
|
||||
{
|
||||
TUZEL uz;
|
||||
int i,j;
|
||||
|
||||
uz.data=NULL;uz.levy=NULL;uz.pravy=NULL;
|
||||
uz.spatky=NULL;
|
||||
j=str_count(list);
|
||||
for(i=0;i<j;i++)
|
||||
if (list[i]!=NULL) if (sort_add_to_tree(&uz,list[i],direction))
|
||||
{
|
||||
sort_release_tree(&uz);
|
||||
return NULL;
|
||||
}
|
||||
sort_read_list(&uz,list);
|
||||
sort_release_tree(&uz);
|
||||
if (direction > 0) {
|
||||
qsort(list, str_count(list), sizeof(char *), cmp_list_forward);
|
||||
} else if (direction < 0) {
|
||||
qsort(list, str_count(list), sizeof(char *), cmp_list_backward);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
|
@ -401,4 +260,4 @@ void strlist_cat(TSTR_LIST *org, TSTR_LIST add)
|
|||
int cnt=str_count(add);
|
||||
int i;
|
||||
for (i=0;i<cnt;i++) str_add(org,add[i]);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@ int str_count(TSTR_LIST p);
|
|||
void release_list(TSTR_LIST list);
|
||||
TSTR_LIST sort_list(TSTR_LIST list,int direction);
|
||||
TSTR_LIST read_directory(const char *mask,int view_type,int attrs);
|
||||
void name_conv(const char *c);
|
||||
//void name_conv(const char *c);
|
||||
void strlist_cat(TSTR_LIST *org, TSTR_LIST add);
|
||||
|
||||
void pl_add_data(PTRMAP **p,void *data,int datasize);
|
||||
|
@ -32,4 +32,4 @@ void pl_delete_all(PTRMAP **p);
|
|||
|
||||
int load_string_list(TSTR_LIST *list,const char *filename);
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#define SWAP_FREE_LIST 8192
|
||||
|
||||
typedef struct sw_free_block
|
||||
{
|
||||
long size,seek;
|
||||
int32_t size,seek;
|
||||
}SW_FREE_BLOCK;
|
||||
|
||||
SW_FREE_BLOCK swp_list[SWAP_FREE_LIST];
|
||||
|
@ -21,7 +22,7 @@ void swap_init(void)
|
|||
swp_ptr=1;
|
||||
}
|
||||
|
||||
int swap_find_block(long size)
|
||||
int swap_find_block(int32_t size)
|
||||
{
|
||||
int i;
|
||||
SW_FREE_BLOCK *p;
|
||||
|
@ -33,10 +34,10 @@ int swap_find_block(long size)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int swap_add_block(long size)
|
||||
int swap_add_block(int32_t size)
|
||||
{
|
||||
int i;
|
||||
long sp;
|
||||
int32_t sp;
|
||||
SW_FREE_BLOCK *p;
|
||||
|
||||
size+=255;
|
||||
|
@ -60,7 +61,7 @@ int swap_add_block(long size)
|
|||
return sp;
|
||||
}
|
||||
|
||||
void swap_find_seek(long seek1,long seek2,int *pos1,int *pos2)
|
||||
void swap_find_seek(int32_t seek1,int32_t seek2,int *pos1,int *pos2)
|
||||
{
|
||||
int i;
|
||||
SW_FREE_BLOCK *p;
|
||||
|
@ -82,7 +83,7 @@ void swap_find_seek(long seek1,long seek2,int *pos1,int *pos2)
|
|||
}
|
||||
|
||||
|
||||
void alloc_swp_block(long seek,long size)
|
||||
void alloc_swp_block(int32_t seek,int32_t size)
|
||||
{
|
||||
|
||||
if (swp_fnot_used<0 && swp_unuseds) swap_find_block(0x7fffffff);
|
||||
|
@ -106,7 +107,7 @@ void alloc_swp_block(long seek,long size)
|
|||
}
|
||||
}
|
||||
|
||||
void swap_free_block(long seek,long size)
|
||||
void swap_free_block(int32_t seek,int32_t size)
|
||||
{
|
||||
int i1,i2;
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#define byte char
|
||||
#define integer signed short
|
||||
#define word unsigned short
|
||||
#define longint long
|
||||
#define longint int32_t
|
||||
|
|
|
@ -48,7 +48,7 @@ word *mapvesaadr1(word *a)
|
|||
{
|
||||
word bank;
|
||||
|
||||
bank=(long)a>>16;
|
||||
bank=(int32_t)a>>16;
|
||||
if (bank!=lastbank)
|
||||
{
|
||||
lastbank=bank;
|
||||
|
@ -61,7 +61,7 @@ word *mapvesaadr1(word *a)
|
|||
int386 (0x10,®s,®s); // window A
|
||||
}
|
||||
}
|
||||
return (word *)(((long)a & 0xffff)+0xa0000);
|
||||
return (word *)(((int32_t)a & 0xffff)+0xa0000);
|
||||
}
|
||||
|
||||
void switchvesabank(word bank)
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
int find_chunk(FILE *riff,char *name)
|
||||
{
|
||||
char chunk_name[4];
|
||||
long next;
|
||||
int32_t next;
|
||||
|
||||
fseek(riff,12,SEEK_SET);
|
||||
do
|
||||
|
@ -23,7 +23,7 @@ int find_chunk(FILE *riff,char *name)
|
|||
|
||||
int get_chunk_size(FILE *riff)
|
||||
{
|
||||
long size;
|
||||
int32_t size;
|
||||
|
||||
fread(&size,1,4,riff);
|
||||
fseek(riff,-4,SEEK_CUR);
|
||||
|
@ -32,7 +32,7 @@ int get_chunk_size(FILE *riff)
|
|||
|
||||
int read_chunk(FILE *riff,void *mem)
|
||||
{
|
||||
long size,res;
|
||||
int32_t size,res;
|
||||
|
||||
fread(&size,1,4,riff);
|
||||
res=fread(mem,1,size,riff);
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
typedef struct t_wave
|
||||
{
|
||||
unsigned short wav_mode,chans;
|
||||
long freq,bps;
|
||||
int32_t freq,bps;
|
||||
}T_WAVE;
|
||||
|
||||
int find_chunk(FILE *riff,char *name); //-1 neuspech, jinak pozice
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include "WAV_MEM.H"
|
||||
#include "wav_mem.h"
|
||||
|
||||
char *find_chunk(char *wav,char *name)
|
||||
{
|
||||
long next;
|
||||
int32_t next;
|
||||
|
||||
wav+=12;
|
||||
do
|
||||
|
@ -20,7 +20,7 @@ char *find_chunk(char *wav,char *name)
|
|||
|
||||
int get_chunk_size(char *wav)
|
||||
{
|
||||
long size;
|
||||
int32_t size;
|
||||
|
||||
memcpy(&size,wav,4);
|
||||
return(size);
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
typedef struct t_wave
|
||||
{
|
||||
unsigned short wav_mode,chans;
|
||||
long freq,bps;
|
||||
int32_t freq,bps;
|
||||
}T_WAVE;
|
||||
|
||||
char *find_chunk(char *wav,char *name);
|
||||
|
|
66
libs/zvuk.c
66
libs/zvuk.c
|
@ -56,37 +56,37 @@ char detect_enables[8];
|
|||
typedef struct tchannel
|
||||
{
|
||||
char *play_pos, *start_loop, *end_loop;
|
||||
long speed_maj;
|
||||
int32_t speed_maj;
|
||||
unsigned short speed_min, minor_pos, sample_type, vol_left, vol_right;
|
||||
}TCHANNEL;
|
||||
|
||||
TCHANNEL chaninfo[32];
|
||||
char *mixbuffer=NULL;
|
||||
char backsndbuff[BACK_BUFF_SIZE];
|
||||
volatile long backsnd=0;
|
||||
volatile long backstep=0x10000;
|
||||
volatile int32_t backsnd=0;
|
||||
volatile int32_t backstep=0x10000;
|
||||
volatile int backfine=0;
|
||||
long ticker_save;
|
||||
/*long jumptable[3];
|
||||
long getdma;
|
||||
long ido;*/
|
||||
int32_t ticker_save;
|
||||
/*int32_t jumptable[3];
|
||||
int32_t getdma;
|
||||
int32_t ido;*/
|
||||
unsigned short predstih=0x960;
|
||||
long lastdma;
|
||||
long lastmix;
|
||||
long mixpos;
|
||||
long surpos;
|
||||
long mixsize;
|
||||
long dmaposadr;
|
||||
long dmasizadr;
|
||||
long dmapageadr;
|
||||
long dmanum;
|
||||
int32_t lastdma;
|
||||
int32_t lastmix;
|
||||
int32_t mixpos;
|
||||
int32_t surpos;
|
||||
int32_t mixsize;
|
||||
int32_t dmaposadr;
|
||||
int32_t dmasizadr;
|
||||
int32_t dmapageadr;
|
||||
int32_t dmanum;
|
||||
int dmamask;
|
||||
int dmamode;
|
||||
int dmamodenum=0x58;//rezim DMA (default pro SB - POZOR zmenit pro GUS na 0x48
|
||||
int device;
|
||||
long samplerate=22050;
|
||||
long mixfreq=50;
|
||||
long idt_map[2];
|
||||
int32_t samplerate=22050;
|
||||
int32_t mixfreq=50;
|
||||
int32_t idt_map[2];
|
||||
int call_back_data;
|
||||
int call_back_sel;
|
||||
static char *countdown=(char *)0x440;
|
||||
|
@ -99,7 +99,7 @@ short btable[256];
|
|||
int bfreq,bblocks,bblock_size,bvolume=255;
|
||||
int bxbass=0;
|
||||
static int gfxvol=255;
|
||||
long blength;
|
||||
int32_t blength;
|
||||
static char depack[32768];
|
||||
void (__far __interrupt *oldvect)();
|
||||
static char swap_chans=0;
|
||||
|
@ -194,13 +194,13 @@ outp(dmamode,(dmanum & 3)+dmamodenum);
|
|||
if (dmanum>3)
|
||||
{
|
||||
block>>=1;
|
||||
poz=(long)adr>>1;
|
||||
page=((long)adr>>16) & ~1;
|
||||
poz=(int32_t)adr>>1;
|
||||
page=((int32_t)adr>>16) & ~1;
|
||||
}
|
||||
else
|
||||
{
|
||||
poz=(long)adr;
|
||||
page=(long)adr>>16;
|
||||
poz=(int32_t)adr;
|
||||
page=(int32_t)adr>>16;
|
||||
}
|
||||
block--;
|
||||
outp(dmaposadr,poz & 0xff);
|
||||
|
@ -442,7 +442,7 @@ int open_backsound(char *filename)
|
|||
|
||||
int load_music_block()
|
||||
{
|
||||
long remain;
|
||||
int32_t remain;
|
||||
if (bsnd!=NULL && !clear_buffer)
|
||||
{
|
||||
fread(&remain,1,sizeof(remain),bsnd);
|
||||
|
@ -604,12 +604,12 @@ switch (mode)
|
|||
}
|
||||
//backsndbuff[0]=128;backstep=0;backsnd=0;
|
||||
lastdma=0;
|
||||
mixpos=(long)(mixbuffer+predstih);
|
||||
mixpos=(int32_t)(mixbuffer+predstih);
|
||||
memset(chaninfo,0,sizeof(TCHANNEL)*32);
|
||||
memset(mixbuffer,0x80,65536);
|
||||
}
|
||||
|
||||
void play_sample(int channel,void *sample,long size,long lstart,long sfreq,int type)
|
||||
void play_sample(int channel,void *sample,int32_t size,int32_t lstart,int32_t sfreq,int type)
|
||||
{
|
||||
chaninfo[channel].play_pos=sample;
|
||||
chaninfo[channel].start_loop=(char *)sample+lstart;
|
||||
|
@ -619,7 +619,7 @@ void play_sample(int channel,void *sample,long size,long lstart,long sfreq,int t
|
|||
chaninfo[channel].sample_type=type;
|
||||
}
|
||||
|
||||
void chan_break_ext(int channel,void *org_sample,long size_sample)
|
||||
void chan_break_ext(int channel,void *org_sample,int32_t size_sample)
|
||||
{
|
||||
chaninfo[channel].start_loop=chaninfo[channel].end_loop=(char *)org_sample+size_sample;
|
||||
}
|
||||
|
@ -783,12 +783,12 @@ void set_mixing_device(int mix_dev,int mix_freq,...)
|
|||
if (p[0]==0x42) set_mixing_device(DEV_PCSPEAKER,mix_freq);
|
||||
else
|
||||
{
|
||||
rm_proc_set((long)mixbuffer>>4,dpmiselector,p[0],DAC_MODE);
|
||||
rm_proc_set((int32_t)mixbuffer>>4,dpmiselector,p[0],DAC_MODE);
|
||||
if (samplerate>22050) samplerate=22050;
|
||||
}
|
||||
break;
|
||||
case DEV_PCSPEAKER:
|
||||
rm_proc_set((long)mixbuffer>>4,dpmiselector,0x42,SPK_MODE);
|
||||
rm_proc_set((int32_t)mixbuffer>>4,dpmiselector,0x42,SPK_MODE);
|
||||
if (samplerate>19000) samplerate=19000;
|
||||
break;
|
||||
case DEV_ULTRA:
|
||||
|
@ -804,11 +804,11 @@ void set_mixing_device(int mix_dev,int mix_freq,...)
|
|||
}
|
||||
}
|
||||
|
||||
long pc_speak_position(void);
|
||||
int32_t pc_speak_position(void);
|
||||
|
||||
void start_mixing()
|
||||
{
|
||||
ticker_save=*(long *)0x46c;
|
||||
ticker_save=*(int32_t *)0x46c;
|
||||
test_counter=0;
|
||||
switch (device)
|
||||
{
|
||||
|
@ -867,7 +867,7 @@ void stop_mixing()
|
|||
{
|
||||
mixer_zavora=1;
|
||||
_disable();
|
||||
*(long *)0x46c=ticker_save+(long)(((float)test_counter/mixfreq)*(18.2059));
|
||||
*(int32_t *)0x46c=ticker_save+(int32_t)(((float)test_counter/mixfreq)*(18.2059));
|
||||
outp(0x43,0x34);
|
||||
outp(0x40,0);
|
||||
outp(0x40,0);
|
||||
|
|
|
@ -25,7 +25,7 @@ int sound_detect(int *dev,int *port,int *dma, int *irq);
|
|||
void set_mixing_device(int mix_dev,int mix_freq,...);
|
||||
char start_mixing();
|
||||
void stop_mixing();
|
||||
void play_sample(int channel,void *sample,long size,long lstart,long sfreq,int type);
|
||||
void play_sample(int channel,void *sample,int32_t size,int32_t lstart,int32_t sfreq,int type);
|
||||
void set_channel_volume(int channel,int left,int right);
|
||||
void init_winamp_plugins(const char *path);
|
||||
|
||||
|
@ -43,14 +43,14 @@ char get_channel_state(int channel);
|
|||
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,long size_sample); //zrusi loop s moznosti dohrat zvuk
|
||||
void chan_break_ext(int channel,void *org_sample,int32_t size_sample); //zrusi loop s moznosti dohrat zvuk
|
||||
|
||||
char set_snd_effect(int funct,int data);
|
||||
char check_snd_effect(int funct);
|
||||
int get_snd_effect(int funct);
|
||||
|
||||
void *PrepareVideoSound(int mixfreq, int buffsize);
|
||||
char LoadNextVideoFrame(void *buffer, char *data, int size, short *xlat, short *accnums, long *writepos);
|
||||
char LoadNextVideoFrame(void *buffer, char *data, int size, short *xlat, short *accnums, int32_t *writepos);
|
||||
void DoneVideoSound(void *buffer);
|
||||
|
||||
|
||||
|
|
|
@ -67,17 +67,17 @@ class SoundChannelInfo
|
|||
CRITICAL_SECTION sect;
|
||||
char *play_pos, *start_loop, *end_loop;
|
||||
IDirectSoundBuffer8 *buffer;
|
||||
unsigned long chantype;
|
||||
unsigned long idsPlayPos;
|
||||
unsigned long idsWritePos;
|
||||
unsigned long idsBuffSize;
|
||||
long volume; //volume for DS
|
||||
long pan; //pan for DS
|
||||
uint32_t chantype;
|
||||
uint32_t idsPlayPos;
|
||||
uint32_t idsWritePos;
|
||||
uint32_t idsBuffSize;
|
||||
int32_t volume; //volume for DS
|
||||
int32_t pan; //pan for DS
|
||||
int volleft; //left volume for skeldal
|
||||
int volright; //right volume for skeldal
|
||||
unsigned long preload;
|
||||
unsigned long stopTime; //time, when buffer reached end. For calculating idle time
|
||||
unsigned long startTime; //time, when buffer started. For calculating idle time, use 0 to sticky buffer
|
||||
uint32_t preload;
|
||||
uint32_t stopTime; //time, when buffer reached end. For calculating idle time
|
||||
uint32_t startTime; //time, when buffer started. For calculating idle time, use 0 to sticky buffer
|
||||
SoundChannelInfo()
|
||||
{
|
||||
buffer=NULL;
|
||||
|
@ -87,7 +87,7 @@ class SoundChannelInfo
|
|||
volume=DSBVOLUME_MAX;
|
||||
}
|
||||
~SoundChannelInfo() {if (buffer) buffer->Release();DeleteCriticalSection(§);}
|
||||
unsigned long CalculateLockSize();
|
||||
uint32_t CalculateLockSize();
|
||||
void ChannelMaintaince();
|
||||
bool IsPlaying() {return play_pos!=NULL;}
|
||||
// bool IsFree(char type) {return play_pos==NULL || (type==chantype && play_pos==end_loop);}
|
||||
|
@ -96,14 +96,14 @@ class SoundChannelInfo
|
|||
void Lock() {EnterCriticalSection(§);}
|
||||
void Unlock() {LeaveCriticalSection(§);}
|
||||
bool TryLock() {return TryEnterCriticalSection(§)!=FALSE;}
|
||||
void SetVolume(long vol)
|
||||
void SetVolume(int32_t vol)
|
||||
{
|
||||
Lock();
|
||||
if (volume!=vol) if (buffer && play_pos ) hres=buffer->SetVolume(vol);
|
||||
volume=vol;
|
||||
Unlock();
|
||||
}
|
||||
void SetPan(long p)
|
||||
void SetPan(int32_t p)
|
||||
{
|
||||
Lock();
|
||||
if (pan!=p) if (buffer && play_pos ) hres=buffer->SetPan(p);
|
||||
|
@ -194,18 +194,18 @@ static void DSStop()
|
|||
ds8=NULL;
|
||||
}
|
||||
|
||||
unsigned long SoundChannelInfo::CalculateLockSize()
|
||||
uint32_t SoundChannelInfo::CalculateLockSize()
|
||||
{
|
||||
if (buffer==NULL) return 0;
|
||||
unsigned long playpos;
|
||||
uint32_t playpos;
|
||||
buffer->GetCurrentPosition(NULL,&playpos);
|
||||
long diff=(signed)playpos-(signed)idsPlayPos;
|
||||
int32_t diff=(signed)playpos-(signed)idsPlayPos;
|
||||
if (diff<0) diff+=idsBuffSize;
|
||||
unsigned long wendpos=playpos+preload;
|
||||
uint32_t wendpos=playpos+preload;
|
||||
if (wendpos>=idsBuffSize) wendpos-=idsBuffSize;
|
||||
if (wendpos<idsWritePos && wendpos>playpos) return 0;
|
||||
if (wendpos<idsWritePos) wendpos+=idsBuffSize;
|
||||
unsigned long sz=(wendpos-idsWritePos+3) & ~3;
|
||||
uint32_t sz=(wendpos-idsWritePos+3) & ~3;
|
||||
if (sz>idsBuffSize/2) sz=idsBuffSize/2;
|
||||
idsPlayPos=playpos;
|
||||
return sz;
|
||||
|
@ -217,17 +217,17 @@ void SoundChannelInfo::ChannelMaintaince()
|
|||
if (play_pos!=NULL)
|
||||
{
|
||||
if (play_pos!=end_loop) stopTime=GetTickCount();
|
||||
unsigned long lockSize=CalculateLockSize();
|
||||
uint32_t lockSize=CalculateLockSize();
|
||||
if (lockSize)
|
||||
{
|
||||
// printf("%8d\r",lockSize);
|
||||
void *audioptrs[2];
|
||||
unsigned long sizes[2];
|
||||
uint32_t sizes[2];
|
||||
hres=buffer->Lock(idsWritePos,lockSize,audioptrs,sizes,audioptrs+1,sizes+1,0);
|
||||
for (int i=0;i<2 && audioptrs[i];i++)
|
||||
{
|
||||
char *wrt=(char *)audioptrs[i];
|
||||
for (unsigned long j=0;j<sizes[i];j++) if (play_pos!=end_loop)
|
||||
for (uint32_t j=0;j<sizes[i];j++) if (play_pos!=end_loop)
|
||||
{
|
||||
*wrt++=*play_pos++;
|
||||
if (play_pos==end_loop) play_pos=start_loop;
|
||||
|
@ -271,7 +271,7 @@ void SoundChannelInfo::Reset()
|
|||
void SoundChannelInfo::InitChannel(char type, char *ppos, char *bloop,char *eloop, int freq)
|
||||
{
|
||||
Lock();
|
||||
unsigned long newchantype=type+freq*4;
|
||||
uint32_t newchantype=type+freq*4;
|
||||
if (chantype!=newchantype || buffer==NULL)
|
||||
{
|
||||
Reset();
|
||||
|
@ -394,7 +394,7 @@ void stop_mixing()
|
|||
DSStop();
|
||||
}
|
||||
|
||||
void play_sample(int channel,void *sample,long size,long lstart,long sfreq,int type)
|
||||
void play_sample(int channel,void *sample,int32_t size,int32_t lstart,int32_t sfreq,int type)
|
||||
{
|
||||
char *start=(char *)sample;
|
||||
channels[channel].InitChannel(type,start,start+lstart,start+size,sfreq);
|
||||
|
@ -436,7 +436,7 @@ void chan_break_loop(int channel)
|
|||
channels[channel].BreakLoop();
|
||||
}
|
||||
|
||||
void chan_break_ext(int channel,void *org_sample,long size_sample) //zrusi loop s moznosti dohrat zvu
|
||||
void chan_break_ext(int channel,void *org_sample,int32_t size_sample) //zrusi loop s moznosti dohrat zvu
|
||||
{
|
||||
char *end_sample=(char *)org_sample+size_sample;
|
||||
channels[channel].BreakLoopEx(end_sample);
|
||||
|
@ -502,11 +502,11 @@ static DWORD Mus_silentPlay=0;
|
|||
struct MusFile
|
||||
{
|
||||
short channels;
|
||||
long freq;
|
||||
long ssize;
|
||||
long blocks;
|
||||
long reserved1;
|
||||
long reserved2;
|
||||
int32_t freq;
|
||||
int32_t ssize;
|
||||
int32_t blocks;
|
||||
int32_t reserved1;
|
||||
int32_t reserved2;
|
||||
short ampltable[256];
|
||||
};
|
||||
|
||||
|
@ -607,7 +607,7 @@ static char music_decompres_block()
|
|||
}
|
||||
if (fadetime)
|
||||
{
|
||||
long ftime=FADELENGTH-(GetTickCount()-fadetime);
|
||||
int32_t ftime=FADELENGTH-(GetTickCount()-fadetime);
|
||||
if (ftime<0) ftime=0;
|
||||
float mul=(float)ftime*(float)ftime/(float)(FADELENGTH*FADELENGTH);
|
||||
val=(short)(val*mul);
|
||||
|
@ -787,7 +787,7 @@ void *PrepareVideoSound(int mixfreq, int buffsize)
|
|||
return (void *)ds_music;
|
||||
}
|
||||
|
||||
char LoadNextVideoFrame(void *buffer, char *data, int size, short *xlat,short *accnums, long *writepos)
|
||||
char LoadNextVideoFrame(void *buffer, char *data, int size, short *xlat,short *accnums, int32_t *writepos)
|
||||
{
|
||||
IDirectSoundBuffer8 *ds_music=(IDirectSoundBuffer8 *)buffer;
|
||||
DSBCAPS caps;
|
||||
|
@ -795,7 +795,7 @@ char LoadNextVideoFrame(void *buffer, char *data, int size, short *xlat,short *a
|
|||
ds_music->GetCaps(&caps);
|
||||
DWORD play;
|
||||
ds_music->GetCurrentPosition(&play,NULL);
|
||||
long remain=play-*writepos;
|
||||
int32_t remain=play-*writepos;
|
||||
if (remain<0) remain+=caps.dwBufferBytes;
|
||||
if (remain<size*2) return 0;
|
||||
char curchan=0;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue