mirror of
https://github.com/ondra-novak/gates_of_skeldal.git
synced 2025-07-14 02:11:58 -04:00
no loading between levels, many improvements in code
This commit is contained in:
parent
77f1700902
commit
a8a87d514c
55 changed files with 628 additions and 763 deletions
|
@ -198,7 +198,7 @@ void button2(OBJREC *o)
|
|||
|
||||
void draw_status_line(char *c)
|
||||
{
|
||||
static word *font;
|
||||
static const word *font;
|
||||
static FC_TABLE color;
|
||||
static word backgr;
|
||||
static word ysmax=0,y;
|
||||
|
|
|
@ -12,14 +12,15 @@ word *lbuffer;
|
|||
word *screen;
|
||||
word curcolor,charcolors[7] = {0x0000,0x03E0,0x0380,0x0300,0x0280,0x0000,0x0000};
|
||||
longint linelen;
|
||||
word *curfont,*writepos,writeposx;
|
||||
const word *curfont;
|
||||
word *writepos,writeposx;
|
||||
byte fontdsize=0;
|
||||
byte *palmem,*xlatmem;
|
||||
void (*showview)(word,word,word,word);
|
||||
char line480=0;
|
||||
int32_t screen_buffer_size=512000;
|
||||
|
||||
void *mscursor,*mssavebuffer=NULL;
|
||||
const void *mscursor,*mssavebuffer=NULL;
|
||||
integer mscuroldx=0,mscuroldy=0;
|
||||
integer msshowx=0,msshowy=0;
|
||||
int32_t pictlen; // Tato promenna je pouze pouzita v BGRAPH1.ASM
|
||||
|
@ -194,7 +195,7 @@ void hide_ms_cursor()
|
|||
put_picture(mscuroldx,mscuroldy,mssavebuffer);
|
||||
}
|
||||
|
||||
void *register_ms_cursor(void *cursor)
|
||||
void *register_ms_cursor(const void *cursor)
|
||||
{
|
||||
integer xs,ys;
|
||||
|
||||
|
|
|
@ -15,7 +15,8 @@ void RedirectScreenBufferSecond(void);
|
|||
|
||||
|
||||
extern word curcolor,charcolors[7];
|
||||
extern word *curfont,*writepos,writeposx;
|
||||
extern const word *curfont;
|
||||
extern word *writepos,writeposx;
|
||||
extern byte fontdsize;
|
||||
extern void (*showview)(word,word,word,word);
|
||||
extern char __skip_change_line_test;
|
||||
|
@ -42,13 +43,13 @@ void ver_line_xor(int x1,int y1,int y2);
|
|||
//#pragma aux ver_line_xor parm [eSi] [eAX] [eCX] modify [eDX];
|
||||
void line_32(int x,int y,int xs,int ys);
|
||||
//#pragma aux line_32 parm [esi] [eax] [ecx] [ebx] modify [edx edi]
|
||||
void char_32(word *posit,word *font,char znak);
|
||||
void char_32(word *posit,const word *font,char znak);
|
||||
//#pragma aux char_32 parm [edi] [esi] [eax] modify [eax ebx ecx edx]
|
||||
void char2_32(word *posit,word *font,char znak);
|
||||
void char2_32(word *posit,const word *font,char znak);
|
||||
//#pragma aux char2_32 parm [edi] [esi] [eax] modify [eax ebx ecx edx]
|
||||
word charsize(word *font,char znak);
|
||||
word charsize(const word *font,char znak);
|
||||
//#pragma aux charsize parm [esi] [eax]
|
||||
void put_picture(word x,word y,void *p);
|
||||
void put_picture(word x,word y,const void *p);
|
||||
//#pragma aux put_picture parm [esi] [eax] [edi] modify [ebx ecx edx]
|
||||
void get_picture(word x,word y,word xs,word ys,void *p);
|
||||
//#pragma aux get_picture parm [esi] [eax] [ebx] [ecx] [edi] modify [edx]
|
||||
|
@ -108,22 +109,22 @@ void closemode(void);
|
|||
void line32(word x1,word y1, word x2, word y2);
|
||||
void position(word x,word y);
|
||||
void show_ms_cursor(integer x,integer y);
|
||||
void *register_ms_cursor(void *cursor);
|
||||
void *register_ms_cursor(const void *cursor);
|
||||
void move_ms_cursor(integer newx,integer newy,char nodraw);
|
||||
void hide_ms_cursor(void);
|
||||
void redraw_ms_cursor_on_screen(void);
|
||||
int text_height(char *text);
|
||||
int text_width(char *text);
|
||||
void set_aligned_position(int x,int y,char alignx, char aligny,char *text);
|
||||
int text_height( const char *text);
|
||||
int text_width( const char *text);
|
||||
void set_aligned_position(int x,int y,char alignx, char aligny,const char *text);
|
||||
void rectangle(int x1,int y1,int x2,int y2,int color);
|
||||
word *mapvesaadr1(word *a);
|
||||
void rel_position_x(word x);
|
||||
|
||||
void put_8bit_clipped(void *src,void *trg,int startline,int velx,int vely);
|
||||
void put_8bit_clipped(const void *src,void *trg,int startline,int velx,int vely);
|
||||
//#pragma aux put_8bit_clipped parm [ESI][EDI][EAX][EBX][EDX] modify [ECX];
|
||||
void put_textured_bar_(void *src,void *trg,int xsiz,int ysiz,int xofs,int yofs);
|
||||
void put_textured_bar_(const void *src,void *trg,int xsiz,int ysiz,int xofs,int yofs);
|
||||
//#pragma aux put_textured_bar_ parm [EBX][EDI][EDX][ECX][ESI][EAX];
|
||||
void put_textured_bar(void *src,int x,int y,int xs,int ys,int xofs,int yofs);
|
||||
void put_textured_bar(const void *src,int x,int y,int xs,int ys,int xofs,int yofs);
|
||||
void trans_bar(int x,int y,int xs,int ys,int barva);
|
||||
//#pragma aux trans_bar parm [EDI][ESI][EDX][ECX][EBX] modify [EAX];
|
||||
void trans_bar25(int x,int y,int xs,int ys);
|
||||
|
@ -132,11 +133,11 @@ void trans_line_x(int x,int y,int xs,int barva);
|
|||
//#pragma aux trans_line_x parm [EDI][ESI][ECX][EDX] modify [EAX];
|
||||
void trans_line_y(int x,int y,int ys,int barva);
|
||||
//#pragma aux trans_line_y parm [EDI][ESI][ECX][EDX] modify [EAX];
|
||||
void draw_placed_texture(short *txtr,int celx,int cely,int posx,int posy,int posz,char turn);
|
||||
void draw_placed_texture(const short *txtr,int celx,int cely,int posx,int posy,int posz,char turn);
|
||||
|
||||
void put_image(word *image,word *target,int start_line,int sizex,int sizey);
|
||||
void put_image(const word *image,word *target,int start_line,int sizex,int sizey);
|
||||
//#pragma aux put_image parm [ESI][EDI][EAX][EBX][EDX] modify [ECX]
|
||||
void put_picture2picture(word *source,word *target,int xp,int yp);
|
||||
void put_picture2picture(const word *source,word *target,int xp,int yp);
|
||||
//#pragma aux put_picture2picture parm [ESI][EDI][EAX][EDX] modify [ECX]
|
||||
|
||||
|
||||
|
|
|
@ -8,7 +8,8 @@
|
|||
|
||||
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};
|
||||
word *curfont,*writepos,writeposx;
|
||||
const word *curfont;
|
||||
word *writepos,writeposx;
|
||||
byte fontdsize=0;
|
||||
void (*showview)(word,word,word,word);
|
||||
char line480=0;
|
||||
|
@ -17,7 +18,8 @@ char screenstate=0;
|
|||
char __skip_change_line_test=0;
|
||||
char no_restore_mode=0;
|
||||
|
||||
void *mscursor,*mssavebuffer=NULL;
|
||||
const void *mscursor;
|
||||
void *mssavebuffer=NULL;
|
||||
integer mscuroldx=0,mscuroldy=0;
|
||||
integer mscuroldxs=1,mscuroldys=1;
|
||||
char write_window=0;
|
||||
|
@ -501,7 +503,7 @@ void redraw_ms_cursor_on_screen(void) {
|
|||
}
|
||||
|
||||
|
||||
void *register_ms_cursor(void *cursor)
|
||||
void *register_ms_cursor(const void *cursor)
|
||||
{
|
||||
integer xs,ys;
|
||||
|
||||
|
@ -544,7 +546,7 @@ void move_ms_cursor(integer newx,integer newy,char nodraw)
|
|||
mscuroldys=ys;
|
||||
}
|
||||
|
||||
int text_height(char *text)
|
||||
int text_height(const char *text)
|
||||
{
|
||||
char max=0,cur;
|
||||
|
||||
|
@ -553,7 +555,7 @@ int text_height(char *text)
|
|||
return max<<fontdsize;
|
||||
}
|
||||
|
||||
int text_width(char *text)
|
||||
int text_width(const char *text)
|
||||
{
|
||||
int suma=0;
|
||||
|
||||
|
@ -563,7 +565,7 @@ int text_width(char *text)
|
|||
}
|
||||
|
||||
|
||||
void set_aligned_position(int x,int y,char alignx,char aligny,char *text)
|
||||
void set_aligned_position(int x,int y,char alignx,char aligny,const char *text)
|
||||
{
|
||||
switch (alignx)
|
||||
{
|
||||
|
|
|
@ -121,7 +121,7 @@ void line_32(int x,int y,int xs,int ys)
|
|||
}
|
||||
|
||||
|
||||
void char_32(word *posit,word *font,char znak)
|
||||
void char_32(word *posit,const word *font,char znak)
|
||||
//#pragma aux char_32 parm [edi] [esi] [eax] modify [eax ebx ecx edx]
|
||||
{
|
||||
int32_t scr_linelen2 = GetScreenPitch();
|
||||
|
@ -213,7 +213,7 @@ chrend: ;konec
|
|||
}
|
||||
*/
|
||||
}
|
||||
void char2_32(word *posit,word *font,char znak)
|
||||
void char2_32(word *posit, const word *font,char znak)
|
||||
//#pragma aux char2_32 parm [edi] [esi] [eax] modify [eax ebx ecx edx]
|
||||
{
|
||||
|
||||
|
@ -275,7 +275,7 @@ chr2end: ;konec
|
|||
*/
|
||||
}
|
||||
|
||||
word charsize(word *font,char znak)
|
||||
word charsize(const word *font,char znak)
|
||||
{
|
||||
|
||||
unsigned char *esi = (unsigned char *)font;
|
||||
|
@ -308,12 +308,12 @@ chsend: and eax,0ffffh
|
|||
}*/
|
||||
}
|
||||
|
||||
void put_picture(word x,word y,void *p)
|
||||
void put_picture(word x,word y,const void *p)
|
||||
//#pragma aux put_picture parm [esi] [eax] [edi] modify [ebx ecx edx]
|
||||
{
|
||||
int32_t scr_linelen2 = GetScreenPitch();
|
||||
word *adr=GetScreenAdr()+scr_linelen2*y+x;
|
||||
word *data=p;
|
||||
const word *data=p;
|
||||
word xs=data[0];
|
||||
word ys=data[1];
|
||||
word mode=data[2];
|
||||
|
@ -354,7 +354,7 @@ void put_picture(word x,word y,void *p)
|
|||
}
|
||||
if (mode==8 || mode==264)
|
||||
{
|
||||
word *table=data;
|
||||
const word *table=data;
|
||||
uint8_t *cdata=(uint8_t *)(data+(mode==264?10*256:256));
|
||||
int i;
|
||||
int j;
|
||||
|
@ -369,7 +369,7 @@ void put_picture(word x,word y,void *p)
|
|||
}
|
||||
else if (mode==512 )
|
||||
{
|
||||
word *table=data;
|
||||
const word *table=data;
|
||||
uint8_t *cdata=(uint8_t *)(data+256);
|
||||
int i;
|
||||
int j;
|
||||
|
@ -412,11 +412,11 @@ void get_picture(word x,word y,word xs,word ys,void *p)
|
|||
}
|
||||
}
|
||||
|
||||
void put_image(word *image,word *target,int start_line,int sizex,int sizey)
|
||||
void put_image(const word *image,word *target,int start_line,int sizex,int sizey)
|
||||
//#pragma aux put_image parm [ESI][EDI][EAX][EBX][EDX] modify [ECX]
|
||||
{
|
||||
int32_t scr_linelen2 = GetScreenPitch();
|
||||
word *esi = image;
|
||||
const word *esi = image;
|
||||
word *edi = target;
|
||||
int edx = sizey;
|
||||
int ecx = esi[0];
|
||||
|
@ -464,15 +464,15 @@ puti_lp:mov ecx,ebx
|
|||
}*/
|
||||
}
|
||||
|
||||
void put_8bit_clipped(void *src,void *trg,int startline,int velx,int vely)
|
||||
void put_8bit_clipped(const void *src,void *trg,int startline,int velx,int vely)
|
||||
//#pragma aux put_8bit_clipped parm [ESI][EDI][EAX][EBX][EDX] modify [ECX];
|
||||
{
|
||||
int32_t scr_linelen2 = GetScreenPitch();
|
||||
if (src==NULL) return;
|
||||
{
|
||||
word *esi = src;
|
||||
const word *esi = src;
|
||||
word *edi = trg;
|
||||
word *paleta = esi+3;
|
||||
const word *paleta = esi+3;
|
||||
int cx = esi[0];
|
||||
unsigned char *imgdata = (unsigned char *)(esi + 3 + 256)+ startline * cx;
|
||||
|
||||
|
@ -536,7 +536,7 @@ put8_trns:
|
|||
ende:
|
||||
}*/
|
||||
|
||||
void put_textured_bar_(void *src,void *trg,int xsiz,int ysiz,int xofs,int yofs)
|
||||
void put_textured_bar_(const void *src,void *trg,int xsiz,int ysiz,int xofs,int yofs)
|
||||
//#pragma aux put_textured_bar_ parm [EBX][EDI][EDX][ECX][ESI][EAX];
|
||||
{
|
||||
|
||||
|
@ -711,7 +711,7 @@ void wait_retrace()
|
|||
|
||||
#define pic_start (2+2+2+512*5+512*5)
|
||||
|
||||
void put_picture2picture(word *source,word *target,int xp,int yp)
|
||||
void put_picture2picture(const word *source,word *target,int xp,int yp)
|
||||
//#pragma aux put_picture2picture parm [ESI][EDI][EAX][EDX] modify [ECX]
|
||||
{
|
||||
|
||||
|
|
|
@ -89,6 +89,9 @@ void keyboard(EVENT_MSG *msg, void *user_data) {
|
|||
user_data;
|
||||
if (msg->msg == E_WATCH) {
|
||||
*otevri_zavoru = 1;
|
||||
if (game_display_is_quit_requested()) {
|
||||
send_message(E_KEYBOARD, E_QUIT_GAME_KEY);
|
||||
}
|
||||
if (!_bios_keybrd(_KEYBRD_READY))
|
||||
return;
|
||||
i = _bios_keybrd(_KEYBRD_READ);
|
||||
|
|
|
@ -464,15 +464,12 @@ void except_GPF()
|
|||
}
|
||||
|
||||
*/
|
||||
|
||||
void init_events()
|
||||
{
|
||||
send_message(E_ADD,E_WATCH,keyboard);
|
||||
send_message(E_ADD,E_WATCH,timer);
|
||||
send_message(E_ADD,E_WATCH,tasker);
|
||||
#ifdef nodebug
|
||||
alloc_exception(0xD,except_GPF);
|
||||
alloc_exception(0xE,except_GPF);
|
||||
#endif
|
||||
}
|
||||
|
||||
static char do_events_called=0;
|
||||
|
|
|
@ -32,6 +32,9 @@
|
|||
#define E_MOUSE 11
|
||||
#define E_TIMER 12
|
||||
|
||||
|
||||
#define E_QUIT_GAME_KEY ((int)0xFFFF)
|
||||
|
||||
#define TASK_RUNNING 0
|
||||
#define TASK_TERMINATING 1
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@ FC_TABLE f_default;
|
|||
word desktop_y_size;
|
||||
char force_redraw_desktop=0;
|
||||
static char change_flag=0,f_cancel_event=0;
|
||||
word *default_font;
|
||||
const word *default_font;
|
||||
void empty()
|
||||
{
|
||||
}
|
||||
|
@ -382,7 +382,7 @@ CTL3D *border(word light,word shadow, word bsize, word btype)
|
|||
return &p;
|
||||
}
|
||||
|
||||
void property(CTL3D *ctl,word *font,FC_TABLE *fcolor,word color)
|
||||
void property(CTL3D *ctl,const word *font,FC_TABLE *fcolor,word color)
|
||||
{
|
||||
if (ctl!=NULL) memcpy(&o_end->border3d,ctl,sizeof(CTL3D));
|
||||
if (font!=NULL) o_end->font=font;
|
||||
|
|
|
@ -69,7 +69,7 @@ typedef struct objrec
|
|||
int32_t datasize;
|
||||
void *data;
|
||||
FC_TABLE f_color;
|
||||
word *font;
|
||||
const word *font;
|
||||
void *userptr;
|
||||
void (*call_init)(struct objrec *, va_list);
|
||||
void (*call_draw)(int , int, int, int, struct objrec *);
|
||||
|
@ -122,7 +122,7 @@ extern CTL3D noneborder;
|
|||
extern FC_TABLE f_default;
|
||||
extern word desktop_y_size;
|
||||
//extern char change_flag;
|
||||
extern word *default_font;
|
||||
extern const word *default_font;
|
||||
extern void *gui_background;
|
||||
|
||||
|
||||
|
@ -137,7 +137,7 @@ void redraw_object(OBJREC *o);
|
|||
void redraw_window(void);
|
||||
void define(int id,int x,int y,int xs,int ys,char align,void (*initproc)(OBJREC *),...);
|
||||
CTL3D *border(word light,word shadow, word bsize, word btype);
|
||||
void property(CTL3D *ctl,word *font,FC_TABLE *fcolor,word color);
|
||||
void property(CTL3D *ctl,const word *font,FC_TABLE *fcolor,word color);
|
||||
FC_TABLE *flat_color(word color);
|
||||
void aktivate_window(MS_EVENT *ms);
|
||||
void redraw_desktop(void);
|
||||
|
|
402
libs/memman.c
402
libs/memman.c
|
@ -21,7 +21,7 @@ void bonz_table();
|
|||
|
||||
#define NON_GETMEM_RESERVED (4*1024)
|
||||
static const char ** mman_pathlist=NULL;
|
||||
static char swap_status=0;
|
||||
|
||||
|
||||
static FILE *swap = NULL;
|
||||
char mman_patch=0;
|
||||
|
@ -121,133 +121,97 @@ typedef struct tnametable
|
|||
int32_t seek;
|
||||
}TNAMETABLE;
|
||||
|
||||
typedef struct tnametable_ref {
|
||||
const TNAMETABLE *data;
|
||||
uint32_t count;
|
||||
} TNAMETABLE_REF;
|
||||
|
||||
static int32_t *grptable,grptabsiz;
|
||||
static TNAMETABLE *nametable;
|
||||
static int nmtab_size;
|
||||
static TNAMETABLE_REF bmf_nametable;
|
||||
static TNAMETABLE_REF patch_nametable;
|
||||
static int next_name_read=0;
|
||||
static int last_group;
|
||||
|
||||
char *main_file_name=NULL;
|
||||
handle_groups _handles;
|
||||
static FILE *bmf=NULL;
|
||||
static FILE *patch=NULL;
|
||||
//static FILE *bmf=NULL;
|
||||
//static FILE *patch=NULL;
|
||||
static void *bmf_m = NULL;
|
||||
static size_t bmf_s = 0;
|
||||
static void *patch_m = NULL;
|
||||
static size_t patch_s = 0;
|
||||
uint32_t bk_global_counter=0;
|
||||
char *swap_path;
|
||||
|
||||
#ifdef LOGFILE
|
||||
void bonz_table()
|
||||
{
|
||||
int i;
|
||||
if (bmf==NULL) return;
|
||||
for(i=0;i<nmtab_size;i++)
|
||||
{
|
||||
fprintf(stderr,"%-12.12s %12d\n",nametable[i].name,nametable[i].seek);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
static int test_file_exist_DOS(int group,char *filename)
|
||||
{
|
||||
char *f;
|
||||
|
||||
f=alloca(strlen(mman_pathlist[group])+strlen(filename)+1);
|
||||
strcpy(f,mman_pathlist[group]);
|
||||
strcat(f,filename);
|
||||
const char *f = build_pathname(2, mman_pathlist[group], filename);
|
||||
if (!check_file_exists(f)) return 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void load_grp_table()
|
||||
{
|
||||
int32_t i = 0;;
|
||||
|
||||
SEND_LOG("(LOAD) Loading Group Table");
|
||||
fseek(bmf,4,SEEK_SET);
|
||||
fread(&i,4,1,bmf);
|
||||
const uint32_t *src_table = (const uint32_t *)bmf_m;
|
||||
//fseek(bmf,4,SEEK_SET);
|
||||
i = src_table[1];//fread(&i,4,1,bmf);
|
||||
grptable=(int32_t *)getmem(i+4);
|
||||
fseek(bmf,0,SEEK_SET);
|
||||
fread(grptable,i,1,bmf);
|
||||
//fseek(bmf,0,SEEK_SET);
|
||||
grptabsiz = src_table[0];
|
||||
//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");
|
||||
}
|
||||
|
||||
void load_file_table()
|
||||
{
|
||||
int strsize;
|
||||
void *p;
|
||||
|
||||
SEND_LOG("(LOAD) Loading File Table");
|
||||
fseek(bmf,grptabsiz,SEEK_SET);
|
||||
fseek(bmf,12,SEEK_CUR);
|
||||
fread(&strsize,4,1,bmf);
|
||||
strsize-=grptabsiz;
|
||||
fseek(bmf,grptabsiz,SEEK_SET);
|
||||
p=getmem(strsize);
|
||||
nametable = p;
|
||||
fread(nametable,1,strsize,bmf);
|
||||
nmtab_size=strsize/sizeof(*nametable);
|
||||
SEND_LOG("(LOAD) File Table Loaded");
|
||||
static TNAMETABLE_REF load_file_table(const void *bmf_m)
|
||||
{
|
||||
const uint32_t *src_table = (const uint32_t *)bmf_m;
|
||||
uint32_t grptabsiz = src_table[1];
|
||||
TNAMETABLE_REF out;
|
||||
out.data = (const TNAMETABLE *)((const char *)bmf_m + grptabsiz);
|
||||
out.count = (out.data[0].seek - grptabsiz)/sizeof(TNAMETABLE);
|
||||
return out;
|
||||
}
|
||||
|
||||
|
||||
|
||||
int find_name(int group,char *name)
|
||||
{
|
||||
int i;
|
||||
|
||||
for(i=0;i<(grptabsiz>>2);i+=2)
|
||||
{
|
||||
if (grptable[i]==group) break;
|
||||
}
|
||||
if ((grptabsiz>>2)<=i) return -1;
|
||||
for(i=grptable[i+1];i<nmtab_size;i++)
|
||||
if (!strncmp(nametable[i].name,name,12)) break;
|
||||
if (i==nmtab_size) return -1;
|
||||
return i;
|
||||
int get_file_entry_in_table(const TNAMETABLE_REF *where, char *name) {
|
||||
for(uint32_t i = 0; i< where->count; ++i) {
|
||||
if (strncmp(where->data[i].name, name, 12) == 0) {
|
||||
return where->data[i].seek;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
int get_file_entry(int group,char *name)
|
||||
{
|
||||
int i;
|
||||
char ex;
|
||||
|
||||
if (mman_patch) ex=test_file_exist_DOS(group,name);else ex=0;
|
||||
if (ex || bmf==0) return 0;
|
||||
i=find_name(group,name);
|
||||
if (i==-1) return 0;
|
||||
return nametable[i].seek;
|
||||
ex=test_file_exist_DOS(group,name);
|
||||
if (ex || bmf_m==0) return 0;
|
||||
if (patch_m) {
|
||||
int sk = get_file_entry_in_table(&patch_nametable, name);
|
||||
if (sk >= 0) return -sk;
|
||||
}
|
||||
if (bmf_m) {
|
||||
int sk = get_file_entry_in_table(&bmf_nametable, name);
|
||||
if (sk >= 0) return sk;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
int swap_block(THANDLE_DATA *h)
|
||||
{
|
||||
int32_t wsize,pos;
|
||||
|
||||
if (mman_action!=NULL) mman_action(MMA_SWAP);
|
||||
if (!swap) return -1;
|
||||
if (h->flags & BK_HSWAP) pos=h->seekpos; else pos=swap_add_block(h->size);
|
||||
fseek(swap,0,SEEK_END);
|
||||
wsize=ftell(swap);
|
||||
fseek(swap,pos,SEEK_SET);
|
||||
SEND_LOG("(SWAP) Swaping block '%-.12s'",h->src_file);
|
||||
wsize=fwrite(h->blockdata,1,h->size,swap);
|
||||
swap_status=1;
|
||||
if ((unsigned)wsize==h->size)
|
||||
{
|
||||
h->seekpos=pos;
|
||||
if (h->flags & BK_PRELOAD) h->flags&=~BK_SWAPABLE;
|
||||
h->flags|=BK_HSWAP;
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
SEND_LOG("(SWAP) Swap failed!");
|
||||
swap_error();
|
||||
}
|
||||
swap_free_block(pos,h->size);
|
||||
return -1;
|
||||
}
|
||||
|
||||
THANDLE_DATA *get_handle(int handle)
|
||||
{
|
||||
|
@ -264,80 +228,16 @@ THANDLE_DATA *get_handle(int handle)
|
|||
return ((THANDLE_DATA *)_handles[group])+list;
|
||||
}
|
||||
|
||||
void heap_error(size_t size) //heap system
|
||||
{
|
||||
int i,j;
|
||||
uint32_t maxcounter=0;
|
||||
THANDLE_DATA *sh;
|
||||
char repeat=0,did=0;
|
||||
THANDLE_DATA *lastblock=NULL;
|
||||
char *last_free=NULL;
|
||||
do
|
||||
{
|
||||
maxcounter=0;
|
||||
sh=NULL;
|
||||
repeat=0;did=0;
|
||||
for(i=0;i<BK_MAJOR_HANDLES;i++)
|
||||
if (_handles[i]!=NULL)
|
||||
{
|
||||
uint32_t c,max=0xffffffff,d;
|
||||
for (j=0;j<BK_MINOR_HANDLES;j++)
|
||||
{
|
||||
THANDLE_DATA *h;
|
||||
|
||||
h=((THANDLE_DATA *)_handles[i]+j);
|
||||
c=bk_global_counter-h->counter;
|
||||
if (h->status==BK_PRESENT && ~h->flags & BK_LOCKED) {
|
||||
if (last_free!=NULL)
|
||||
{
|
||||
d=(char *)h->blockdata-last_free;
|
||||
if (d<max) sh=h,max=d,did=1;
|
||||
}
|
||||
else if (c>maxcounter)
|
||||
{
|
||||
maxcounter=c;
|
||||
sh=h;
|
||||
did=1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (lastblock==sh)
|
||||
{
|
||||
did=0;repeat=0;
|
||||
}
|
||||
if (did)
|
||||
{
|
||||
size-=sh->size;
|
||||
last_free=sh->blockdata;
|
||||
if (sh->flags & BK_SWAPABLE)
|
||||
{
|
||||
if (swap_block(sh)) //pri neuspechu o ulozeni je nalezen blok jiny
|
||||
{
|
||||
sh->counter=bk_global_counter;
|
||||
repeat=1;
|
||||
}
|
||||
else
|
||||
{
|
||||
free(sh->blockdata);
|
||||
sh->status=BK_SWAPED;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (sh->flags & BK_PRELOAD) sh->status=BK_SWAPED;
|
||||
else sh->status=BK_NOT_LOADED;
|
||||
free(sh->blockdata);
|
||||
if (mman_action!=NULL) mman_action(MMA_FREE);
|
||||
}
|
||||
}
|
||||
else
|
||||
standard_mem_error(size);
|
||||
lastblock=sh;
|
||||
}
|
||||
while (repeat || size>0);
|
||||
// if (swaped) _dos_commit(swap);
|
||||
}
|
||||
static char need_to_be_free(const void *ptr) {
|
||||
const char *beg = (const char *)bmf_m;
|
||||
const char *p = (const char *)ptr;
|
||||
if (p >= beg && p < beg+bmf_s) return 0;
|
||||
beg = (const char *)patch_m;
|
||||
if (p >= beg && p < beg+bmf_s) return 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
THANDLE_DATA *kill_block(int handle)
|
||||
{
|
||||
|
@ -351,7 +251,9 @@ THANDLE_DATA *kill_block(int handle)
|
|||
}
|
||||
SEND_LOG("(KILL) Killing block '%-.12s' (%04X)",h->src_file,handle);
|
||||
if (h->status==BK_SAME_AS) return h;
|
||||
if (h->status==BK_PRESENT) free(h->blockdata);
|
||||
if (h->status==BK_PRESENT) {
|
||||
ablock_free(h->blockdata);
|
||||
}
|
||||
if (h->flags & BK_HSWAP) swap_free_block(h->seekpos,h->size);
|
||||
h->status=BK_NOT_LOADED;
|
||||
h->flags&=~BK_HSWAP;
|
||||
|
@ -369,6 +271,11 @@ THANDLE_DATA *zneplatnit_block(int handle)
|
|||
return h;
|
||||
}
|
||||
|
||||
static void heap_error() {
|
||||
display_error("out of memory");
|
||||
abort();
|
||||
}
|
||||
|
||||
void init_manager(const char *filename,const char *swap_is_not_supported) // filename= Jmeno datoveho souboru nebo NULL pak
|
||||
// se pouzije DOS
|
||||
// swp je cesta do TEMP adresare
|
||||
|
@ -378,13 +285,12 @@ void init_manager(const char *filename,const char *swap_is_not_supported) // fil
|
|||
memset(_handles,0,sizeof(_handles));
|
||||
if (filename!=NULL)
|
||||
{
|
||||
bmf=fopen_icase(filename,"rb");
|
||||
if (bmf)
|
||||
bmf_m = map_file_to_memory(file_icase_find(filename), &bmf_s);
|
||||
if (bmf_m)
|
||||
{
|
||||
main_file_name=(char *)getmem(strlen(filename)+1);
|
||||
strcpy(main_file_name,filename);
|
||||
load_grp_table();
|
||||
load_file_table();
|
||||
bmf_nametable = load_file_table(bmf_m);
|
||||
}
|
||||
else
|
||||
main_file_name=NULL;
|
||||
|
@ -433,11 +339,11 @@ int find_handle(const char *name,void *decomp)
|
|||
|
||||
int test_file_exist(int group,char *filename)
|
||||
{
|
||||
if (find_name(group,filename)==-1) return test_file_exist_DOS(group,filename);
|
||||
if (get_file_entry(group,filename)==0) return test_file_exist_DOS(group,filename);
|
||||
return 1;
|
||||
}
|
||||
|
||||
THANDLE_DATA *def_handle(int handle,const char *filename,void *decompress,char path)
|
||||
THANDLE_DATA *def_handle(int handle,const char *filename,ABLOCK_DECODEPROC decompress,char path)
|
||||
{
|
||||
THANDLE_DATA *h;
|
||||
int i;
|
||||
|
@ -473,7 +379,7 @@ THANDLE_DATA *def_handle(int handle,const char *filename,void *decompress,char p
|
|||
|
||||
void *afile(char *filename,int group,int32_t *blocksize)
|
||||
{
|
||||
char *c,*d;
|
||||
char *d;
|
||||
int32_t entr;
|
||||
void *p;
|
||||
|
||||
|
@ -484,27 +390,41 @@ void *afile(char *filename,int group,int32_t *blocksize)
|
|||
else entr=get_file_entry(group,d);
|
||||
if (entr!=0)
|
||||
{
|
||||
FILE *hnd;
|
||||
const void *hnd;
|
||||
SEND_LOG("(LOAD) Afile is loading file '%s' from group %d",d,group);
|
||||
if (entr<0) entr=-entr,hnd=patch;else hnd=bmf;
|
||||
fseek(hnd,entr,SEEK_SET);
|
||||
fread(blocksize,1,4,hnd);
|
||||
p=getmem(*blocksize);
|
||||
fread(p,1,*blocksize,hnd);
|
||||
if (entr<0) entr=-entr,hnd=patch_m;else hnd=bmf_m;
|
||||
const int32_t * szptr = (const int32_t *)hnd;
|
||||
*blocksize = *szptr;
|
||||
void *ret = getmem(*blocksize);
|
||||
memcpy(ret, szptr+1, *blocksize);
|
||||
return ret;
|
||||
}
|
||||
else if (mman_pathlist!=NULL)
|
||||
{
|
||||
const char *name = build_pathname(2,mman_pathlist[group],d);
|
||||
|
||||
SEND_LOG("(LOAD) Afile is loading file '%s' from disk (group %d)",d,group);
|
||||
c=alloca(strlen(filename)+strlen(mman_pathlist[group])+2);
|
||||
c=strcat(strcpy(c,mman_pathlist[group]),filename);
|
||||
p=load_file(c);
|
||||
p=load_file(name);
|
||||
*blocksize=last_load_size;
|
||||
}
|
||||
else return NULL;
|
||||
return p;
|
||||
}
|
||||
|
||||
void *ablock(int handle)
|
||||
|
||||
static void decompress_data(THANDLE_DATA *h) {
|
||||
if (h->loadproc) {
|
||||
int32_t sz = h->size;
|
||||
const void *r = h->loadproc(h->blockdata, &sz);
|
||||
if (r != h->blockdata) {
|
||||
ablock_free(h->blockdata);
|
||||
h->blockdata = r;
|
||||
h->size = sz;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const void *ablock(int handle)
|
||||
{
|
||||
THANDLE_DATA *h;
|
||||
|
||||
|
@ -517,10 +437,11 @@ void *ablock(int handle)
|
|||
handle=h->seekpos;
|
||||
goto sem;
|
||||
}
|
||||
if (h->status==BK_PRESENT) return h->blockdata;
|
||||
if (h->status==BK_DIRLIST)
|
||||
if (h->status==BK_PRESENT) {
|
||||
return h->blockdata;
|
||||
} if (h->status==BK_DIRLIST)
|
||||
{
|
||||
free(h->blockdata);h->status=BK_NOT_LOADED;
|
||||
ablock_free(h->blockdata);h->status=BK_NOT_LOADED;
|
||||
}
|
||||
if (h->status==BK_NOT_LOADED)
|
||||
{
|
||||
|
@ -541,27 +462,26 @@ void *ablock(int handle)
|
|||
p=NULL;
|
||||
s=0;
|
||||
}
|
||||
if (h->loadproc!=NULL) h->loadproc(&p,&s);
|
||||
h->blockdata=p;
|
||||
h->status=BK_PRESENT;
|
||||
h->size=s;
|
||||
return p;
|
||||
decompress_data(h);
|
||||
return h->blockdata;
|
||||
}
|
||||
else
|
||||
{
|
||||
int entr=h->seekpos;
|
||||
FILE *hnd;
|
||||
int entr=h->seekpos;
|
||||
const void *hnd;
|
||||
if (mman_action!=NULL) mman_action(MMA_READ);
|
||||
if (entr<0) entr=-entr,hnd=patch;else hnd=bmf;
|
||||
fseek(hnd,entr,SEEK_SET);
|
||||
fread(&s,1,4,hnd);
|
||||
p=getmem(s);
|
||||
fread(p,1,s,hnd);
|
||||
if (h->loadproc!=NULL) h->loadproc(&p,&s);
|
||||
if (entr<0) entr=-entr,hnd=patch_m;else hnd=bmf_m;
|
||||
const int32_t *szptr =(const int32_t *)((const char *)hnd+entr);
|
||||
s = *szptr;
|
||||
void *p = (void *)(szptr+1);
|
||||
h->blockdata=p;
|
||||
h->status=BK_PRESENT;
|
||||
h->size=s;
|
||||
return p;
|
||||
decompress_data(h);
|
||||
return h->blockdata;
|
||||
}
|
||||
}
|
||||
//tato cast programu bude jeste dodelana - else ....
|
||||
|
@ -572,6 +492,16 @@ void *ablock(int handle)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
void *ablock_copy(int handle) {
|
||||
const void *ptr = ablock(handle);
|
||||
if (need_to_be_free(ptr)) return (void *)ptr;
|
||||
THANDLE_DATA *h = get_handle(handle);
|
||||
void *cpy = getmem(h->size);
|
||||
memcpy(cpy, ptr, h->size);
|
||||
h->blockdata = cpy;
|
||||
return cpy;
|
||||
}
|
||||
|
||||
void alock(int handle)
|
||||
{
|
||||
THANDLE_DATA *h;
|
||||
|
@ -651,43 +581,6 @@ void apreload_sign(int handle,int max_handle)
|
|||
if (!(h->flags & BK_PRELOAD) || !(h->flags & BK_HSWAP)) apr_sign[handle]=h->seekpos;
|
||||
}
|
||||
|
||||
int apreload_sort(const void *val1,const void *val2)
|
||||
{
|
||||
int32_t vl1,vl2;
|
||||
|
||||
vl1=apr_sign[*(word *)val1];
|
||||
vl2=apr_sign[*(word *)val2];
|
||||
return (vl1>vl2)-(vl1<vl2);
|
||||
}
|
||||
|
||||
void apreload_start(void (*percent)(int cur,int max))
|
||||
{
|
||||
short *p;
|
||||
int i;
|
||||
int c,z;
|
||||
|
||||
swap_status=0;
|
||||
p=NewArr(short,max_sign);
|
||||
for(i=0;i<max_sign;i++) p[i]=i;
|
||||
qsort(p,max_sign,sizeof(word),apreload_sort);
|
||||
for(i=0,c=0;i<max_sign;i++) if (apr_sign[p[i]]==0x7f7f7f7f)p[i]=-1;else c++;
|
||||
for(i=0,z=0;i<max_sign;i++) if (p[i]!=-1)
|
||||
{
|
||||
apreload(p[i]);
|
||||
percent(z++,swap_status?c+max_sign*2:c);
|
||||
}
|
||||
if (swap_status)
|
||||
for(i=0;i<max_sign;i++)
|
||||
{
|
||||
THANDLE_DATA *h=get_handle(p[i]);
|
||||
if (h->status==BK_PRESENT) swap_block(h);
|
||||
percent(c+i,c+max_sign);
|
||||
}
|
||||
// _dos_commit(swap);
|
||||
free(apr_sign);
|
||||
free(p);
|
||||
apr_sign=NULL;
|
||||
}
|
||||
|
||||
void undef_handle(int handle)
|
||||
{
|
||||
|
@ -715,11 +608,10 @@ void close_manager()
|
|||
free(_handles[i]);
|
||||
}
|
||||
free(main_file_name);
|
||||
if (bmf) fclose(bmf);
|
||||
if (patch) fclose(patch);
|
||||
if (bmf_m) unmap_file(bmf_m, bmf_s);
|
||||
if (patch_m) unmap_file(patch_m, patch_s);
|
||||
if (swap) fclose(swap);
|
||||
free(grptable); grptable=NULL;
|
||||
free(nametable); nametable=NULL;
|
||||
|
||||
max_handle=0;
|
||||
}
|
||||
|
||||
|
@ -814,13 +706,6 @@ void *grealloc(void *p,int32_t size)
|
|||
return q;
|
||||
}
|
||||
|
||||
char *read_next_entry(char mode)
|
||||
{
|
||||
if (mode==MMR_FIRST) next_name_read=0;
|
||||
if (main_file_name==NULL) return NULL;
|
||||
if (next_name_read>=nmtab_size) return NULL;
|
||||
return nametable[next_name_read++].name;
|
||||
}
|
||||
|
||||
int read_group(int index)
|
||||
{
|
||||
|
@ -829,34 +714,13 @@ int read_group(int index)
|
|||
|
||||
char add_patch_file(char *filename)
|
||||
{
|
||||
int32_t l;
|
||||
int32_t poc;
|
||||
int i,cc=0;
|
||||
TNAMETABLE p;
|
||||
SEND_LOG("Adding patch: %s",filename);
|
||||
if (!patch) return 2;
|
||||
if (!bmf) return 3;
|
||||
patch=fopen_icase(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);
|
||||
fseek(patch,l,SEEK_SET);
|
||||
for(i=0;i<poc;i++)
|
||||
{
|
||||
int j;
|
||||
fread(&p,1,sizeof(p),patch);
|
||||
j=find_name(read_group(0),p.name);
|
||||
if (j==-1)
|
||||
{
|
||||
nametable=grealloc(nametable,sizeof(TNAMETABLE)*(nmtab_size+1));
|
||||
j=nmtab_size++;strncpy(nametable[j].name,p.name,12);
|
||||
}
|
||||
nametable[j].seek=-p.seek,cc++;
|
||||
}
|
||||
SEND_LOG("Patch added: %s - %d entries modified",filename,cc);
|
||||
if (!patch_m) return 2;
|
||||
if (!bmf_m) return 3;
|
||||
patch_m = map_file_to_memory(file_icase_find(filename), &bmf_s);
|
||||
if (!patch_m) return 1;
|
||||
patch_nametable = load_file_table(patch_m);
|
||||
SEND_LOG("Patch added: %s - %u entries modified",filename,patch_nametable.count);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -943,3 +807,7 @@ FILE *afiletemp(char *filename, int group)
|
|||
fseek(f,0,SEEK_SET);
|
||||
return f;
|
||||
}
|
||||
|
||||
void ablock_free(const void *ptr) {
|
||||
if (need_to_be_free(ptr)) free((void *)ptr);
|
||||
}
|
||||
|
|
|
@ -12,6 +12,14 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
///decodes block if needed
|
||||
/**
|
||||
* @param src source data
|
||||
* @param size source size - you need to write own size if data has been converted
|
||||
* @param pointer either to src or newly allocated block with replacement (must be allocated by malloc)
|
||||
*/
|
||||
typedef const void *(*ABLOCK_DECODEPROC)(const void *src, int32_t *size);
|
||||
|
||||
|
||||
#define freemem(size) free(size);
|
||||
//#define malloc(size) getmem(size)
|
||||
|
@ -36,11 +44,11 @@ typedef struct thandle_data
|
|||
{
|
||||
char src_file[12]; //12
|
||||
int32_t seekpos; //16
|
||||
void *blockdata; //20
|
||||
const void *blockdata; //20
|
||||
char flags; //21
|
||||
uint8_t path; //22
|
||||
short status;
|
||||
void (*loadproc)(void **data,int32_t *size);//28
|
||||
ABLOCK_DECODEPROC loadproc;
|
||||
unsigned short lockcount; //32
|
||||
uint32_t counter;
|
||||
uint32_t size;
|
||||
|
@ -66,6 +74,7 @@ typedef handle_list *handle_groups[BK_MAJOR_HANDLES];
|
|||
#define BK_SHARED 4
|
||||
#define BK_PRELOAD 8
|
||||
#define BK_HSWAP 16
|
||||
#define BK_READONLY 32
|
||||
|
||||
//extern char *const * mman_pathlist; //tento pointer musi byt naplnen ukazatelem na tabulku cest
|
||||
extern int memman_handle; //cislo handle naposled zpracovavaneho prikazem ablock
|
||||
|
@ -75,13 +84,13 @@ void *grealloc(void *m,int32_t size); //realokace pameti pres memman
|
|||
void *load_file(const char *filename); //obycejne natahne soubor do pameti a vrati ukazatel.
|
||||
void init_manager(const char *filename,const char *swp); //inicializuje manager. Jmeno filename i swapname nejsou povinne (musi byt NULL kdyz nejsou pouzity)
|
||||
void def_mman_group_table(const char ** ); //define pointer to table of paths, for each group there is path
|
||||
THANDLE_DATA *def_handle(int handle,const char *filename,void *decompress,char path); //deklaruje rukojet. promenna decompress je ukazatel na funkci ktera upravi data pred vracenim ukazatele
|
||||
void *ablock(int handle); //vraci ukazatel bloku spojeneho s handlem
|
||||
THANDLE_DATA *def_handle(int handle,const char *filename,ABLOCK_DECODEPROC decompress,char path); //deklaruje rukojet. promenna decompress je ukazatel na funkci ktera upravi data pred vracenim ukazatele
|
||||
const void *ablock(int handle); //vraci ukazatel bloku spojeneho s handlem
|
||||
void *ablock_copy(int handle); //vraci ukazatel bloku spojeneho s handlem
|
||||
void alock(int handle); //zamyka blok
|
||||
void aunlock(int handle); //odmyka blok
|
||||
void aswap(int handle); //zapina swapovani pro blok
|
||||
void aunswap(int handle); //vypina swapovani pro blok
|
||||
void apreload(int handle); //zapina preloading pro blok (preloading proved pomoci ablock)
|
||||
//void free(void); //free
|
||||
void close_manager(void); //uzavre manager a uvolni veskerou pamet
|
||||
void undef_handle(int handle); //uvolni hadle k dalsimu pouziti
|
||||
|
@ -92,11 +101,9 @@ int test_file_exist(int group,char *filename); //testuje zda soubor existuje v r
|
|||
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 ablock_free(const void *ptr);
|
||||
|
||||
void apreload_sign(int handle,int max_handle); //pripravi preloading pro nacteni dat z CD (sekvencne)
|
||||
void apreload_start(void (*percent)(int cur,int max)); //provede sekvenci apreload
|
||||
|
||||
char *read_next_entry(char mode); //cte adresar DDL souboru a vraci jmeno, nebo NULL. mode udava, zda se hleda od zacatku, nebo pokracuje tam kde program skoncil
|
||||
int read_group(int index);
|
||||
char add_patch_file(char *filename); //pripojuje zaplatu
|
||||
FILE *afiletemp(char *filename, int group);
|
||||
|
|
|
@ -123,7 +123,7 @@ static void StretchImageHQ(word *src, word *trg, int32_t linelen, char full)
|
|||
|
||||
|
||||
|
||||
static void PlayMGFFile(void *file, MGIF_PROC proc,int ypos,char full)
|
||||
static void PlayMGFFile(const void *file, MGIF_PROC proc,int ypos,char full)
|
||||
{
|
||||
int32_t scr_linelen2 = GetScreenPitch();
|
||||
mgif_install_proc(proc);
|
||||
|
@ -144,7 +144,9 @@ static void PlayMGFFile(void *file, MGIF_PROC proc,int ypos,char full)
|
|||
file=mgif_play(file);
|
||||
StretchImageHQ(picture, GetScreenAdr()+ypos*scr_linelen2, scr_linelen2,full);
|
||||
showview(0,ypos,0,360);
|
||||
if (_bios_keybrd(_KEYBRD_READY)==0) {
|
||||
if (game_display_is_quit_requested()) {
|
||||
break;
|
||||
} else if (_bios_keybrd(_KEYBRD_READY)==0) {
|
||||
mix_back_sound(0);
|
||||
}
|
||||
else
|
||||
|
@ -159,13 +161,13 @@ static void PlayMGFFile(void *file, MGIF_PROC proc,int ypos,char full)
|
|||
}
|
||||
|
||||
|
||||
void show_full_lfb12e(void *target,void *buff,void *paleta);
|
||||
void show_delta_lfb12e(void *target,void *buff,void *paleta);
|
||||
void show_full_lfb12e(void *target,const void *buff,const void *paleta);
|
||||
void show_delta_lfb12e(void *target,const void *buff,const void *paleta);
|
||||
void show_delta_lfb12e_dx(void *target,void *buff,void *paleta);
|
||||
void show_full_lfb12e_dx(void *target,void *buff,void *paleta);
|
||||
|
||||
|
||||
word * load_mgf_palette(word *pal) {
|
||||
word * load_mgf_palette(const word *pal) {
|
||||
static word paleta[256];
|
||||
for (int i = 0; i < 256; ++i) {
|
||||
paleta[i] = pal[i]+(pal[i]&0x7fe0);
|
||||
|
@ -173,7 +175,7 @@ word * load_mgf_palette(word *pal) {
|
|||
return paleta;
|
||||
}
|
||||
|
||||
void BigPlayProc(int act,void *data,int csize)
|
||||
void BigPlayProc(int act,const void *data,int csize)
|
||||
{
|
||||
switch (act)
|
||||
{
|
||||
|
@ -189,7 +191,7 @@ void BigPlayProc(int act,void *data,int csize)
|
|||
void play_animation(const char *filename,char mode,int posy,char sound)
|
||||
{
|
||||
size_t sz;
|
||||
void *mgf=map_file_to_memory(filename, &sz);
|
||||
void *mgf=map_file_to_memory(file_icase_find(filename), &sz);
|
||||
change_music(NULL);
|
||||
if (mgf==NULL) return;
|
||||
PlayMGFFile(mgf,BigPlayProc,posy,mode & 0x80);
|
||||
|
|
|
@ -74,9 +74,9 @@ void mgif_install_proc(MGIF_PROC proc)
|
|||
show_proc=proc;
|
||||
}
|
||||
|
||||
struct mgif_header load_mgif_header(char **mgif) {
|
||||
struct mgif_header load_mgif_header(const char **mgif) {
|
||||
struct mgif_header r;
|
||||
char *iter = *mgif;
|
||||
const char *iter = *mgif;
|
||||
memcpy(r.sign, iter, 4); iter+=4;
|
||||
memcpy(r.year, iter, 2); iter+=2;
|
||||
r.eof = *iter++;
|
||||
|
@ -90,9 +90,9 @@ struct mgif_header load_mgif_header(char **mgif) {
|
|||
return r;
|
||||
}
|
||||
|
||||
void *open_mgif(void *mgif) //vraci ukazatel na prvni frame
|
||||
const void *open_mgif(const void *mgif) //vraci ukazatel na prvni frame
|
||||
{
|
||||
char *c = mgif;
|
||||
const char *c = mgif;
|
||||
struct mgif_header mgh = load_mgif_header(&c);
|
||||
|
||||
if (strncmp(mgh.sign,MGIF,4)) return NULL;
|
||||
|
@ -111,9 +111,9 @@ void close_mgif(void) //dealokuje buffery pro prehravani
|
|||
}
|
||||
|
||||
|
||||
int input_code(void *source,int32_t *bitepos,int bitsize,int mask)
|
||||
int input_code(const void *source,int32_t *bitepos,int bitsize,int mask)
|
||||
{
|
||||
uint8_t *esi = source; // mov esi,source
|
||||
const uint8_t *esi = source; // mov esi,source
|
||||
int32_t *edi = bitepos; // mov edi,bitepos
|
||||
int ebx = bitsize; // mov ebx,bitsize
|
||||
int edx = mask; // mov edx,mask
|
||||
|
@ -276,7 +276,7 @@ end:
|
|||
*/
|
||||
}
|
||||
|
||||
void lzw_decode(void *source,char *target)
|
||||
void lzw_decode(const void *source,char *target)
|
||||
{
|
||||
int32_t bitpos=0;
|
||||
int code;
|
||||
|
@ -332,7 +332,7 @@ typedef struct chunk_header_t {
|
|||
uint8_t type;
|
||||
} CHUNK_HEADER_T;
|
||||
|
||||
CHUNK_HEADER_T read_chunk_header(char **iter) {
|
||||
CHUNK_HEADER_T read_chunk_header(const char **iter) {
|
||||
CHUNK_HEADER_T ret;
|
||||
ret.type = *(uint8_t *)(*iter)++;
|
||||
ret.size = *(uint8_t *)(*iter)++;
|
||||
|
@ -341,7 +341,7 @@ CHUNK_HEADER_T read_chunk_header(char **iter) {
|
|||
return ret;
|
||||
}
|
||||
|
||||
FRAME_HEADER_T read_frame_header(char **iter) {
|
||||
FRAME_HEADER_T read_frame_header(const char **iter) {
|
||||
FRAME_HEADER_T ret;
|
||||
ret.count = *(uint8_t *)(*iter)++;
|
||||
ret.size = *(uint8_t *)(*iter)++;
|
||||
|
@ -350,11 +350,13 @@ FRAME_HEADER_T read_frame_header(char **iter) {
|
|||
return ret;
|
||||
}
|
||||
|
||||
void *mgif_play(void *mgif) //dekoduje a zobrazi frame
|
||||
const void *mgif_play(const void *mgif) //dekoduje a zobrazi frame
|
||||
{
|
||||
char *pf,*pc,*ff;
|
||||
const char *pf;
|
||||
const char *pc;
|
||||
char *ff;
|
||||
// int acts,size,act,csize;
|
||||
void *scr_sav;
|
||||
const void *scr_sav;
|
||||
int scr_act=-1;
|
||||
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
//!!!! POZOR, NUTNE LINKOVAT SOUBOR LZWA.ASM
|
||||
#ifndef _MGIFMEM_H
|
||||
|
||||
typedef void (*MGIF_PROC)(int,void *,int csize); //prvni cislo akce, druhy data akce
|
||||
typedef void (*MGIF_PROC)(int,const void *,int csize); //prvni cislo akce, druhy data akce
|
||||
|
||||
#define _MGIFMEM_H
|
||||
#define MGIF "MGIF"
|
||||
|
@ -34,7 +34,7 @@ typedef struct mgif_header
|
|||
|
||||
|
||||
void mgif_install_proc(MGIF_PROC proc);
|
||||
void *open_mgif(void *mgif); //vraci ukazatel na prvni frame
|
||||
void *mgif_play(void *mgif); //dekoduje a zobrazi frame
|
||||
const void *open_mgif(const void *mgif); //vraci ukazatel na prvni frame
|
||||
const void *mgif_play(const void *mgif); //dekoduje a zobrazi frame
|
||||
void close_mgif(void); //dealokuje buffery pro prehravani
|
||||
#endif
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
#include <assert.h>
|
||||
|
||||
void show_full_lfb12e(void *target, void *buff, void *paleta) {
|
||||
void show_full_lfb12e(void *target,const void *buff, const void *paleta) {
|
||||
uint16_t *edi = (uint16_t *)target;
|
||||
uint8_t *esi = (uint8_t *)buff;
|
||||
uint16_t *ebx = (uint16_t *)paleta;
|
||||
|
|
49
libs/pcx.c
49
libs/pcx.c
|
@ -13,9 +13,9 @@
|
|||
void *get_palette_ptr=NULL;
|
||||
|
||||
|
||||
void decomprimate_line_256(char *src,char *trg,int linelen,int *srcstep)
|
||||
void decomprimate_line_256(const char *src,char *trg,int linelen,int *srcstep)
|
||||
{
|
||||
char *srcsave;
|
||||
const char *srcsave;
|
||||
|
||||
srcsave=src;
|
||||
while (linelen--)
|
||||
|
@ -31,9 +31,9 @@ void decomprimate_line_256(char *src,char *trg,int linelen,int *srcstep)
|
|||
}
|
||||
*srcstep=src-srcsave;
|
||||
}
|
||||
void decomprimate_line_hi(char *src,unsigned short *trg,unsigned short *paleta,int linelen,int *srcstep)
|
||||
void decomprimate_line_hi(const char *src,unsigned short *trg,unsigned short *paleta,int linelen,int *srcstep)
|
||||
{
|
||||
char *srcsave;
|
||||
const char *srcsave;
|
||||
|
||||
srcsave=src;
|
||||
while (linelen--)
|
||||
|
@ -52,10 +52,10 @@ void decomprimate_line_hi(char *src,unsigned short *trg,unsigned short *paleta,i
|
|||
*srcstep=src-srcsave;
|
||||
}
|
||||
|
||||
void palette_shadow(char *pal1,unsigned short pal2[][256],int tr,int tg,int tb)
|
||||
void palette_shadow(const char *pal1,unsigned short pal2[][256],int tr,int tg,int tb)
|
||||
{
|
||||
int i,j;
|
||||
char *bt;
|
||||
const char *bt;
|
||||
int r,g,b;
|
||||
short hi;
|
||||
|
||||
|
@ -90,14 +90,15 @@ void palette_shadow(char *pal1,unsigned short pal2[][256],int tr,int tg,int tb)
|
|||
}
|
||||
|
||||
|
||||
int load_pcx(char *pcx,int32_t fsize,int conv_type,char **buffer, ... )
|
||||
int load_pcx(const 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];
|
||||
char *paleta1;
|
||||
char *ptr1;
|
||||
const char *paleta1;
|
||||
const char *ptr1;
|
||||
char *ptr4;
|
||||
unsigned short *ptr2;
|
||||
char *ptr3;
|
||||
const char *ptr3;
|
||||
int i;
|
||||
PCXHEADER pcxdata;
|
||||
int xsize,ysize;
|
||||
|
@ -129,20 +130,20 @@ int load_pcx(char *pcx,int32_t fsize,int conv_type,char **buffer, ... )
|
|||
case A_NORMAL_PAL: *buffer=(char *)getmem(sz = xsize*ysize+16+768);break;
|
||||
default: return -2; //invalid type specificied
|
||||
}
|
||||
ptr1=*buffer;
|
||||
*(unsigned short *)ptr1++=xsize;ptr1++;
|
||||
*(unsigned short *)ptr1++=ysize;ptr1++;
|
||||
*(unsigned short *)ptr1++=conv_type;ptr1++;
|
||||
ptr4=*buffer;
|
||||
*(unsigned short *)ptr4++=xsize;ptr4++;
|
||||
*(unsigned short *)ptr4++=ysize;ptr4++;
|
||||
*(unsigned short *)ptr4++=conv_type;ptr4++;
|
||||
pcx+=sizeof(pcxdata);ptr3=pcx;
|
||||
if (conv_type==A_NORMAL_PAL)
|
||||
{
|
||||
memcpy(ptr1,paleta1,768);
|
||||
ptr1+=768;
|
||||
memcpy(ptr4,paleta1,768);
|
||||
ptr4+=768;
|
||||
}
|
||||
if (conv_type==A_8BIT)
|
||||
{
|
||||
memcpy(ptr1,paleta2,512);
|
||||
ptr1+=512;
|
||||
memcpy(ptr4,paleta2,512);
|
||||
ptr4+=512;
|
||||
}
|
||||
if (conv_type==A_FADE_PAL)
|
||||
{
|
||||
|
@ -154,8 +155,8 @@ int load_pcx(char *pcx,int32_t fsize,int conv_type,char **buffer, ... )
|
|||
tg=va_arg(lst,int);
|
||||
tb=va_arg(lst,int);
|
||||
va_end(lst);
|
||||
palette_shadow(paleta1,(unsigned short (*)[256])ptr1,tr,tg,tb);
|
||||
ptr1+=SHADE_PAL;
|
||||
palette_shadow(paleta1,(unsigned short (*)[256])ptr4,tr,tg,tb);
|
||||
ptr4+=SHADE_PAL;
|
||||
}
|
||||
ysize++;
|
||||
while (--ysize)
|
||||
|
@ -163,13 +164,13 @@ int load_pcx(char *pcx,int32_t fsize,int conv_type,char **buffer, ... )
|
|||
int step;
|
||||
if (conv_type==A_16BIT)
|
||||
{
|
||||
decomprimate_line_hi(ptr3,(unsigned short *)ptr1,paleta2,pcxdata.bytesperline,&step);
|
||||
ptr1+=2*xsize;
|
||||
decomprimate_line_hi(ptr3,(unsigned short *)ptr4,paleta2,pcxdata.bytesperline,&step);
|
||||
ptr4+=2*xsize;
|
||||
}
|
||||
else
|
||||
{
|
||||
decomprimate_line_256(ptr3,ptr1,pcxdata.bytesperline,&step);
|
||||
ptr1+=xsize;
|
||||
decomprimate_line_256(ptr3,ptr4,pcxdata.bytesperline,&step);
|
||||
ptr4+=xsize;
|
||||
}
|
||||
ptr3+=step;
|
||||
}
|
||||
|
|
|
@ -31,9 +31,9 @@ extern "C" {
|
|||
|
||||
|
||||
//returns <0 error, >0 allocated size
|
||||
int load_pcx(char *pcx,int32_t fsize,int conv_type,char **buffer, ... );
|
||||
int load_pcx(const char *pcx,int32_t fsize,int conv_type,char **buffer, ... );
|
||||
int open_pcx(const char *filename,int type,char **buffer,...);
|
||||
void palette_shadow(char *pal1,unsigned short pal2[][256],int tr,int tg,int tb);
|
||||
void palette_shadow(const char *pal1,unsigned short pal2[][256],int tr,int tg,int tb);
|
||||
extern void *get_palette_ptr;
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
#include <stdio.h>
|
||||
#include "wav_mem.h"
|
||||
|
||||
char *find_chunk(char *wav,char *name)
|
||||
const char *find_chunk(const char *wav,char *name) //TODO improve
|
||||
{
|
||||
int32_t next;
|
||||
|
||||
|
@ -18,7 +18,7 @@ char *find_chunk(char *wav,char *name)
|
|||
while (1);
|
||||
}
|
||||
|
||||
int get_chunk_size(char *wav)
|
||||
int get_chunk_size(const char *wav)
|
||||
{
|
||||
int32_t size;
|
||||
|
||||
|
@ -26,7 +26,7 @@ int get_chunk_size(char *wav)
|
|||
return(size);
|
||||
}
|
||||
|
||||
int read_chunk(char *wav,void *mem)
|
||||
int read_chunk(const char *wav,void *mem)
|
||||
{
|
||||
|
||||
wav+=4;
|
||||
|
|
|
@ -12,9 +12,9 @@ typedef struct t_wave
|
|||
int32_t freq,bps;
|
||||
}T_WAVE;
|
||||
|
||||
char *find_chunk(char *wav,char *name);
|
||||
int get_chunk_size(char *wav);
|
||||
int read_chunk(char *wav,void *mem);
|
||||
const char *find_chunk(const char *wav,char *name);
|
||||
int get_chunk_size(const char *wav);
|
||||
int read_chunk(const char *wav,void *mem);
|
||||
|
||||
|
||||
#endif
|
||||
|
|
|
@ -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);
|
||||
void stop_mixing(void);
|
||||
void play_sample(int channel,void *sample,int32_t size,int32_t lstart,int32_t sfreq,int type);
|
||||
void play_sample(int channel,const void *sample,int32_t size,int32_t lstart,int32_t sfreq,int type);
|
||||
void set_channel_volume(int channel,int left,int right);
|
||||
void set_end_of_song_callback(const char * (*cb)(void *), void *ctx);
|
||||
|
||||
|
@ -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,int32_t size_sample); //zrusi loop s moznosti dohrat zvuk
|
||||
void chan_break_ext(int channel,const 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, int32_t *writepos);
|
||||
char LoadNextVideoFrame(void *buffer, const char *data, int size, const short *xlat, short *accnums, int32_t *writepos);
|
||||
void DoneVideoSound(void *buffer);
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue