mirror of
https://github.com/ondra-novak/gates_of_skeldal.git
synced 2025-07-05 06:00:33 -04:00
revision of events
This commit is contained in:
parent
858c4384e8
commit
669f72908e
33 changed files with 661 additions and 382 deletions
|
@ -16,7 +16,7 @@ include_directories(platform libs)
|
||||||
|
|
||||||
|
|
||||||
include_directories( ${SDL2_INCLUDE_DIRS})
|
include_directories( ${SDL2_INCLUDE_DIRS})
|
||||||
add_compile_options(-funsigned-char)
|
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -funsigned-char")
|
||||||
enable_testing()
|
enable_testing()
|
||||||
add_subdirectory(libs)
|
add_subdirectory(libs)
|
||||||
add_subdirectory(platform)
|
add_subdirectory(platform)
|
||||||
|
|
|
@ -42,7 +42,7 @@ HRESULT MusicPlayer::InitBuffer(IDirectSound8 *ds8, int *linvoltable)
|
||||||
wfex.nAvgBytesPerSec=wfex.nSamplesPerSec*wfex.nBlockAlign;
|
wfex.nAvgBytesPerSec=wfex.nSamplesPerSec*wfex.nBlockAlign;
|
||||||
wfex.wFormatTag=WAVE_FORMAT_PCM;
|
wfex.wFormatTag=WAVE_FORMAT_PCM;
|
||||||
wfex.nChannels=2;
|
wfex.nChannels=2;
|
||||||
|
|
||||||
DSBUFFERDESC desc;
|
DSBUFFERDESC desc;
|
||||||
desc.dwSize=sizeof(desc);
|
desc.dwSize=sizeof(desc);
|
||||||
desc.dwBufferBytes=BUFFER_SIZE;
|
desc.dwBufferBytes=BUFFER_SIZE;
|
||||||
|
@ -70,7 +70,7 @@ HRESULT MusicPlayer::Play()
|
||||||
memset(ptr,0,size);
|
memset(ptr,0,size);
|
||||||
_ds8Buffer->Unlock(ptr,size,NULL,NULL);
|
_ds8Buffer->Unlock(ptr,size,NULL,NULL);
|
||||||
_ds8Buffer->SetVolume(_linvoltable[_volume]);
|
_ds8Buffer->SetVolume(_linvoltable[_volume]);
|
||||||
HRESULT res=_ds8Buffer->Play(0,0,DSBPLAY_LOOPING);
|
HRESULT res=_ds8Buffer->Play(0,0,DSBPLAY_LOOPING);
|
||||||
_crossfadebytes=0;
|
_crossfadebytes=0;
|
||||||
_minorpos=0;
|
_minorpos=0;
|
||||||
return res;
|
return res;
|
||||||
|
@ -80,7 +80,7 @@ class AutoCloseCriticalSection
|
||||||
{
|
{
|
||||||
LPCRITICAL_SECTION lcrit;
|
LPCRITICAL_SECTION lcrit;
|
||||||
public:
|
public:
|
||||||
AutoCloseCriticalSection(LPCRITICAL_SECTION l):lcrit(l)
|
AutoCloseCriticalSection(LPCRITICAL_SECTION l):lcrit(l)
|
||||||
{
|
{
|
||||||
EnterCriticalSection(lcrit);
|
EnterCriticalSection(lcrit);
|
||||||
}
|
}
|
||||||
|
@ -91,15 +91,15 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
int MusicPlayer::Open(int samplerate, int numchannels, int bitspersamp, int bufferlenms, int prebufferms)
|
int MusicPlayer::Open(int samplerate, int numchannels, int bitspersamp, int bufferlenms, int prebufferms)
|
||||||
{
|
{
|
||||||
AutoCloseCriticalSection lsect(&_lock);
|
AutoCloseCriticalSection lsect(&_lock);
|
||||||
if (numchannels<1 || numchannels>2) return -1;
|
if (numchannels<1 || numchannels>2) return -1;
|
||||||
if (bitspersamp!=8 && bitspersamp!=16) return -1;
|
if (bitspersamp!=8 && bitspersamp!=16) return -1;
|
||||||
_stereo=numchannels==2;
|
_stereo=numchannels==2;
|
||||||
_bit16=bitspersamp==16;
|
_bit16=bitspersamp==16;
|
||||||
_speed=samplerate*1024/44100;
|
_speed=samplerate*1024/44100;
|
||||||
if (_speed<128) return -1;
|
if (_speed<128) return -1;
|
||||||
_opened=true;
|
_opened=true;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -139,12 +139,12 @@ void MusicPlayer::Close()
|
||||||
{
|
{
|
||||||
DWORD status;
|
DWORD status;
|
||||||
_ds8Buffer->GetStatus(&status);
|
_ds8Buffer->GetStatus(&status);
|
||||||
_ds8Buffer->Play(0,0,DSBPLAY_LOOPING);
|
_ds8Buffer->Play(0,0,DSBPLAY_LOOPING);
|
||||||
EnterCriticalSection(&_lock);
|
EnterCriticalSection(&_lock);
|
||||||
if ((status & DSBSTATUS_PLAYING)==0)
|
if ((status & DSBSTATUS_PLAYING)==0)
|
||||||
_ds8Buffer->Stop();
|
_ds8Buffer->Stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_crossfadebytes==0)
|
if (_crossfadebytes==0)
|
||||||
{
|
{
|
||||||
DWORD xfadepos=GetSafeXFadePos();
|
DWORD xfadepos=GetSafeXFadePos();
|
||||||
|
@ -168,16 +168,16 @@ void MusicPlayer::Close()
|
||||||
_ds8Buffer->Unlock(ptr[0],sz[0],ptr[1],sz[1]);
|
_ds8Buffer->Unlock(ptr[0],sz[0],ptr[1],sz[1]);
|
||||||
}
|
}
|
||||||
_crossfadebytes=xfadesz;
|
_crossfadebytes=xfadesz;
|
||||||
_lastWritePos=xfadepos;
|
_lastWritePos=xfadepos;
|
||||||
}
|
}
|
||||||
_opened=false;
|
_opened=false;
|
||||||
LeaveCriticalSection(&_lock);
|
LeaveCriticalSection(&_lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
int MusicPlayer::Write(const char *buf, int len)
|
int MusicPlayer::Write(const char *buf, int len)
|
||||||
{
|
{
|
||||||
EnterCriticalSection(&_lock);
|
EnterCriticalSection(&_lock);
|
||||||
if (!_opened)
|
if (!_opened)
|
||||||
{
|
{
|
||||||
LeaveCriticalSection(&_lock);
|
LeaveCriticalSection(&_lock);
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -192,7 +192,7 @@ int MusicPlayer::Write(const char *buf, int len)
|
||||||
while (len>0)
|
while (len>0)
|
||||||
{
|
{
|
||||||
short sample[2];
|
short sample[2];
|
||||||
|
|
||||||
if (_bit16)
|
if (_bit16)
|
||||||
if (_stereo)
|
if (_stereo)
|
||||||
{
|
{
|
||||||
|
@ -215,7 +215,7 @@ int MusicPlayer::Write(const char *buf, int len)
|
||||||
sample[0]=(*buf)*256;
|
sample[0]=(*buf)*256;
|
||||||
sample[1]=(*buf)*256;
|
sample[1]=(*buf)*256;
|
||||||
}
|
}
|
||||||
while (remainspace<4)
|
while (remainspace<4)
|
||||||
{
|
{
|
||||||
if (stage<1)
|
if (stage<1)
|
||||||
{
|
{
|
||||||
|
@ -245,7 +245,7 @@ int MusicPlayer::Write(const char *buf, int len)
|
||||||
stage=0;
|
stage=0;
|
||||||
remainspace=locksz[stage];
|
remainspace=locksz[stage];
|
||||||
wrtptr=lockptr[stage];
|
wrtptr=lockptr[stage];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (_crossfadebytes)
|
if (_crossfadebytes)
|
||||||
{
|
{
|
||||||
|
@ -261,7 +261,7 @@ int MusicPlayer::Write(const char *buf, int len)
|
||||||
if (_crossfadebytes<4) _crossfadebytes=0;else _crossfadebytes-=4;
|
if (_crossfadebytes<4) _crossfadebytes=0;else _crossfadebytes-=4;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
memcpy(wrtptr,sample,4);
|
wrtptr = sample;
|
||||||
wrtptr=(void *)((char *)wrtptr+4);
|
wrtptr=(void *)((char *)wrtptr+4);
|
||||||
remainspace-=4;
|
remainspace-=4;
|
||||||
_minorpos+=_speed;
|
_minorpos+=_speed;
|
||||||
|
@ -305,9 +305,9 @@ void MusicPlayer::SetVolume(int volume)
|
||||||
{
|
{
|
||||||
if (volume<0) return;
|
if (volume<0) return;
|
||||||
_ds8Buffer->SetVolume(_linvoltable[volume]);
|
_ds8Buffer->SetVolume(_linvoltable[volume]);
|
||||||
if (volume==0)
|
if (volume==0)
|
||||||
Pause(1);
|
Pause(1);
|
||||||
else
|
else
|
||||||
Pause(0);
|
Pause(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -333,7 +333,7 @@ void MusDecoder::AttachOutput(IWAOutput *o)
|
||||||
bool MusDecoder::Play(const char *filename)
|
bool MusDecoder::Play(const char *filename)
|
||||||
{
|
{
|
||||||
DWORD res=0;
|
DWORD res=0;
|
||||||
if (filename[0]=='?')
|
if (filename[0]=='?')
|
||||||
{
|
{
|
||||||
if (_output->Open(44100,1,8,-1,-1)<0)
|
if (_output->Open(44100,1,8,-1,-1)<0)
|
||||||
{
|
{
|
||||||
|
@ -447,7 +447,7 @@ UINT MusDecoder::SilentWritterThread()
|
||||||
}
|
}
|
||||||
_playing=false;
|
_playing=false;
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
WinAmpDecoder::WinAmpDecoder()
|
WinAmpDecoder::WinAmpDecoder()
|
||||||
|
@ -477,7 +477,7 @@ bool WinAmpDecoder::Play(const char *filename)
|
||||||
{
|
{
|
||||||
_currPlugin=0;
|
_currPlugin=0;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
int playtm=_currPlugin->GetOutputTime();
|
int playtm=_currPlugin->GetOutputTime();
|
||||||
int nexttm=playtm;
|
int nexttm=playtm;
|
||||||
int c=0;
|
int c=0;
|
||||||
|
@ -489,7 +489,7 @@ bool WinAmpDecoder::Play(const char *filename)
|
||||||
|
|
||||||
void WinAmpDecoder::Stop()
|
void WinAmpDecoder::Stop()
|
||||||
{
|
{
|
||||||
if (_currPlugin==0) return;
|
if (_currPlugin==0) return;
|
||||||
_currPlugin->Stop();
|
_currPlugin->Stop();
|
||||||
_currPlugin->AttachOutput(0);
|
_currPlugin->AttachOutput(0);
|
||||||
_currPlugin=0;
|
_currPlugin=0;
|
||||||
|
@ -502,6 +502,6 @@ bool WinAmpDecoder::IsPlaying()
|
||||||
}
|
}
|
||||||
|
|
||||||
void WinAmpDecoder::SetVolume(int volume, int main)
|
void WinAmpDecoder::SetVolume(int volume, int main)
|
||||||
{
|
{
|
||||||
_currPlugin->SetVolume(volume);
|
_currPlugin->SetVolume(volume);
|
||||||
}
|
}
|
||||||
|
|
|
@ -216,7 +216,7 @@ static void error(char *text)
|
||||||
sprintf(buff,"%s v odstavci %d\r\nLocal_pgf=%d / DIALOG : %d / SENTENCE : %d\r\n",text,last_pgf+local_pgf,local_pgf,local_pgf/128,last_pgf);
|
sprintf(buff,"%s v odstavci %d\r\nLocal_pgf=%d / DIALOG : %d / SENTENCE : %d\r\n",text,last_pgf+local_pgf,local_pgf,local_pgf/128,last_pgf);
|
||||||
// MessageBox(NULL,buff,NULL,MB_OK|MB_ICONSTOP|MB_SYSTEMMODAL);
|
// MessageBox(NULL,buff,NULL,MB_OK|MB_ICONSTOP|MB_SYSTEMMODAL);
|
||||||
SEND_LOG("(DIALOGS) Dialog error detected at %d:%d",local_pgf/128,last_pgf);
|
SEND_LOG("(DIALOGS) Dialog error detected at %d:%d",local_pgf/128,last_pgf);
|
||||||
SEND_LOG("(DIALOGS) Error description: %s",text,0);
|
SEND_LOG("(DIALOGS) Error description: %s",text);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void show_dialog_picture()
|
static void show_dialog_picture()
|
||||||
|
@ -906,7 +906,7 @@ static void exit_dialog()
|
||||||
norefresh=0;
|
norefresh=0;
|
||||||
}
|
}
|
||||||
starting_shop=-1;
|
starting_shop=-1;
|
||||||
SEND_LOG("(DIALOGS) Exiting dialog...",0,0);
|
SEND_LOG("(DIALOGS) Exiting dialog...");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -955,7 +955,7 @@ char join_character(int i)
|
||||||
THUMAN *s=postavy_2+i;
|
THUMAN *s=postavy_2+i;
|
||||||
int j;
|
int j;
|
||||||
|
|
||||||
SEND_LOG("(DIALOGS) Joining character '%s'",s->jmeno,0);
|
SEND_LOG("(DIALOGS) Joining character '%s'",s->jmeno);
|
||||||
for(j=0,h=postavy;j<POCET_POSTAV;j++,h++) if (!h->used)
|
for(j=0,h=postavy;j<POCET_POSTAV;j++,h++) if (!h->used)
|
||||||
{
|
{
|
||||||
memcpy(h,s,sizeof(THUMAN));
|
memcpy(h,s,sizeof(THUMAN));
|
||||||
|
@ -966,7 +966,7 @@ char join_character(int i)
|
||||||
bott_draw(1);
|
bott_draw(1);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
SEND_LOG("(DIALOGS) Join failed - no room for new character",0,0);
|
SEND_LOG("(DIALOGS) Join failed - no room for new character");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1335,7 +1335,7 @@ void call_dialog(int entr,int mob)
|
||||||
curcolor=0;
|
curcolor=0;
|
||||||
create_back_pic();
|
create_back_pic();
|
||||||
bar32(0,SCREEN_OFFLINE,639,SCREEN_OFFLINE+359);
|
bar32(0,SCREEN_OFFLINE,639,SCREEN_OFFLINE+359);
|
||||||
SEND_LOG("(DIALOGS) Starting dialog...",0,0);
|
SEND_LOG("(DIALOGS) Starting dialog...");
|
||||||
for(i=0;i<POCET_POSTAV;i++) if (isdemon(postavy+i)) unaffect_demon(i);
|
for(i=0;i<POCET_POSTAV;i++) if (isdemon(postavy+i)) unaffect_demon(i);
|
||||||
mute_all_tracks(0);
|
mute_all_tracks(0);
|
||||||
dialog_mob=mob;
|
dialog_mob=mob;
|
||||||
|
@ -1367,7 +1367,7 @@ char save_dialog_info(TMPFILE_WR *f)
|
||||||
char *c,res=0;
|
char *c,res=0;
|
||||||
T_PARAGRAPH *q;
|
T_PARAGRAPH *q;
|
||||||
|
|
||||||
SEND_LOG("(DIALOGS)(SAVELOAD) Saving dialogs info...",0,0);
|
SEND_LOG("(DIALOGS)(SAVELOAD) Saving dialogs info...");
|
||||||
p=ablock(H_DIALOGY_DAT);
|
p=ablock(H_DIALOGY_DAT);
|
||||||
pgf_pocet=*p;
|
pgf_pocet=*p;
|
||||||
temp_storage_write(&pgf_pocet,1*4,f);
|
temp_storage_write(&pgf_pocet,1*4,f);
|
||||||
|
@ -1387,7 +1387,7 @@ char save_dialog_info(TMPFILE_WR *f)
|
||||||
free(c);
|
free(c);
|
||||||
}
|
}
|
||||||
temp_storage_write(_flag_map,1*sizeof(_flag_map),f);
|
temp_storage_write(_flag_map,1*sizeof(_flag_map),f);
|
||||||
SEND_LOG("(DIALOGS)(SAVELOAD) Done...",0,0);
|
SEND_LOG("(DIALOGS)(SAVELOAD) Done...");
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1399,7 +1399,7 @@ char load_dialog_info(TMPFILE_RD *f)
|
||||||
char *c,res=0;
|
char *c,res=0;
|
||||||
T_PARAGRAPH *q;
|
T_PARAGRAPH *q;
|
||||||
|
|
||||||
SEND_LOG("(DIALOGS)(SAVELOAD) Loading dialogs info...",0,0);
|
SEND_LOG("(DIALOGS)(SAVELOAD) Loading dialogs info...");
|
||||||
p=ablock(H_DIALOGY_DAT);
|
p=ablock(H_DIALOGY_DAT);
|
||||||
aswap(H_DIALOGY_DAT);
|
aswap(H_DIALOGY_DAT);
|
||||||
temp_storage_read(&pgf_pocet,1*4,f);
|
temp_storage_read(&pgf_pocet,1*4,f);
|
||||||
|
@ -1425,6 +1425,6 @@ char load_dialog_info(TMPFILE_RD *f)
|
||||||
free(c);
|
free(c);
|
||||||
}
|
}
|
||||||
res|=(temp_storage_read(_flag_map,1*sizeof(_flag_map),f)!=sizeof(_flag_map));
|
res|=(temp_storage_read(_flag_map,1*sizeof(_flag_map),f)!=sizeof(_flag_map));
|
||||||
SEND_LOG("(DIALOGS)(SAVELOAD) Done...",0,0);
|
SEND_LOG("(DIALOGS)(SAVELOAD) Done...");
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,10 +46,10 @@ void save_dump(const uint16_t *screen_addr,
|
||||||
|
|
||||||
if (dump_counter == -1) {
|
if (dump_counter == -1) {
|
||||||
dump_counter = findMaxDumpNumber(".");
|
dump_counter = findMaxDumpNumber(".");
|
||||||
SEND_LOG("(DUMP) Dump counter sets to %d", dump_counter, 0);
|
SEND_LOG("(DUMP) Dump counter sets to %d", dump_counter);
|
||||||
}
|
}
|
||||||
sprintf(c, "dump%04d.bmp", ++dump_counter);
|
sprintf(c, "dump%04d.bmp", ++dump_counter);
|
||||||
SEND_LOG("(DUMP) Saving screen shot named '%s'", c, 0);
|
SEND_LOG("(DUMP) Saving screen shot named '%s'", c);
|
||||||
f = fopen(c, "wb");
|
f = fopen(c, "wb");
|
||||||
fputc('B', f);
|
fputc('B', f);
|
||||||
fputc('M', f);
|
fputc('M', f);
|
||||||
|
|
|
@ -1249,7 +1249,7 @@ void mob_check_death(int num,TMOB *p)
|
||||||
mob_dostal=0;
|
mob_dostal=0;
|
||||||
bott_draw(0);
|
bott_draw(0);
|
||||||
if (p->lives>0) return;
|
if (p->lives>0) return;
|
||||||
SEND_LOG("(GAME) Monster killed ... '%s'",p->name,0);
|
SEND_LOG("(GAME) Monster killed ... '%s'",p->name);
|
||||||
sect=p->sector;
|
sect=p->sector;
|
||||||
p->vlajky&=~MOB_IN_BATTLE & ~MOB_LIVE;
|
p->vlajky&=~MOB_IN_BATTLE & ~MOB_LIVE;
|
||||||
free_path(num);
|
free_path(num);
|
||||||
|
|
|
@ -84,7 +84,7 @@ static int unable_open_temp(char *c)
|
||||||
concat(e,d,c);
|
concat(e,d,c);
|
||||||
closemode();
|
closemode();
|
||||||
display_error(e);
|
display_error(e);
|
||||||
SEND_LOG("(SAVELOAD) Open temp error detected (%s)",c,0);
|
SEND_LOG("(SAVELOAD) Open temp error detected (%s)",c);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -95,7 +95,7 @@ static void unable_write_temp(char *c)
|
||||||
concat(e,d,c);
|
concat(e,d,c);
|
||||||
closemode();
|
closemode();
|
||||||
display_error(e);
|
display_error(e);
|
||||||
SEND_LOG("(SAVELOAD) Open temp error detected (%s)",c,0);
|
SEND_LOG("(SAVELOAD) Open temp error detected (%s)",c);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -348,7 +348,7 @@ int save_map_state() //uklada stav mapy pro savegame (neuklada aktualni pozici);
|
||||||
restore_sound_names();
|
restore_sound_names();
|
||||||
strcpy(sta,level_fname);
|
strcpy(sta,level_fname);
|
||||||
fsta=temp_storage_create(sta);if (fsta==NULL) unable_open_temp(sta);
|
fsta=temp_storage_create(sta);if (fsta==NULL) unable_open_temp(sta);
|
||||||
SEND_LOG("(SAVELOAD) Saving map state for current map",0,0);
|
SEND_LOG("(SAVELOAD) Saving map state for current map");
|
||||||
if (load_org_map(level_fname,&org_sides,&org_sectors,NULL,NULL)) goto err;
|
if (load_org_map(level_fname,&org_sides,&org_sectors,NULL,NULL)) goto err;
|
||||||
siz=(mapsize+7)/8;
|
siz=(mapsize+7)/8;
|
||||||
bf=(char *)getmem(siz);
|
bf=(char *)getmem(siz);
|
||||||
|
@ -400,7 +400,7 @@ int save_map_state() //uklada stav mapy pro savegame (neuklada aktualni pozici);
|
||||||
save_enemy_paths(fsta);
|
save_enemy_paths(fsta);
|
||||||
res=0;
|
res=0;
|
||||||
err:
|
err:
|
||||||
SEND_LOG("(SAVELOAD) State of current map saved (err:%d)",res,0);
|
SEND_LOG("(SAVELOAD) State of current map saved (err:%d)",res);
|
||||||
temp_storage_close_wr(fsta);
|
temp_storage_close_wr(fsta);
|
||||||
free(org_sectors);
|
free(org_sectors);
|
||||||
free(org_sides);
|
free(org_sides);
|
||||||
|
@ -430,7 +430,7 @@ int load_map_state() //obnovuje stav mapy; nutno volat po zavolani load_map;
|
||||||
if (ver>STATE_CUR_VER) goto err;
|
if (ver>STATE_CUR_VER) goto err;
|
||||||
if (!temp_storage_read(&i,sizeof(mapsize)*1,fsta)) goto err;
|
if (!temp_storage_read(&i,sizeof(mapsize)*1,fsta)) goto err;
|
||||||
if (mapsize!=i) goto err;
|
if (mapsize!=i) goto err;
|
||||||
SEND_LOG("(SAVELOAD) Loading map state for current map",0,0);
|
SEND_LOG("(SAVELOAD) Loading map state for current map");
|
||||||
temp_storage_read(&siz,1*sizeof(siz),fsta);
|
temp_storage_read(&siz,1*sizeof(siz),fsta);
|
||||||
bf=(char *)getmem(siz);
|
bf=(char *)getmem(siz);
|
||||||
if (!temp_storage_read(bf,siz*1,fsta)) goto err;
|
if (!temp_storage_read(bf,siz*1,fsta)) goto err;
|
||||||
|
@ -483,7 +483,7 @@ int load_map_state() //obnovuje stav mapy; nutno volat po zavolani load_map;
|
||||||
res|=load_all_fly(fsta);
|
res|=load_all_fly(fsta);
|
||||||
res|=load_enemy_paths(fsta);
|
res|=load_enemy_paths(fsta);
|
||||||
err:
|
err:
|
||||||
SEND_LOG("(SAVELOAD) State of current map loaded (err:%d)",res,0);
|
SEND_LOG("(SAVELOAD) State of current map loaded (err:%d)",res);
|
||||||
temp_storage_close_rd(fsta);
|
temp_storage_close_rd(fsta);
|
||||||
free(bf);
|
free(bf);
|
||||||
return res;
|
return res;
|
||||||
|
@ -493,7 +493,7 @@ void restore_current_map() //pouze obnovuje ulozeny stav aktualni mapy
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
SEND_LOG("(SAVELOAD) Restore map...",0,0);
|
SEND_LOG("(SAVELOAD) Restore map...");
|
||||||
kill_all_sounds();
|
kill_all_sounds();
|
||||||
for(i=0;i<mapsize;i++) map_coord[i].flags&=~0x7f; //vynuluj flags_info
|
for(i=0;i<mapsize;i++) map_coord[i].flags&=~0x7f; //vynuluj flags_info
|
||||||
free(map_sides); //uvolni informace o stenach
|
free(map_sides); //uvolni informace o stenach
|
||||||
|
@ -530,7 +530,7 @@ int pack_status_file(FILE *f,const char *status_name)
|
||||||
char *buffer,*c;
|
char *buffer,*c;
|
||||||
unsigned char name_len;
|
unsigned char name_len;
|
||||||
|
|
||||||
SEND_LOG("(SAVELOAD) Packing status file '%s'",status_name,0);
|
SEND_LOG("(SAVELOAD) Packing status file '%s'",status_name);
|
||||||
fsz = temp_storage_find(status_name);
|
fsz = temp_storage_find(status_name);
|
||||||
if (fsz < 0) return 2;
|
if (fsz < 0) return 2;
|
||||||
name_len = (unsigned char)strlen(status_name);
|
name_len = (unsigned char)strlen(status_name);
|
||||||
|
@ -561,7 +561,7 @@ int unpack_status_file(FILE *f)
|
||||||
fread(&namelen, 1,1, f);
|
fread(&namelen, 1,1, f);
|
||||||
if (namelen == 0) return -1;
|
if (namelen == 0) return -1;
|
||||||
fread(name, 1, namelen, f);
|
fread(name, 1, namelen, f);
|
||||||
SEND_LOG("(SAVELOAD) Unpacking status file '%s'",name,0);
|
SEND_LOG("(SAVELOAD) Unpacking status file '%s'",name);
|
||||||
fread(&fsz,1,4,f);
|
fread(&fsz,1,4,f);
|
||||||
buffer=(char *)getmem(fsz);
|
buffer=(char *)getmem(fsz);
|
||||||
if (fread(buffer,1,fsz,f)!=(unsigned)fsz) return 1;
|
if (fread(buffer,1,fsz,f)!=(unsigned)fsz) return 1;
|
||||||
|
@ -602,7 +602,7 @@ int save_basic_info()
|
||||||
char res=0;
|
char res=0;
|
||||||
THUMAN *h;
|
THUMAN *h;
|
||||||
|
|
||||||
SEND_LOG("(SAVELOAD) Saving basic info for game (file:%s)",_GAME_ST ,0);
|
SEND_LOG("(SAVELOAD) Saving basic info for game (file:%s)",_GAME_ST );
|
||||||
f=temp_storage_create(_GAME_ST);
|
f=temp_storage_create(_GAME_ST);
|
||||||
if (f==NULL) return 1;
|
if (f==NULL) return 1;
|
||||||
s.viewsector=viewsector;
|
s.viewsector=viewsector;
|
||||||
|
@ -646,7 +646,7 @@ int save_basic_info()
|
||||||
temp_storage_write(h->demon_save,sizeof(THUMAN)*1,f); //ulozeni polozek s demony
|
temp_storage_write(h->demon_save,sizeof(THUMAN)*1,f); //ulozeni polozek s demony
|
||||||
res|=save_dialog_info(f);
|
res|=save_dialog_info(f);
|
||||||
temp_storage_close_wr(f);
|
temp_storage_close_wr(f);
|
||||||
SEND_LOG("(SAVELOAD) Done... Result: %d",res,0);
|
SEND_LOG("(SAVELOAD) Done... Result: %d",res);
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -659,7 +659,7 @@ int load_basic_info()
|
||||||
TITEM *itg;
|
TITEM *itg;
|
||||||
THUMAN *h;
|
THUMAN *h;
|
||||||
|
|
||||||
SEND_LOG("(SAVELOAD) Loading basic info for game (file:%s)",_GAME_ST,0);
|
SEND_LOG("(SAVELOAD) Loading basic info for game (file:%s)",_GAME_ST);
|
||||||
f=temp_storage_open(_GAME_ST);
|
f=temp_storage_open(_GAME_ST);
|
||||||
if (f==NULL) return 1;
|
if (f==NULL) return 1;
|
||||||
res|=(temp_storage_read(&s,1*sizeof(s),f)!=sizeof(s));
|
res|=(temp_storage_read(&s,1*sizeof(s),f)!=sizeof(s));
|
||||||
|
@ -726,7 +726,7 @@ int load_basic_info()
|
||||||
}
|
}
|
||||||
else load_another=0;
|
else load_another=0;
|
||||||
for(i=0;i<POCET_POSTAV;i++) postavy[i].dostal=0;
|
for(i=0;i<POCET_POSTAV;i++) postavy[i].dostal=0;
|
||||||
SEND_LOG("(SAVELOAD) Done... Result: %d",res,0);
|
SEND_LOG("(SAVELOAD) Done... Result: %d",res);
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -766,7 +766,7 @@ int save_game(int slotnum,char *gamename)
|
||||||
FILE *svf;
|
FILE *svf;
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
SEND_LOG("(SAVELOAD) Saving game slot %d",slotnum,0);
|
SEND_LOG("(SAVELOAD) Saving game slot %d",slotnum);
|
||||||
save_map_state();
|
save_map_state();
|
||||||
concat(sn,pathtable[SR_SAVES],_SLOT_SAV);
|
concat(sn,pathtable[SR_SAVES],_SLOT_SAV);
|
||||||
MakeSaveGameDir(pathtable[SR_SAVES]);
|
MakeSaveGameDir(pathtable[SR_SAVES]);
|
||||||
|
@ -793,7 +793,7 @@ int save_game(int slotnum,char *gamename)
|
||||||
open_story_file();
|
open_story_file();
|
||||||
fclose(svf);
|
fclose(svf);
|
||||||
}
|
}
|
||||||
SEND_LOG("(SAVELOAD) Game saved.... Result %d",r,0);
|
SEND_LOG("(SAVELOAD) Game saved.... Result %d",r);
|
||||||
disable_intro();
|
disable_intro();
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
@ -806,7 +806,7 @@ int load_game(int slotnum)
|
||||||
FILE *svf;
|
FILE *svf;
|
||||||
int r,t;
|
int r,t;
|
||||||
|
|
||||||
SEND_LOG("(SAVELOAD) Loading game slot %d",slotnum,0);
|
SEND_LOG("(SAVELOAD) Loading game slot %d",slotnum);
|
||||||
if (battle) konec_kola();
|
if (battle) konec_kola();
|
||||||
battle=0;
|
battle=0;
|
||||||
close_story_file();
|
close_story_file();
|
||||||
|
@ -822,7 +822,7 @@ int load_game(int slotnum)
|
||||||
open_story_file();
|
open_story_file();
|
||||||
if (r>0)
|
if (r>0)
|
||||||
{
|
{
|
||||||
SEND_LOG("(ERROR) Error detected during unpacking game... Loading stopped (result:%d)",r,0);
|
SEND_LOG("(ERROR) Error detected during unpacking game... Loading stopped (result:%d)",r);
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
load_book();
|
load_book();
|
||||||
|
@ -838,7 +838,7 @@ int load_game(int slotnum)
|
||||||
norefresh=1;
|
norefresh=1;
|
||||||
}
|
}
|
||||||
for(t=0;t<POCET_POSTAV;t++) postavy[t].zvolene_akce=NULL;
|
for(t=0;t<POCET_POSTAV;t++) postavy[t].zvolene_akce=NULL;
|
||||||
SEND_LOG("(SAVELOAD) Game loaded.... Result %d",r,0);
|
SEND_LOG("(SAVELOAD) Game loaded.... Result %d",r);
|
||||||
// if (GetKeyState(VK_CONTROL) & 0x80) correct_level();
|
// if (GetKeyState(VK_CONTROL) & 0x80) correct_level();
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
@ -1422,7 +1422,7 @@ void open_story_file()
|
||||||
{
|
{
|
||||||
|
|
||||||
story=temp_storage_append(STORY_BOOK);
|
story=temp_storage_append(STORY_BOOK);
|
||||||
SEND_LOG("(STORY) Story temp file is opened....",0,0);
|
SEND_LOG("(STORY) Story temp file is opened....");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1437,7 +1437,7 @@ void close_story_file()
|
||||||
{
|
{
|
||||||
if (story!=NULL) temp_storage_close_wr(story);
|
if (story!=NULL) temp_storage_close_wr(story);
|
||||||
story=NULL;
|
story=NULL;
|
||||||
SEND_LOG("(STORY) Story temp file is closed...",0,0);
|
SEND_LOG("(STORY) Story temp file is closed...");
|
||||||
}
|
}
|
||||||
|
|
||||||
static int load_map_state_partial(char *level_fname,int mapsize) //obnovuje stav mapy; castecne
|
static int load_map_state_partial(char *level_fname,int mapsize) //obnovuje stav mapy; castecne
|
||||||
|
|
|
@ -248,7 +248,7 @@ void message_keyboard(EVENT_MSG *msg,void **user_ptr)
|
||||||
|
|
||||||
case E_DONE:c = *user_ptr;
|
case E_DONE:c = *user_ptr;
|
||||||
free(c);
|
free(c);
|
||||||
user_ptr = NULL;
|
*user_ptr = NULL;
|
||||||
break;
|
break;
|
||||||
case E_KEYBOARD:
|
case E_KEYBOARD:
|
||||||
{
|
{
|
||||||
|
@ -274,7 +274,6 @@ void message_keyboard(EVENT_MSG *msg,void **user_ptr)
|
||||||
|
|
||||||
int message(int butts,char def,char canc,char *keys,...)
|
int message(int butts,char def,char canc,char *keys,...)
|
||||||
{
|
{
|
||||||
char **texty;
|
|
||||||
int id;
|
int id;
|
||||||
void *clksav;int clksav2;
|
void *clksav;int clksav2;
|
||||||
|
|
||||||
|
@ -284,8 +283,13 @@ int message(int butts,char def,char canc,char *keys,...)
|
||||||
unwire_proc();
|
unwire_proc();
|
||||||
save_click_map(&clksav,&clksav2);
|
save_click_map(&clksav,&clksav2);
|
||||||
change_click_map(NULL,0);
|
change_click_map(NULL,0);
|
||||||
texty=(char **)(&keys+1);
|
va_list args;
|
||||||
open_message_win(butts+1,texty);
|
va_start(args, keys);
|
||||||
|
char **texts = (char **)alloca((butts+1)*sizeof(char *));
|
||||||
|
for (int i = 0; i < butts+1; ++i) {
|
||||||
|
texts[i] = va_arg(args,char *);
|
||||||
|
}
|
||||||
|
open_message_win(butts+1,texts);
|
||||||
send_message(E_ADD,E_KEYBOARD,message_keyboard,keys);
|
send_message(E_ADD,E_KEYBOARD,message_keyboard,keys);
|
||||||
escape();
|
escape();
|
||||||
id=o_aktual->id;
|
id=o_aktual->id;
|
||||||
|
@ -1393,7 +1397,7 @@ int load_string_list_ex(TSTR_LIST *list,char *filename)
|
||||||
if (j==';') while ((j=temp_storage_getc(f))!='\n' && j!=EOF);
|
if (j==';') while ((j=temp_storage_getc(f))!='\n' && j!=EOF);
|
||||||
if (j=='\n') lin++;
|
if (j=='\n') lin++;
|
||||||
}
|
}
|
||||||
while (j=='\n');
|
while (j=='\n' || j == '\r');
|
||||||
temp_storage_ungetc(f);
|
temp_storage_ungetc(f);
|
||||||
j=temp_storage_scanf(f,"%d",&i);
|
j=temp_storage_scanf(f,"%d",&i);
|
||||||
if (j==EOF)
|
if (j==EOF)
|
||||||
|
@ -1414,7 +1418,12 @@ int load_string_list_ex(TSTR_LIST *list,char *filename)
|
||||||
enc_close(f);
|
enc_close(f);
|
||||||
return lin;
|
return lin;
|
||||||
}
|
}
|
||||||
p=strchr(c,'\n');if (p!=NULL) *p=0;
|
|
||||||
|
p=strchr(c,0);
|
||||||
|
while (p > c && isspace(p[-1])) {
|
||||||
|
--p;
|
||||||
|
*p = 0;
|
||||||
|
}
|
||||||
for(p=c;*p;p++) *p=*p=='|'?'\n':*p;
|
for(p=c;*p;p++) *p=*p=='|'?'\n':*p;
|
||||||
if (str_replace(list,i,c)==NULL)
|
if (str_replace(list,i,c)==NULL)
|
||||||
{
|
{
|
||||||
|
|
80
game/inv.c
80
game/inv.c
|
@ -1103,7 +1103,7 @@ void real_regeneration()
|
||||||
if (sleep_ticks>MAX_SLEEP) sleep_ticks=MAX_SLEEP;
|
if (sleep_ticks>MAX_SLEEP) sleep_ticks=MAX_SLEEP;
|
||||||
tick_tack(1);
|
tick_tack(1);
|
||||||
TimerEvents(viewsector,viewdir,game_time);
|
TimerEvents(viewsector,viewdir,game_time);
|
||||||
SEND_LOG("(GAME) Tick Tack, Game time: %d",game_time,0);
|
SEND_LOG("(GAME) Tick Tack, Game time: %d",game_time);
|
||||||
GlobEvent(MAGLOB_ONROUND,viewsector,viewdir);
|
GlobEvent(MAGLOB_ONROUND,viewsector,viewdir);
|
||||||
bott_draw(0);
|
bott_draw(0);
|
||||||
}
|
}
|
||||||
|
@ -2263,7 +2263,7 @@ void build_fly_map()
|
||||||
if (!counter)
|
if (!counter)
|
||||||
SEND_LOG("(FLY) Fly_map was reduced - capacity: %d flies in game / was: %d",fly_count,fly_map_size);
|
SEND_LOG("(FLY) Fly_map was reduced - capacity: %d flies in game / was: %d",fly_count,fly_map_size);
|
||||||
else
|
else
|
||||||
SEND_LOG("(FLY) Fly_map was expanded - capacity: %d flies in game ",fly_count,fly_map_size);
|
SEND_LOG("(FLY) Fly_map was expanded - capacity: %d flies in game / was: %d",fly_count,fly_map_size);
|
||||||
counter=1000;
|
counter=1000;
|
||||||
fly_map_size=fly_count;
|
fly_map_size=fly_count;
|
||||||
}
|
}
|
||||||
|
@ -2416,26 +2416,70 @@ static void shop_mouse_event(EVENT_MSG *msg,void **unused)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static __inline void copy_data(char **src, void *target, int size) {
|
||||||
|
memcpy(target, *src, size);
|
||||||
|
(*src)+=size;
|
||||||
|
}
|
||||||
|
|
||||||
|
static char * load_TSHOP(char *binary, TSHOP *target) {
|
||||||
|
copy_data(&binary, target->keeper, 16);
|
||||||
|
copy_data(&binary, target->picture, 13);
|
||||||
|
copy_data(&binary, &target->koef, 4);
|
||||||
|
copy_data(&binary, &target->products, 4);
|
||||||
|
copy_data(&binary, &target->shop_id, 4);
|
||||||
|
copy_data(&binary, &target->list_size, 4);
|
||||||
|
copy_data(&binary, &target->spec_max, 2);
|
||||||
|
copy_data(&binary, &target->list, 4);
|
||||||
|
return binary;
|
||||||
|
}
|
||||||
|
|
||||||
|
static char * load_TPRODUCT(char *binary, TPRODUCT *target) {
|
||||||
|
copy_data(&binary, &target->item, 2);
|
||||||
|
copy_data(&binary, &target->cena, 4);
|
||||||
|
copy_data(&binary, &target->trade_flags, 2);
|
||||||
|
copy_data(&binary, &target->pocet, 4);
|
||||||
|
copy_data(&binary, &target->max_pocet, 4);
|
||||||
|
return binary;
|
||||||
|
}
|
||||||
|
|
||||||
static void rebuild_shops(void)
|
static void rebuild_shops(void)
|
||||||
{
|
{
|
||||||
char *c=(char *)shop_hacek;
|
char *c=(char *)shop_hacek;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
SEND_LOG("(SHOP) Rebuilding shops....",0,0);
|
SEND_LOG("(SHOP) Rebuilding shops....");
|
||||||
if (shop_list!=NULL) free(shop_list);
|
if (shop_list!=NULL) free(shop_list);
|
||||||
shop_list=NewArr(TSHOP *,max_shops);
|
shop_list=NewArr(TSHOP *,max_shops);
|
||||||
c+=4;
|
c+=4;
|
||||||
for(i=0;i<max_shops;i++)
|
char *d = c;
|
||||||
{
|
size_t reqsize = 0;
|
||||||
TSHOP *p;
|
for(i=0;i<max_shops;i++) {
|
||||||
|
TSHOP s;
|
||||||
|
d = load_TSHOP(d, &s);
|
||||||
|
reqsize += sizeof(TSHOP);
|
||||||
|
for (int j = 0; j < s.products; ++j) {
|
||||||
|
TPRODUCT p;
|
||||||
|
d = load_TPRODUCT(d, &p);
|
||||||
|
reqsize += sizeof(TPRODUCT);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
char *newhacek = getmem(reqsize);
|
||||||
|
TPRODUCT *products = (TPRODUCT *)(newhacek+max_shops*sizeof(TSHOP));
|
||||||
|
TSHOP *shops = (TSHOP *)newhacek;
|
||||||
|
for(i=0;i<max_shops;i++) {
|
||||||
|
c = load_TSHOP(c, shops+i);
|
||||||
|
shops[i].list = products;
|
||||||
|
for (int j = 0; j < shops[i].products; ++j) {
|
||||||
|
c = load_TPRODUCT(c, products);
|
||||||
|
products++;
|
||||||
|
}
|
||||||
|
shop_list[i] = shops+i;
|
||||||
|
SEND_LOG("(SHOP) Shop found: '%s', products %d",shops[i].keeper,shops[i].products);
|
||||||
|
}
|
||||||
|
free(shop_hacek);
|
||||||
|
shop_hacek = newhacek;
|
||||||
|
|
||||||
shop_list[i]=(TSHOP *)c;
|
|
||||||
p=shop_list[i];
|
|
||||||
c+=sizeof(TSHOP);
|
|
||||||
p->list=(TPRODUCT *)c;
|
|
||||||
c+=p->products*sizeof(TPRODUCT);
|
|
||||||
SEND_LOG("(SHOP) Shop found: '%s'",p->keeper,0);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void load_shops(void)
|
void load_shops(void)
|
||||||
|
@ -2844,7 +2888,7 @@ void enter_shop(int shopid)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
SEND_LOG("(SHOP) Entering shop...",0,0);
|
SEND_LOG("(SHOP) Entering shop...");
|
||||||
for(i=0;i<POCET_POSTAV;i++) if (isdemon(postavy+i)) unaffect_demon(i);
|
for(i=0;i<POCET_POSTAV;i++) if (isdemon(postavy+i)) unaffect_demon(i);
|
||||||
for(i=0;i<POCET_POSTAV && postavy[i].sektor!=viewsector;i++);
|
for(i=0;i<POCET_POSTAV && postavy[i].sektor!=viewsector;i++);
|
||||||
if (i==POCET_POSTAV) return; //nesmysl, nemelo by nikdy nastat.
|
if (i==POCET_POSTAV) return; //nesmysl, nemelo by nikdy nastat.
|
||||||
|
@ -2922,7 +2966,7 @@ char shop_change_player(int id, int xa, int ya,int xr,int yr)
|
||||||
char _exit_shop(int id, int xa, int ya,int xr,int yr)
|
char _exit_shop(int id, int xa, int ya,int xr,int yr)
|
||||||
{
|
{
|
||||||
xr,yr,xa,ya,id;
|
xr,yr,xa,ya,id;
|
||||||
SEND_LOG("(SHOP) Exiting shop...",0,0);
|
SEND_LOG("(SHOP) Exiting shop...");
|
||||||
if (cur_owner==-1)
|
if (cur_owner==-1)
|
||||||
{
|
{
|
||||||
free(picked_item);
|
free(picked_item);
|
||||||
|
@ -2941,7 +2985,7 @@ static void reroll_shop(TSHOP *p)
|
||||||
int poc_spec=0;
|
int poc_spec=0;
|
||||||
TPRODUCT *pr;
|
TPRODUCT *pr;
|
||||||
|
|
||||||
SEND_LOG("(SHOP) Shops reroll: '%s' ",p->keeper,0);
|
SEND_LOG("(SHOP) Shops reroll: '%s' ",p->keeper);
|
||||||
pr=p->list;
|
pr=p->list;
|
||||||
for(i=0;i<p->list_size;i++,pr++)
|
for(i=0;i<p->list_size;i++,pr++)
|
||||||
{
|
{
|
||||||
|
@ -2973,7 +3017,7 @@ char save_shops()
|
||||||
TMPFILE_WR *f;
|
TMPFILE_WR *f;
|
||||||
int res=0;
|
int res=0;
|
||||||
|
|
||||||
SEND_LOG("(SHOP) Saving shops...",0,0);
|
SEND_LOG("(SHOP) Saving shops...");
|
||||||
if (max_shops==0 || shop_hacek==NULL) return 0;
|
if (max_shops==0 || shop_hacek==NULL) return 0;
|
||||||
f = temp_storage_create(_SHOP_ST);
|
f = temp_storage_create(_SHOP_ST);
|
||||||
if (f==NULL) return 1;
|
if (f==NULL) return 1;
|
||||||
|
@ -2991,7 +3035,7 @@ char load_saved_shops()
|
||||||
int res=0;
|
int res=0;
|
||||||
int i=0,j=0;
|
int i=0,j=0;
|
||||||
|
|
||||||
SEND_LOG("(SHOP) Loading saved shops...",0,0);
|
SEND_LOG("(SHOP) Loading saved shops...");
|
||||||
f=temp_storage_open(_SHOP_ST);
|
f=temp_storage_open(_SHOP_ST);
|
||||||
if (f==NULL) return 0;
|
if (f==NULL) return 0;
|
||||||
temp_storage_read(&i,1*sizeof(max_shops),f);
|
temp_storage_read(&i,1*sizeof(max_shops),f);
|
||||||
|
|
|
@ -190,10 +190,10 @@ static void play_anim(va_list args) //tasked animation
|
||||||
|
|
||||||
if (running_anm)
|
if (running_anm)
|
||||||
{
|
{
|
||||||
SEND_LOG("(ERROR)(ANIM) Animation's mutex is already in use!",0,0);
|
SEND_LOG("(ERROR)(ANIM) Animation's mutex is already in use!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
SEND_LOG("(ANIM) Running animation number %xh",block,0);
|
|
||||||
anim_render_buffer=getmem(ANIM_SIZE);
|
anim_render_buffer=getmem(ANIM_SIZE);
|
||||||
mgif_install_proc(animace_kouzla);
|
mgif_install_proc(animace_kouzla);
|
||||||
running_anm=1;
|
running_anm=1;
|
||||||
|
@ -202,7 +202,7 @@ static void play_anim(va_list args) //tasked animation
|
||||||
alock(block);
|
alock(block);
|
||||||
anm=open_mgif(ablock(block));
|
anm=open_mgif(ablock(block));
|
||||||
c=0;
|
c=0;
|
||||||
SEND_LOG("(ANIM) Buffer is now ready...",0,0);
|
SEND_LOG("(ANIM) Buffer is now ready...");
|
||||||
while (anm!=NULL)
|
while (anm!=NULL)
|
||||||
{
|
{
|
||||||
task_wait_event(E_KOUZLO_ANM);
|
task_wait_event(E_KOUZLO_ANM);
|
||||||
|
@ -215,7 +215,7 @@ static void play_anim(va_list args) //tasked animation
|
||||||
close_mgif();
|
close_mgif();
|
||||||
running_anm=0;
|
running_anm=0;
|
||||||
free(anim_render_buffer);
|
free(anim_render_buffer);
|
||||||
SEND_LOG("(ANIM) Closing animation %xh",block,0);
|
|
||||||
aunlock(block);
|
aunlock(block);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -617,7 +617,7 @@ static void unaffect_after_demon(int cil)
|
||||||
char a;
|
char a;
|
||||||
TKOUZLO *spl;
|
TKOUZLO *spl;
|
||||||
|
|
||||||
SEND_LOG("(SPELLS) Unaffecting after demon...",0,0);
|
SEND_LOG("(SPELLS) Unaffecting after demon...");
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
a=0;
|
a=0;
|
||||||
|
@ -657,7 +657,7 @@ void spell_end(int num,int ccil,int owner)
|
||||||
unaffect_after_demon(ccil);
|
unaffect_after_demon(ccil);
|
||||||
zmena_demona(cil,owner,0);
|
zmena_demona(cil,owner,0);
|
||||||
_flag_map[num]&=~SPL_DEMON;
|
_flag_map[num]&=~SPL_DEMON;
|
||||||
SEND_LOG("(SPELLS) Spell 'Demon' has ended...",0,0);
|
SEND_LOG("(SPELLS) Spell 'Demon' has ended...");
|
||||||
}
|
}
|
||||||
postavy[cil].stare_vls[VLS_KOUZLA]&=~_flag_map[num];
|
postavy[cil].stare_vls[VLS_KOUZLA]&=~_flag_map[num];
|
||||||
if (cil>=0 && cil<POCET_POSTAV)
|
if (cil>=0 && cil<POCET_POSTAV)
|
||||||
|
@ -682,7 +682,7 @@ void spell_end(int num,int ccil,int owner)
|
||||||
l=_flag_map[num];
|
l=_flag_map[num];
|
||||||
_flag_map[num]=0;
|
_flag_map[num]=0;
|
||||||
if (l>0xffff) spell_end_global();
|
if (l>0xffff) spell_end_global();
|
||||||
SEND_LOG("(SPELLS) Spell ID %d ends.",num,0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void spell_demon(int num,TKOUZLO *spl,int cil,int demon)
|
static void spell_demon(int num,TKOUZLO *spl,int cil,int demon)
|
||||||
|
@ -1394,7 +1394,7 @@ void call_spell(int i)
|
||||||
unsigned char ext=0;
|
unsigned char ext=0;
|
||||||
int cil;
|
int cil;
|
||||||
|
|
||||||
SEND_LOG("(SPELLS) Calculating spell ID: %d",i,0);
|
|
||||||
p=spell_table[i];
|
p=spell_table[i];
|
||||||
if (p==NULL) return;
|
if (p==NULL) return;
|
||||||
cil=p->cil;
|
cil=p->cil;
|
||||||
|
@ -1485,7 +1485,7 @@ int add_spell(int num,int cil,int owner,char noanim)
|
||||||
int accnum;
|
int accnum;
|
||||||
char time_acc=1;
|
char time_acc=1;
|
||||||
|
|
||||||
SEND_LOG("(SPELLS) Casting spell number %d",num,0);
|
|
||||||
alock(H_KOUZLA);
|
alock(H_KOUZLA);
|
||||||
q=(TKOUZLO *)ablock(H_KOUZLA)+num;
|
q=(TKOUZLO *)ablock(H_KOUZLA)+num;
|
||||||
accnum=q->accnum;
|
accnum=q->accnum;
|
||||||
|
@ -1500,7 +1500,7 @@ int add_spell(int num,int cil,int owner,char noanim)
|
||||||
if (i==MAX_SPELLS) i=nl;
|
if (i==MAX_SPELLS) i=nl;
|
||||||
if (i==-1)
|
if (i==-1)
|
||||||
{
|
{
|
||||||
SEND_LOG("(ERROR) Too many spells in game!",0,0);
|
SEND_LOG("(ERROR) Too many spells in game!");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if (spell_table[i]!=NULL)
|
if (spell_table[i]!=NULL)
|
||||||
|
@ -1636,7 +1636,7 @@ void cast(int num,THUMAN *p,int owner, char backfire)
|
||||||
|
|
||||||
SEND_LOG("(SPELLS) Cast num %d cil %d",num2,cil);
|
SEND_LOG("(SPELLS) Cast num %d cil %d",num2,cil);
|
||||||
k=((TKOUZLO *)ablock(H_KOUZLA))+num2;
|
k=((TKOUZLO *)ablock(H_KOUZLA))+num2;
|
||||||
SEND_LOG("(SPELLS) Cast spell name %s",k->spellname,0);
|
|
||||||
|
|
||||||
if (cil>0 && k->cil!=C_postava_jinde)
|
if (cil>0 && k->cil!=C_postava_jinde)
|
||||||
{
|
{
|
||||||
|
@ -1711,7 +1711,7 @@ void cast(int num,THUMAN *p,int owner, char backfire)
|
||||||
if (p->mana>p->mana_battery)
|
if (p->mana>p->mana_battery)
|
||||||
{
|
{
|
||||||
if (p->mana_battery>=0)p->mana=p->mana_battery;
|
if (p->mana_battery>=0)p->mana=p->mana_battery;
|
||||||
else SEND_LOG("(ERROR) Mana battery error on character %d",p-postavy,0);
|
else
|
||||||
p->mana_battery=32767;
|
p->mana_battery=32767;
|
||||||
}
|
}
|
||||||
end:
|
end:
|
||||||
|
@ -1821,7 +1821,7 @@ void area_cast(int num,int sector,int owner,char noanim)
|
||||||
|
|
||||||
void kouzla_init()
|
void kouzla_init()
|
||||||
{
|
{
|
||||||
SEND_LOG("(SPELLS) Init...",0,0);
|
SEND_LOG("(SPELLS) Init...");
|
||||||
send_message(E_ADD,E_KOUZLO_ANM,kouzla_anm);
|
send_message(E_ADD,E_KOUZLO_ANM,kouzla_anm);
|
||||||
send_message(E_ADD,E_KOUZLO_KOLO,kouzla_kola);
|
send_message(E_ADD,E_KOUZLO_KOLO,kouzla_kola);
|
||||||
memset(spell_table,0,sizeof(spell_table));
|
memset(spell_table,0,sizeof(spell_table));
|
||||||
|
@ -1837,7 +1837,7 @@ void reinit_kouzla_full()
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
SEND_LOG("(SPELLS) Reinit...",0,0);
|
SEND_LOG("(SPELLS) Reinit...");
|
||||||
for(i=0;i<MAX_SPELLS;i++) if (spell_table[i]!=NULL) free(spell_table[i]);
|
for(i=0;i<MAX_SPELLS;i++) if (spell_table[i]!=NULL) free(spell_table[i]);
|
||||||
for(i=0;i<MAX_SPELLS;i++) if (vls_table[i]!=NULL) free(vls_table[i]);
|
for(i=0;i<MAX_SPELLS;i++) if (vls_table[i]!=NULL) free(vls_table[i]);
|
||||||
memset(spell_table,0,sizeof(spell_table));
|
memset(spell_table,0,sizeof(spell_table));
|
||||||
|
@ -1854,7 +1854,7 @@ void remove_all_mob_spells()
|
||||||
int i;
|
int i;
|
||||||
char a;
|
char a;
|
||||||
|
|
||||||
SEND_LOG("(SPELLS) Removing spells from enemies...",0,0);
|
SEND_LOG("(SPELLS) Removing spells from enemies...");
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
a=0;
|
a=0;
|
||||||
|
@ -1882,7 +1882,7 @@ int save_spells(TMPFILE_WR *f)
|
||||||
{
|
{
|
||||||
int i,s;
|
int i,s;
|
||||||
|
|
||||||
SEND_LOG("(SPELLS) Saving spell table...",0,0);
|
SEND_LOG("(SPELLS) Saving spell table...");
|
||||||
for(i=0,s=0;i<MAX_SPELLS;i++)
|
for(i=0,s=0;i<MAX_SPELLS;i++)
|
||||||
if (spell_table[i]!=NULL) s++;
|
if (spell_table[i]!=NULL) s++;
|
||||||
temp_storage_write(&s,1*sizeof(s),f);
|
temp_storage_write(&s,1*sizeof(s),f);
|
||||||
|
@ -1902,7 +1902,7 @@ int load_spells(TMPFILE_RD *f)
|
||||||
|
|
||||||
int i,s;
|
int i,s;
|
||||||
|
|
||||||
SEND_LOG("(SPELLS) Loading saved spell table...",0,0);
|
SEND_LOG("(SPELLS) Loading saved spell table...");
|
||||||
reinit_kouzla_full();
|
reinit_kouzla_full();
|
||||||
res|=(temp_storage_read(&s,1*sizeof(s),f)!=sizeof(s));
|
res|=(temp_storage_read(&s,1*sizeof(s),f)!=sizeof(s));
|
||||||
for(i=0;i<s && !res;i++)
|
for(i=0;i<s && !res;i++)
|
||||||
|
@ -1926,7 +1926,7 @@ void unaffect()
|
||||||
int i;
|
int i;
|
||||||
char a;
|
char a;
|
||||||
|
|
||||||
SEND_LOG("(WIZARD) Unaffect / dispel_magic",0,0);
|
SEND_LOG("(WIZARD) Unaffect / dispel_magic");
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
a=0;
|
a=0;
|
||||||
|
@ -1948,7 +1948,7 @@ void unaffect()
|
||||||
|
|
||||||
}
|
}
|
||||||
while(a);
|
while(a);
|
||||||
SEND_LOG("(WIZARD) Unaffect... done",0,0);
|
SEND_LOG("(WIZARD) Unaffect... done");
|
||||||
}
|
}
|
||||||
|
|
||||||
void unaffect_demon(int cil)
|
void unaffect_demon(int cil)
|
||||||
|
@ -1959,7 +1959,7 @@ void unaffect_demon(int cil)
|
||||||
|
|
||||||
|
|
||||||
cil++;
|
cil++;
|
||||||
SEND_LOG("(SPELLS) Demon returns to astral spaces...",0,0);
|
SEND_LOG("(SPELLS) Demon returns to astral spaces...");
|
||||||
for(i=0;spl=spell_table[i],i<MAX_SPELLS;i++) if (spl!=NULL && _flag_map[i] & SPL_DEMON && spl->cil==cil)
|
for(i=0;spl=spell_table[i],i<MAX_SPELLS;i++) if (spl!=NULL && _flag_map[i] & SPL_DEMON && spl->cil==cil)
|
||||||
{
|
{
|
||||||
while (spell_table[i]!=NULL)
|
while (spell_table[i]!=NULL)
|
||||||
|
|
10
game/menu.c
10
game/menu.c
|
@ -365,9 +365,8 @@ int enter_menu(char open)
|
||||||
|
|
||||||
char *get_next_title(signed char control,char *filename)
|
char *get_next_title(signed char control,char *filename)
|
||||||
{
|
{
|
||||||
/*
|
|
||||||
static TMPFILE_RD *titles=NULL;
|
static TMPFILE_RD *titles=NULL;
|
||||||
static ENCFILE fl;
|
|
||||||
static char buffer[81];
|
static char buffer[81];
|
||||||
char *path,*c;
|
char *path,*c;
|
||||||
|
|
||||||
|
@ -389,13 +388,12 @@ char *get_next_title(signed char control,char *filename)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return (char *)titles;
|
return (char *)titles;
|
||||||
case 0:if (titles!=NULL)fgets(buffer,80,titles);
|
case 0:if (titles!=NULL)temp_storage_gets(buffer,80,titles);
|
||||||
c=strchr(buffer,'\n');if (c!=NULL) *c=0;
|
c=strchr(buffer,'\n');if (c!=NULL) *c=0;
|
||||||
return buffer;
|
return buffer;
|
||||||
case -1:if (titles!=NULL)enc_close(&fl);
|
case -1:if (titles!=NULL)enc_close(titles);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -230,7 +230,7 @@ int load_map(char *filename)
|
||||||
if (level_fname!=NULL) free(level_fname);
|
if (level_fname!=NULL) free(level_fname);
|
||||||
level_fname=(char *)getmem(strlen(filename)+1);
|
level_fname=(char *)getmem(strlen(filename)+1);
|
||||||
strcpy(level_fname,filename);
|
strcpy(level_fname,filename);
|
||||||
SEND_LOG("(GAME) Loading map: '%s'",level_fname,0);
|
SEND_LOG("(GAME) Loading map: '%s'",level_fname);
|
||||||
strupr(level_fname);
|
strupr(level_fname);
|
||||||
mob_template=NULL;
|
mob_template=NULL;
|
||||||
mob_size=0;
|
mob_size=0;
|
||||||
|
@ -303,13 +303,13 @@ int load_map(char *filename)
|
||||||
back_color=RGB888(mglob.fade_r,mglob.fade_g,mglob.fade_b);
|
back_color=RGB888(mglob.fade_r,mglob.fade_g,mglob.fade_b);
|
||||||
break;
|
break;
|
||||||
case A_MAPITEM:
|
case A_MAPITEM:
|
||||||
SEND_LOG("(GAME) Loading items...",0,0);
|
SEND_LOG("(GAME) Loading items...");
|
||||||
load_item_map(temp,size);
|
load_item_map(temp,size);
|
||||||
free(temp);
|
free(temp);
|
||||||
break;
|
break;
|
||||||
case A_MAPMOBS:
|
case A_MAPMOBS:
|
||||||
if (snd_load==0) create_sound_table_old();
|
if (snd_load==0) create_sound_table_old();
|
||||||
SEND_LOG("(GAME) Loading enemies...",0,0);
|
SEND_LOG("(GAME) Loading enemies...");
|
||||||
if (mob_template==NULL)
|
if (mob_template==NULL)
|
||||||
{
|
{
|
||||||
int32_t h;char *p;
|
int32_t h;char *p;
|
||||||
|
@ -324,12 +324,12 @@ int load_map(char *filename)
|
||||||
{
|
{
|
||||||
load_enemies(temp,size,&ofsts,mob_template,mob_size);
|
load_enemies(temp,size,&ofsts,mob_template,mob_size);
|
||||||
free(mob_template);
|
free(mob_template);
|
||||||
SEND_LOG("(GAME) Loading enemies from map template...",0,0);
|
SEND_LOG("(GAME) Loading enemies from map template...");
|
||||||
}
|
}
|
||||||
free(temp);
|
free(temp);
|
||||||
break;
|
break;
|
||||||
case A_MAPMACR:
|
case A_MAPMACR:
|
||||||
SEND_LOG("(GAME) Loading multiactions...",0,0);
|
SEND_LOG("(GAME) Loading multiactions...");
|
||||||
load_macros(size,temp);
|
load_macros(size,temp);
|
||||||
break;
|
break;
|
||||||
case A_MAPVYK:
|
case A_MAPVYK:
|
||||||
|
@ -413,7 +413,7 @@ void leave_current_map()
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
TFLY *p;
|
TFLY *p;
|
||||||
SEND_LOG("(GAME) Leaving current map ... start",0,0);
|
SEND_LOG("(GAME) Leaving current map ... start");
|
||||||
add_leaving_place(viewsector);
|
add_leaving_place(viewsector);
|
||||||
kill_all_sounds();
|
kill_all_sounds();
|
||||||
restore_sound_names();
|
restore_sound_names();
|
||||||
|
@ -1411,7 +1411,7 @@ void real_krok(EVENT_MSG *msg,void **data)
|
||||||
if (msg->msg==E_INIT || msg->msg==E_DONE) return;
|
if (msg->msg==E_INIT || msg->msg==E_DONE) return;
|
||||||
check_all_mobs();
|
check_all_mobs();
|
||||||
calc_game();msg;data;
|
calc_game();msg;data;
|
||||||
SEND_LOG("(GAME) STEP",0,0);
|
SEND_LOG("(GAME) STEP");
|
||||||
}
|
}
|
||||||
|
|
||||||
void do_halucinace()
|
void do_halucinace()
|
||||||
|
|
|
@ -97,7 +97,7 @@ static void wire_setup()
|
||||||
mute_all_tracks(0);
|
mute_all_tracks(0);
|
||||||
cur_mode=MD_SETUP;
|
cur_mode=MD_SETUP;
|
||||||
send_message(E_ADD,E_KEYBOARD,setup_keyboard);
|
send_message(E_ADD,E_KEYBOARD,setup_keyboard);
|
||||||
SEND_LOG("(GAME) Starting setup",0,0);
|
SEND_LOG("(GAME) Starting setup");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void unwire_setup()
|
static void unwire_setup()
|
||||||
|
@ -113,7 +113,7 @@ static void unwire_setup()
|
||||||
send_message(E_DONE,E_KEYBOARD,setup_keyboard);
|
send_message(E_DONE,E_KEYBOARD,setup_keyboard);
|
||||||
wire_proc();
|
wire_proc();
|
||||||
cancel_render=1;
|
cancel_render=1;
|
||||||
SEND_LOG("(GAME) Setup closed",0,0);
|
SEND_LOG("(GAME) Setup closed");
|
||||||
}
|
}
|
||||||
|
|
||||||
char exit_setup(int id,int xa,int ya,int xr,int yr)
|
char exit_setup(int id,int xa,int ya,int xr,int yr)
|
||||||
|
|
155
game/skeldal.c
155
game/skeldal.c
|
@ -92,7 +92,7 @@ TMA_LOADLEV loadlevel;
|
||||||
|
|
||||||
typedef struct inis
|
typedef struct inis
|
||||||
{
|
{
|
||||||
char heslo[25];
|
char heslo[50];
|
||||||
char parmtype;
|
char parmtype;
|
||||||
}INIS;
|
}INIS;
|
||||||
|
|
||||||
|
@ -321,29 +321,29 @@ int set_video(int mode)
|
||||||
{
|
{
|
||||||
case 1:er=initmode256(cur_xlat);
|
case 1:er=initmode256(cur_xlat);
|
||||||
if (banking) report_mode(5); else report_mode(2);
|
if (banking) report_mode(5); else report_mode(2);
|
||||||
SEND_LOG("(GAME) Video changed to 256 colors %s",banking?"Bank":"LFB",0);
|
|
||||||
break;
|
break;
|
||||||
case 2:er=initmode32();
|
case 2:er=initmode32();
|
||||||
if (banking) report_mode(4); else report_mode(1);
|
if (banking) report_mode(4); else report_mode(1);
|
||||||
SEND_LOG("(GAME) Video changed to HIcolor %s",banking?"Bank":"LFB",0);
|
|
||||||
break;
|
break;
|
||||||
case 0:er=initmode_lo(cur_xlat);
|
case 0:er=initmode_lo(cur_xlat);
|
||||||
report_mode(3);
|
report_mode(3);
|
||||||
SEND_LOG("(GAME) Video changed to 256 VGA comp. ",0,0);
|
|
||||||
break;
|
break;
|
||||||
case 3: free(cur_xlat);cur_xlat=create_blw_palette16();
|
case 3: free(cur_xlat);cur_xlat=create_blw_palette16();
|
||||||
er=initmode16(cur_xlat);
|
er=initmode16(cur_xlat);
|
||||||
SEND_LOG("(GAME) Video changed to 16 grayscale",0,0);
|
|
||||||
report_mode(3);
|
report_mode(3);
|
||||||
break;
|
break;
|
||||||
case 4:er=init_empty_mode();
|
case 4:er=init_empty_mode();
|
||||||
report_mode(3);
|
report_mode(3);
|
||||||
SEND_LOG("(GAME) Video changed to <empty>",0,0);
|
|
||||||
break;
|
break;
|
||||||
case 5:free(cur_xlat);cur_xlat=create_hixlat();
|
case 5:free(cur_xlat);cur_xlat=create_hixlat();
|
||||||
er=initmode64(cur_xlat);
|
er=initmode64(cur_xlat);
|
||||||
if (banking) report_mode(7); else report_mode(6);
|
if (banking) report_mode(7); else report_mode(6);
|
||||||
SEND_LOG("(GAME) Video changed to HIcolor64 %s",banking?"Bank":"LFB",0);
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:er=-1;
|
default:er=-1;
|
||||||
|
@ -542,18 +542,18 @@ void music_init(void)
|
||||||
// char *path;
|
// char *path;
|
||||||
/* if (sound_detection)
|
/* if (sound_detection)
|
||||||
{
|
{
|
||||||
SEND_LOG("(SOUND) SOUND_DETECT Detecting sound card",0,0);
|
|
||||||
if (sound_detect(&snd_devnum,&snd_parm1,&snd_parm2,&snd_parm3)) snd_devnum=DEV_NOSOUND;
|
if (sound_detect(&snd_devnum,&snd_parm1,&snd_parm2,&snd_parm3)) snd_devnum=DEV_NOSOUND;
|
||||||
}*/
|
}*/
|
||||||
SEND_LOG("(SOUND) SOUND_SET Setting Sound: Device '%s' Port: %3X",device_name(snd_devnum),snd_parm1);
|
SEND_LOG("(SOUND) SOUND_SET Setting Sound: Device '%s' Port: %3X",device_name(snd_devnum),snd_parm1);
|
||||||
SEND_LOG("(SOUND) SOUND_SET Setting Sound: IRQ: %X DMA: %X",snd_parm2,snd_parm3);
|
SEND_LOG("(SOUND) SOUND_SET Setting Sound: IRQ: %X DMA: %X",snd_parm2,snd_parm3);
|
||||||
set_mixing_device(snd_devnum,snd_mixing,snd_parm1,snd_parm2,snd_parm3);
|
set_mixing_device(snd_devnum,snd_mixing,snd_parm1,snd_parm2,snd_parm3);
|
||||||
SEND_LOG("(SOUND) SOUND_INIT Starting mixing",0,0);
|
|
||||||
start_mixing();
|
start_mixing();
|
||||||
set_snd_effect(SND_GFX,init_gfx_vol);
|
set_snd_effect(SND_GFX,init_gfx_vol);
|
||||||
set_snd_effect(SND_MUSIC,init_music_vol);
|
set_snd_effect(SND_MUSIC,init_music_vol);
|
||||||
// path=plugins_path;
|
// path=plugins_path;
|
||||||
SEND_LOG("(SOUND) SOUND_DONE Sound Engine should work now",0,0);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -608,16 +608,17 @@ void *timming(EVENT_MSG *msg,void **data)
|
||||||
p=q->next;
|
p=q->next;
|
||||||
q->zavora=1;
|
q->zavora=1;
|
||||||
q->counter=q->count_max;
|
q->counter=q->count_max;
|
||||||
if (q->calls!=-1)
|
if (q->calls!=-1) {
|
||||||
if (--q->calls<1)
|
if (--q->calls<1)
|
||||||
{
|
{
|
||||||
for(p=&timer_tree;p->next!=q;p=p->next);
|
for(p=&timer_tree;p->next!=q;p=p->next);
|
||||||
p->next=q->next;
|
p->next=q->next;
|
||||||
#ifdef LOGFILE
|
#ifdef LOGFILE
|
||||||
if (q->next==NULL)
|
if (q->next==NULL) {
|
||||||
SEND_LOG("(TIMER) Self remove for timer id: %d, next-><NULL>",q->id,0);
|
|
||||||
else
|
} else {
|
||||||
SEND_LOG("(TIMER) Self remove for timer id: %d, next->%d",q->id,q->next->id);
|
SEND_LOG("(TIMER) Self remove for timer id: %d, next->%d",q->id,q->next->id);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
free(q);
|
free(q);
|
||||||
q=p;
|
q=p;
|
||||||
|
@ -625,6 +626,7 @@ void *timming(EVENT_MSG *msg,void **data)
|
||||||
//else
|
//else
|
||||||
// q->counter=1;
|
// q->counter=1;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
q->counter=1;
|
q->counter=1;
|
||||||
}
|
}
|
||||||
|
@ -632,7 +634,7 @@ void *timming(EVENT_MSG *msg,void **data)
|
||||||
if (q->next!=p && q!=p)
|
if (q->next!=p && q!=p)
|
||||||
{
|
{
|
||||||
THE_TIMER *z;
|
THE_TIMER *z;
|
||||||
SEND_LOG("(TIMER) Timer integrity corrupted",0,0);
|
|
||||||
z=&timer_tree;while(z->next!=p && z->next!=NULL) z=z->next;
|
z=&timer_tree;while(z->next!=p && z->next!=NULL) z=z->next;
|
||||||
if (z->next==NULL) return NULL;
|
if (z->next==NULL) return NULL;
|
||||||
}
|
}
|
||||||
|
@ -655,10 +657,11 @@ void delete_from_timer(int id)
|
||||||
if (q->zavora)
|
if (q->zavora)
|
||||||
{
|
{
|
||||||
#ifdef LOGFILE
|
#ifdef LOGFILE
|
||||||
if (q->next==NULL)
|
if (q->next==NULL) {
|
||||||
SEND_LOG("(TIMER) Removing timer id: %d, next-><NULL>",id,0);
|
|
||||||
else
|
}else {
|
||||||
SEND_LOG("(TIMER) Removing timer id: %d, next->%d",id,q->next->id);
|
SEND_LOG("(TIMER) Removing timer id: %d, next->%d",id,q->next->id);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
p->next=q->next;
|
p->next=q->next;
|
||||||
free(q);
|
free(q);
|
||||||
|
@ -666,7 +669,7 @@ void delete_from_timer(int id)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
SEND_LOG("(TIMER) Can't remove timer! id: %d. Currently in use.",id,0);
|
|
||||||
q->calls=-2;
|
q->calls=-2;
|
||||||
q->counter=1;
|
q->counter=1;
|
||||||
}
|
}
|
||||||
|
@ -757,7 +760,7 @@ void do_timer(void)
|
||||||
void done_skeldal(void)
|
void done_skeldal(void)
|
||||||
{
|
{
|
||||||
|
|
||||||
SEND_LOG("(GAME) Video returned to textmode",0,0);
|
|
||||||
close_manager();
|
close_manager();
|
||||||
close_story_file();
|
close_story_file();
|
||||||
purge_temps(1);
|
purge_temps(1);
|
||||||
|
@ -766,7 +769,7 @@ void done_skeldal(void)
|
||||||
if (texty!=NULL) release_list(texty);texty=NULL;
|
if (texty!=NULL) release_list(texty);texty=NULL;
|
||||||
if (cur_config!=NULL) release_list(cur_config);cur_config=NULL;
|
if (cur_config!=NULL) release_list(cur_config);cur_config=NULL;
|
||||||
kill_timer();
|
kill_timer();
|
||||||
SEND_LOG("NORMAL TERMINATING--------------------------",0,0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -878,11 +881,11 @@ void error_exception(EVENT_MSG *msg,void **unused)
|
||||||
if (msg->msg==E_PRGERROR)
|
if (msg->msg==E_PRGERROR)
|
||||||
{
|
{
|
||||||
unused;
|
unused;
|
||||||
SEND_LOG("(ERROR) Runtime error detected ... Game terminator lunched.",0,0);
|
|
||||||
SEND_LOG("(ERROR) Log: Now dump of useful informations:",0,0);
|
|
||||||
SEND_LOG("(ERROR) Log: Map name '%s'",level_fname==NULL?"<NULL>":level_fname,0);
|
|
||||||
SEND_LOG("(ERROR) Log: Sector %d Direction %d",viewsector,viewdir);
|
SEND_LOG("(ERROR) Log: Sector %d Direction %d",viewsector,viewdir);
|
||||||
SEND_LOG("(ERROR) Log: Last 'memman' handle: %x",memman_handle,0);
|
|
||||||
SEND_LOG("(ERROR) Log: Battle: %d Select_player %d",battle,select_player);
|
SEND_LOG("(ERROR) Log: Battle: %d Select_player %d",battle,select_player);
|
||||||
closemode();
|
closemode();
|
||||||
printf("Program zp<7A>sobil b<>hovou chybu a bude ukon<6F>en\n"
|
printf("Program zp<7A>sobil b<>hovou chybu a bude ukon<6F>en\n"
|
||||||
|
@ -899,7 +902,7 @@ void error_exception(EVENT_MSG *msg,void **unused)
|
||||||
void swap_error_exception(void)
|
void swap_error_exception(void)
|
||||||
{
|
{
|
||||||
closemode();
|
closemode();
|
||||||
SEND_LOG("(ERROR) Disk is full ...",0,0);
|
|
||||||
puts("Program jiz nema kam odkladat, protoze disk s odkladacim souborem byl \n"
|
puts("Program jiz nema kam odkladat, protoze disk s odkladacim souborem byl \n"
|
||||||
"zaplnen. Uvolnete prosim nejake misto na odkladacim disku, nebo zmente \n"
|
"zaplnen. Uvolnete prosim nejake misto na odkladacim disku, nebo zmente \n"
|
||||||
"adresar odkladani na jednotku, kde je vice mista");
|
"adresar odkladani na jednotku, kde je vice mista");
|
||||||
|
@ -970,78 +973,78 @@ void init_skeldal(void)
|
||||||
int verr;
|
int verr;
|
||||||
|
|
||||||
boldcz=LoadDefaultFont();
|
boldcz=LoadDefaultFont();
|
||||||
SEND_LOG("(INIT) Reading texts.",0,0);
|
|
||||||
cti_texty();
|
cti_texty();
|
||||||
timer_tree.next=NULL;
|
timer_tree.next=NULL;
|
||||||
SEND_LOG("(INIT) Setting random seed.",0,0);
|
|
||||||
srand(clock());
|
srand(clock());
|
||||||
SEND_LOG("(INIT) Creating 256 color palette.",0,0);
|
|
||||||
cur_xlat=create_special_palette();
|
cur_xlat=create_special_palette();
|
||||||
SEND_LOG("(INIT) Init message system - event handler",0,0);
|
|
||||||
init_events();
|
init_events();
|
||||||
SEND_LOG("(INIT) Setting videomode.",0,0);
|
|
||||||
verr=set_video(vmode);
|
verr=set_video(vmode);
|
||||||
if (verr)
|
if (verr)
|
||||||
{
|
{
|
||||||
exit(ERR_GENERAL);
|
exit(ERR_GENERAL);
|
||||||
}
|
}
|
||||||
SEND_LOG("(INIT) Initializing engine.",0,0);
|
|
||||||
general_engine_init();
|
general_engine_init();
|
||||||
atexit(done_skeldal);
|
atexit(done_skeldal);
|
||||||
/*SEND_LOG("(INIT) Loading DOS error handler.",0,0);
|
/*
|
||||||
install_dos_error(device_error,(char *)getmem(4096)+4096);*/
|
install_dos_error(device_error,(char *)getmem(4096)+4096);*/
|
||||||
swap_error=swap_error_exception;
|
swap_error=swap_error_exception;
|
||||||
snprintf(d,sizeof(d),"%s%s",pathtable[SR_DATA],"skeldal.ddl");
|
snprintf(d,sizeof(d),"%s%s",pathtable[SR_DATA],"SKELDAL.DDL");
|
||||||
SEND_LOG("(INIT) Initializing memory manager",0,0);
|
|
||||||
init_manager(d,c);
|
init_manager(d,c);
|
||||||
SEND_LOG("(GAME) Memory manager initialized. Using DDL: '%s' Temp dir: '%s'",d,c);
|
SEND_LOG("(GAME) Memory manager initialized. Using DDL: '%s' Temp dir: '%s'",d,c);
|
||||||
texty_knihy=find_map_path("kniha.txt");
|
texty_knihy=find_map_path("kniha.txt");
|
||||||
SEND_LOG("(INIT) Installing GUI",0,0);
|
|
||||||
install_gui();
|
install_gui();
|
||||||
SEND_LOG("(INIT) Attaching patch.",0,0);
|
|
||||||
if (patch_file!=NULL) patch_error(add_patch_file(patch_file));
|
if (patch_file!=NULL) patch_error(add_patch_file(patch_file));
|
||||||
SEND_LOG("(INIT) Registring basic data.",0,0);
|
|
||||||
register_basic_data();
|
register_basic_data();
|
||||||
SEND_LOG("(INIT) Timer event handler.",0,0);
|
|
||||||
send_message(E_DONE,E_WATCH,timer);
|
send_message(E_DONE,E_WATCH,timer);
|
||||||
send_message(E_DONE,E_IDLE,redraw_desktop_call);
|
send_message(E_DONE,E_IDLE,redraw_desktop_call);
|
||||||
send_message(E_ADD,E_TIMER,timming);
|
send_message(E_ADD,E_TIMER,timming);
|
||||||
SEND_LOG("(INIT) User timer.",0,0);
|
|
||||||
send_message(E_ADD,E_WATCH,user_timer);
|
send_message(E_ADD,E_WATCH,user_timer);
|
||||||
SEND_LOG("(INIT) Mouse clicking maps.",0,0);
|
|
||||||
send_message(E_ADD,E_MOUSE,ms_clicker);
|
send_message(E_ADD,E_MOUSE,ms_clicker);
|
||||||
SEND_LOG("(INIT) Global keyboard event handler.",0,0);
|
|
||||||
send_message(E_ADD,E_KEYBOARD,global_kbd);
|
send_message(E_ADD,E_KEYBOARD,global_kbd);
|
||||||
SEND_LOG("(INIT) Error exception event handler.",0,0);
|
|
||||||
send_message(E_ADD,E_PRGERROR,error_exception);
|
send_message(E_ADD,E_PRGERROR,error_exception);
|
||||||
SEND_LOG("(INIT) Wizard handler.",0,0);
|
|
||||||
if (debug_enabled) install_wizard();
|
if (debug_enabled) install_wizard();
|
||||||
SEND_LOG("(INIT) Background music timer.",0,0);
|
|
||||||
add_to_timer(TM_BACK_MUSIC,5,-1,back_music);
|
add_to_timer(TM_BACK_MUSIC,5,-1,back_music);
|
||||||
SEND_LOG("(INIT) Creating game window.",0,0);
|
|
||||||
add_game_window();
|
add_game_window();
|
||||||
SEND_LOG("(INIT) Music.",0,0);
|
|
||||||
music_init();
|
music_init();
|
||||||
SEND_LOG("(INIT) Mouse interrupt handler.",0,0);
|
|
||||||
if ((verr=init_mysky())!=0)
|
if ((verr=init_mysky())!=0)
|
||||||
{
|
{
|
||||||
closemode();
|
closemode();
|
||||||
puts(texty[174-verr]);
|
puts(texty[174-verr]);
|
||||||
SEND_LOG("(ERROR) %s (%d)",texty[174-verr],verr);
|
SEND_LOG("(ERROR) %s (%d)",texty[174-verr],verr);
|
||||||
SEND_LOG("(ERROR) Mouse not found, shutting down.",0,0);
|
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
SEND_LOG("(INIT) Mouse initialized.",0,0);
|
|
||||||
// hranice_mysky(0,0,639,479);
|
// hranice_mysky(0,0,639,479);
|
||||||
SEND_LOG("(INIT) Loading mouse cursor.",0,0);
|
|
||||||
mouse_set_default(H_MS_DEFAULT);
|
mouse_set_default(H_MS_DEFAULT);
|
||||||
ukaz_mysku();
|
ukaz_mysku();
|
||||||
set_end_of_song_callback(end_of_song_callback, NULL);
|
set_end_of_song_callback(end_of_song_callback, NULL);
|
||||||
SEND_LOG("(INIT) Loading spells.",0,0);
|
|
||||||
kouzla_init();
|
kouzla_init();
|
||||||
SEND_LOG("(INIT) Loading items.",0,0);
|
|
||||||
load_items();
|
load_items();
|
||||||
SEND_LOG("(INIT) Loading shops.",0,0);
|
|
||||||
load_shops();
|
load_shops();
|
||||||
SetWheelMapping('H','P');
|
SetWheelMapping('H','P');
|
||||||
}
|
}
|
||||||
|
@ -1049,7 +1052,7 @@ SEND_LOG("(INIT) Loading shops.",0,0);
|
||||||
void wire_main_functs();
|
void wire_main_functs();
|
||||||
void unwire_main_functs(void)
|
void unwire_main_functs(void)
|
||||||
{
|
{
|
||||||
SEND_LOG("(SYS) Wire main functions",0,0);
|
|
||||||
delete_from_timer(TM_FLY);
|
delete_from_timer(TM_FLY);
|
||||||
delete_from_timer(TM_SCENE);
|
delete_from_timer(TM_SCENE);
|
||||||
delete_from_timer(TM_REGEN);
|
delete_from_timer(TM_REGEN);
|
||||||
|
@ -1063,7 +1066,7 @@ void unwire_main_functs(void)
|
||||||
|
|
||||||
void wire_main_functs(void)
|
void wire_main_functs(void)
|
||||||
{
|
{
|
||||||
SEND_LOG("(SYS) unWire main functions",0,0);
|
|
||||||
add_to_timer(TM_SCENE,gamespeed,-1,refresh_scene);
|
add_to_timer(TM_SCENE,gamespeed,-1,refresh_scene);
|
||||||
add_to_timer(TM_FLY,gamespeed,-1,calc_fly);
|
add_to_timer(TM_FLY,gamespeed,-1,calc_fly);
|
||||||
add_to_timer(TM_REGEN,500,-1,real_regeneration);
|
add_to_timer(TM_REGEN,500,-1,real_regeneration);
|
||||||
|
@ -1080,9 +1083,9 @@ void wire_main_functs(void)
|
||||||
|
|
||||||
void init_game(void)
|
void init_game(void)
|
||||||
{
|
{
|
||||||
SEND_LOG("(INIT) Inventory.",0,0);
|
|
||||||
init_inventory();
|
init_inventory();
|
||||||
SEND_LOG("(INIT) Characters.",0,0);
|
|
||||||
reg_grafiku_postav();
|
reg_grafiku_postav();
|
||||||
build_all_players();
|
build_all_players();
|
||||||
}
|
}
|
||||||
|
@ -1135,14 +1138,14 @@ void enter_game(void)
|
||||||
cancel_pass=0;
|
cancel_pass=0;
|
||||||
autosave();
|
autosave();
|
||||||
set_game_click_map();
|
set_game_click_map();
|
||||||
SEND_LOG("(GAME) --------- Waiting for E_CLOSE_MAP ------------\n",0,0);
|
|
||||||
send_message(E_ADD,E_RELOADMAP,reload_map_handler);
|
send_message(E_ADD,E_RELOADMAP,reload_map_handler);
|
||||||
{
|
{
|
||||||
EVENT_MSG *msg = task_wait_event(E_CLOSE_MAP);
|
EVENT_MSG *msg = task_wait_event(E_CLOSE_MAP);
|
||||||
end = va_arg(msg->data, int);
|
end = va_arg(msg->data, int);
|
||||||
}
|
}
|
||||||
send_message(E_DONE,E_RELOADMAP,reload_map_handler);
|
send_message(E_DONE,E_RELOADMAP,reload_map_handler);
|
||||||
SEND_LOG("(GAME) --------- E_CLOSE_MAP triggered, leaving map------------\n",0,0);
|
|
||||||
unwire_main_functs();
|
unwire_main_functs();
|
||||||
delete_from_timer(TM_FAST_TIMER);
|
delete_from_timer(TM_FAST_TIMER);
|
||||||
cancel_pass=1;
|
cancel_pass=1;
|
||||||
|
@ -1174,7 +1177,7 @@ static int do_config_skeldal(int num,int numdata,char *txt)
|
||||||
sound_detection=0;
|
sound_detection=0;
|
||||||
break;
|
break;
|
||||||
case 6:snd_mixing=numdata;break;
|
case 6:snd_mixing=numdata;break;
|
||||||
case 7:strncpy(default_map,txt,20);default_map[19]='\0';SEND_LOG("(GAME) Start map sets as '%s'",default_map,0);break;
|
case 7:strncpy(default_map,txt,20);default_map[19]='\0';break;
|
||||||
case 8:gamespeed=numdata;break;
|
case 8:gamespeed=numdata;break;
|
||||||
case 9:level_preload=numdata;break;
|
case 9:level_preload=numdata;break;
|
||||||
// case 10:system(txt);break;
|
// case 10:system(txt);break;
|
||||||
|
@ -1262,9 +1265,9 @@ static void configure(char *filename)
|
||||||
puts(s);
|
puts(s);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
SEND_LOG("(GAME) Configuring game...",0,0);
|
|
||||||
process_ini(cur_config,config_skeldal);
|
process_ini(cur_config,config_skeldal);
|
||||||
SEND_LOG("(GAME) Done config.",0,0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int update_config(void)
|
static int update_config(void)
|
||||||
|
@ -1277,7 +1280,7 @@ static int update_config(void)
|
||||||
add_field_num(&cur_config,sinit[9].heslo,level_preload);
|
add_field_num(&cur_config,sinit[9].heslo,level_preload);
|
||||||
add_field_num(&cur_config,sinit[13].heslo,autosave_enabled);
|
add_field_num(&cur_config,sinit[13].heslo,autosave_enabled);
|
||||||
save_config(cur_config,CONFIG_NAME);
|
save_config(cur_config,CONFIG_NAME);
|
||||||
SEND_LOG("(GAME) Config. file was saved",0,0);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1423,7 +1426,7 @@ static void game_big_circle(char enforced)
|
||||||
int err;
|
int err;
|
||||||
int r;
|
int r;
|
||||||
char s[13];
|
char s[13];
|
||||||
SEND_LOG("\n(GAME) --------- Entering big loop ------------",0,0);
|
|
||||||
purge_playlist();
|
purge_playlist();
|
||||||
s[12]=0;strncpy(s,loadlevel.name,12);
|
s[12]=0;strncpy(s,loadlevel.name,12);
|
||||||
err=load_map(s);
|
err=load_map(s);
|
||||||
|
@ -1469,16 +1472,16 @@ static void game_big_circle(char enforced)
|
||||||
for(r=0;r<mapsize*4;r++) call_macro(r,MC_STARTLEV);
|
for(r=0;r<mapsize*4;r++) call_macro(r,MC_STARTLEV);
|
||||||
recalc_volumes(viewsector,viewdir);
|
recalc_volumes(viewsector,viewdir);
|
||||||
loadlevel.name[0]=0;
|
loadlevel.name[0]=0;
|
||||||
SEND_LOG("\n(GAME) --------- Entering game ------------",0,0);
|
|
||||||
enter_game();
|
enter_game();
|
||||||
SEND_LOG("(GAME) --------- Leaving game ------------\n",0,0);
|
|
||||||
leave_current_map();
|
leave_current_map();
|
||||||
s[12]=0;strncpy(s,loadlevel.name,12);
|
s[12]=0;strncpy(s,loadlevel.name,12);
|
||||||
if (s[0]!=0)err=load_map(s);
|
if (s[0]!=0)err=load_map(s);
|
||||||
memset(GlobEventList,0,sizeof(GlobEventList));
|
memset(GlobEventList,0,sizeof(GlobEventList));
|
||||||
|
|
||||||
}
|
}
|
||||||
SEND_LOG("(GAME) --------- Leaving big loop ------------\n",0,0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
extern THUMAN postavy_2[];
|
extern THUMAN postavy_2[];
|
||||||
|
@ -1646,16 +1649,14 @@ int main(int argc,char *argv[])
|
||||||
|
|
||||||
if (argc>=3) rm=!strcmp(argv[1],"12345678");else rm=0;
|
if (argc>=3) rm=!strcmp(argv[1],"12345678");else rm=0;
|
||||||
|
|
||||||
//OPEN_LOG("syslog");
|
|
||||||
OPEN_LOG("con");
|
|
||||||
SEND_LOG("START --------------------------",0,0);
|
|
||||||
argv;
|
argv;
|
||||||
c=getcwd(NULL,0);
|
c=getcwd(NULL,0);
|
||||||
pathtable[SR_SAVES]=getmem(strlen(c)+2);
|
pathtable[SR_SAVES]=getmem(strlen(c)+2);
|
||||||
strcpy(pathtable[SR_SAVES],c);
|
strcpy(pathtable[SR_SAVES],c);
|
||||||
strcat(pathtable[SR_SAVES],PATH_SEPARATOR);
|
strcat(pathtable[SR_SAVES],PATH_SEPARATOR);
|
||||||
free(c);
|
free(c);
|
||||||
SEND_LOG("(GAME) Save directory sets to '%s'",pathtable[SR_SAVES],0);
|
|
||||||
// set_verify(0);
|
// set_verify(0);
|
||||||
mman_pathlist=pathtable;
|
mman_pathlist=pathtable;
|
||||||
zoom_speed(1);
|
zoom_speed(1);
|
||||||
|
@ -1672,7 +1673,7 @@ int main(int argc,char *argv[])
|
||||||
|
|
||||||
adventure=argv[1];
|
adventure=argv[1];
|
||||||
cur_config=NULL;
|
cur_config=NULL;
|
||||||
SEND_LOG("(GAME) Starting new adventure: %s",adventure,0);
|
|
||||||
configure(adventure);
|
configure(adventure);
|
||||||
release_list(cur_config);
|
release_list(cur_config);
|
||||||
cur_config=config;
|
cur_config=config;
|
||||||
|
@ -1680,25 +1681,25 @@ int main(int argc,char *argv[])
|
||||||
#ifdef LOGFILE
|
#ifdef LOGFILE
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
for(i=0;i<(sizeof(pathtable)/4);i++) SEND_LOG("(GAME) LOG: Using directory '%s' as '%s'",pathtable[i],sinit[i+CESTY_POS].heslo);
|
for(i=0;i<(int)(sizeof(pathtable)/sizeof(*pathtable));i++) SEND_LOG("(GAME) LOG: Using directory '%s' as '%s'",pathtable[i],sinit[i+CESTY_POS].heslo);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
start_check();
|
start_check();
|
||||||
purge_temps(1);
|
purge_temps(1);
|
||||||
// textmode_effekt();
|
// textmode_effekt();
|
||||||
clrscr();
|
clrscr();
|
||||||
SEND_LOG("\n(GAME) Init----------------",0,0);
|
|
||||||
init_skeldal();
|
init_skeldal();
|
||||||
|
|
||||||
//add_task(32768,check_number_1phase,argv[0]);
|
//add_task(32768,check_number_1phase,argv[0]);
|
||||||
SEND_LOG("(INIT) Starting game thread.",0,0);
|
|
||||||
if (argc>=3 && rm)
|
if (argc>=3 && rm)
|
||||||
{
|
{
|
||||||
add_task(65536,start_from_mapedit,argc,argv);
|
add_task(65536,start_from_mapedit,argc,argv);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
add_task(65536,start);
|
add_task(65536,start);
|
||||||
SEND_LOG("(INIT) Main thread goes to sleep.",0,0);
|
|
||||||
/* position(200,200);
|
/* position(200,200);
|
||||||
set_font(H_FBIG,RGB(200,200,200));
|
set_font(H_FBIG,RGB(200,200,200));
|
||||||
outtext("Ahoj lidi");
|
outtext("Ahoj lidi");
|
||||||
|
|
|
@ -340,7 +340,7 @@ void recalc_volumes(int sector,int side)
|
||||||
if (sector>=mapsize) return;
|
if (sector>=mapsize) return;
|
||||||
|
|
||||||
side;
|
side;
|
||||||
SEND_LOG("(SOUND) %s","Recalculating volumes",0);
|
SEND_LOG("(SOUND) %s","Recalculating volumes");
|
||||||
newx=map_coord[sector].x;
|
newx=map_coord[sector].x;
|
||||||
newy=map_coord[sector].y;
|
newy=map_coord[sector].y;
|
||||||
// layer=map_coord[sector].layer;
|
// layer=map_coord[sector].layer;
|
||||||
|
@ -580,7 +580,7 @@ void mute_all_tracks(char all)
|
||||||
void kill_all_sounds()
|
void kill_all_sounds()
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
SEND_LOG("(SOUND) Killing sound tracks...",0,0);
|
SEND_LOG("(SOUND) Killing sound tracks...");
|
||||||
for (i=0;i<CHANNELS;i++) release_channel(i);
|
for (i=0;i<CHANNELS;i++) release_channel(i);
|
||||||
for (i=0;i<32;i++) if (locks[i]!=0) aunlock(locks[i]);
|
for (i=0;i<32;i++) if (locks[i]!=0) aunlock(locks[i]);
|
||||||
}
|
}
|
||||||
|
|
|
@ -520,7 +520,7 @@ void zacatek_kola()
|
||||||
int i;
|
int i;
|
||||||
THUMAN *p;
|
THUMAN *p;
|
||||||
|
|
||||||
SEND_LOG("(BATTLE) Start round",0,0);
|
SEND_LOG("(BATTLE) Start round");
|
||||||
build_player_map();
|
build_player_map();
|
||||||
cislo_kola++;
|
cislo_kola++;
|
||||||
autostart_round=0;
|
autostart_round=0;
|
||||||
|
@ -581,7 +581,7 @@ void konec_kola()
|
||||||
int i;THUMAN *h;TMOB *m;
|
int i;THUMAN *h;TMOB *m;
|
||||||
int j;
|
int j;
|
||||||
|
|
||||||
SEND_LOG("(BATTLE) End round",0,0);
|
SEND_LOG("(BATTLE) End round");
|
||||||
prekvapeni=0;
|
prekvapeni=0;
|
||||||
for(i=0,h=postavy;i<POCET_POSTAV;i++,h++)
|
for(i=0,h=postavy;i<POCET_POSTAV;i++,h++)
|
||||||
if (h->used)
|
if (h->used)
|
||||||
|
@ -1162,7 +1162,7 @@ void jadro_souboje(EVENT_MSG *msg,void **unused) //!!!! Jadro souboje
|
||||||
if(nxt==-255)
|
if(nxt==-255)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
SEND_LOG("(BATTLE) Ending round...",nxt,mobs[nxt].name);
|
SEND_LOG("(BATTLE) Ending round...(nxt=%d,mob=%s)",nxt,mobs[nxt].name);
|
||||||
delete_from_timer(TM_SCENE);
|
delete_from_timer(TM_SCENE);
|
||||||
add_to_timer(TM_SCENE,gamespeed,-1,refresh_scene);
|
add_to_timer(TM_SCENE,gamespeed,-1,refresh_scene);
|
||||||
for(i=0;i<MAX_MOBS;i++)
|
for(i=0;i<MAX_MOBS;i++)
|
||||||
|
@ -1272,7 +1272,7 @@ void jadro_souboje(EVENT_MSG *msg,void **unused) //!!!! Jadro souboje
|
||||||
int i;
|
int i;
|
||||||
THUMAN *p;
|
THUMAN *p;
|
||||||
|
|
||||||
SEND_LOG("(BATTLE) Leaving battle",0,0);
|
SEND_LOG("(BATTLE) Leaving battle");
|
||||||
prekvapeni=0;
|
prekvapeni=0;
|
||||||
unwire_proc();
|
unwire_proc();
|
||||||
wire_main_functs();
|
wire_main_functs();
|
||||||
|
@ -2023,7 +2023,7 @@ void start_battle()
|
||||||
disable_click_map();
|
disable_click_map();
|
||||||
if (!running_battle)
|
if (!running_battle)
|
||||||
{
|
{
|
||||||
SEND_LOG("(BATTLE) Battle started (monster: %s)",attack_mob!=NULL?attack_mob->name:"(NULL)",0);
|
SEND_LOG("(BATTLE) Battle started (monster: %s)",attack_mob!=NULL?attack_mob->name:"(NULL)");
|
||||||
poloz_vsechny_predmety();
|
poloz_vsechny_predmety();
|
||||||
zacatek_kola();
|
zacatek_kola();
|
||||||
running_battle=1;
|
running_battle=1;
|
||||||
|
@ -2368,7 +2368,7 @@ char player_check_death(THUMAN *p, char afterround)
|
||||||
if (p->level>1) p->exp=level_map[p->level-2];
|
if (p->level>1) p->exp=level_map[p->level-2];
|
||||||
p->kondice=0;
|
p->kondice=0;
|
||||||
p->mana=0;
|
p->mana=0;
|
||||||
SEND_LOG("(GAME) Character '%s' died. R.I.P.",p->jmeno,0);
|
SEND_LOG("(GAME) Character '%s' died. R.I.P.",p->jmeno);
|
||||||
if (numplayers(p->sektor,0)==0) map_coord[p->sektor].flags &=~MC_PLAYER;
|
if (numplayers(p->sektor,0)==0) map_coord[p->sektor].flags &=~MC_PLAYER;
|
||||||
mp=map_sectors[p->sektor].sector_type;
|
mp=map_sectors[p->sektor].sector_type;
|
||||||
if (mp==S_VODA || mp==S_LAVA || mp==S_VIR) p->sektor=0;
|
if (mp==S_VODA || mp==S_LAVA || mp==S_VIR) p->sektor=0;
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <string_view>
|
#include <string_view>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#include "temp_storage.h"
|
#include "temp_storage.h"
|
||||||
|
@ -16,7 +17,6 @@ typedef struct _temp_storage_file_wr {
|
||||||
typedef struct _temp_storage_file_rd {
|
typedef struct _temp_storage_file_rd {
|
||||||
std::basic_string_view<uint8_t> _data;
|
std::basic_string_view<uint8_t> _data;
|
||||||
int skp = 0;
|
int skp = 0;
|
||||||
int scan_ret = 0;
|
|
||||||
} TMPFILE_RD;
|
} TMPFILE_RD;
|
||||||
|
|
||||||
using FileSystem = std::map<std::string, std::vector<uint8_t>, std::less<> >;
|
using FileSystem = std::map<std::string, std::vector<uint8_t>, std::less<> >;
|
||||||
|
@ -26,7 +26,11 @@ static FileSystem temp_fsystem;
|
||||||
void temp_storage_store(const char *name, const void *data, int32_t size) {
|
void temp_storage_store(const char *name, const void *data, int32_t size) {
|
||||||
auto b = reinterpret_cast<const uint8_t *>(data);
|
auto b = reinterpret_cast<const uint8_t *>(data);
|
||||||
auto e = b+size;
|
auto e = b+size;
|
||||||
temp_fsystem[std::string(name)] = {b,e};
|
auto &v =temp_fsystem[std::string(name)];
|
||||||
|
v.clear();
|
||||||
|
v.resize(size+1);
|
||||||
|
std::copy(b,e, v.begin());
|
||||||
|
v[size] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t temp_storage_find(const char *name) {
|
int32_t temp_storage_find(const char *name) {
|
||||||
|
@ -89,7 +93,7 @@ uint32_t temp_storage_read(void *data, uint32_t size, TMPFILE_RD *f) {
|
||||||
auto p = d.substr(0,size);
|
auto p = d.substr(0,size);
|
||||||
d = d.substr(p.size());
|
d = d.substr(p.size());
|
||||||
auto b = reinterpret_cast<uint8_t *>(data);
|
auto b = reinterpret_cast<uint8_t *>(data);
|
||||||
std::copy(d.begin(), d.end(), b);
|
std::copy(p.begin(), p.end(), b);
|
||||||
return p.size();
|
return p.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -106,7 +110,7 @@ void temp_storage_delete(const char *name) {
|
||||||
|
|
||||||
int temp_storage_getc(TMPFILE_RD *f) {
|
int temp_storage_getc(TMPFILE_RD *f) {
|
||||||
if (f->_data.empty()) return -1;
|
if (f->_data.empty()) return -1;
|
||||||
int r = f->_data[0];
|
int r = static_cast<uint8_t>(f->_data[0]);
|
||||||
f->_data = f->_data.substr(1);
|
f->_data = f->_data.substr(1);
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
@ -114,7 +118,7 @@ int temp_storage_getc(TMPFILE_RD *f) {
|
||||||
char *temp_storage_gets(char *buff, size_t sz, TMPFILE_RD *f) {
|
char *temp_storage_gets(char *buff, size_t sz, TMPFILE_RD *f) {
|
||||||
auto &d =f->_data;
|
auto &d =f->_data;
|
||||||
auto pos = d.find('\n');
|
auto pos = d.find('\n');
|
||||||
if (pos > d.size()) pos = d.size();
|
if (pos > d.size()) pos = d.size(); else ++pos;
|
||||||
if (pos == 0) return NULL;
|
if (pos == 0) return NULL;
|
||||||
if (pos > sz - 1) pos = sz - 1;
|
if (pos > sz - 1) pos = sz - 1;
|
||||||
temp_storage_read(buff, pos, f);
|
temp_storage_read(buff, pos, f);
|
||||||
|
@ -123,23 +127,25 @@ char *temp_storage_gets(char *buff, size_t sz, TMPFILE_RD *f) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void temp_storage_internal_begin_scanf(TMPFILE_RD *f, const char *format, ...) {
|
int temp_storage_internal_begin_scanf(TMPFILE_RD *f, const char *format, ...) {
|
||||||
if (f->_data.empty()) {
|
if (f->_data.empty()) {
|
||||||
f->scan_ret = -1;
|
return -1;
|
||||||
}
|
}
|
||||||
va_list lst;
|
va_list lst;
|
||||||
va_start(lst, format);
|
va_start(lst, format);
|
||||||
f->scan_ret = vsscanf(reinterpret_cast<const char *>(f->_data.data()), format, lst);
|
int scan_ret = vsscanf(reinterpret_cast<const char *>(f->_data.data()), format, lst);
|
||||||
va_end(lst);
|
va_end(lst);
|
||||||
|
return scan_ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
int *temp_storage_internal_skip_ptr(TMPFILE_RD *f) {
|
int *temp_storage_internal_skip_ptr(TMPFILE_RD *f) {
|
||||||
|
f->skp = 0;
|
||||||
return &f->skp;
|
return &f->skp;
|
||||||
}
|
}
|
||||||
|
|
||||||
int temp_storage_internal_end_scanf(TMPFILE_RD *f) {
|
int temp_storage_internal_end_scanf(TMPFILE_RD *f, int r) {
|
||||||
temp_storage_skip(f, f->skp);
|
temp_storage_skip(f, f->skp);
|
||||||
return f->scan_ret;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
void temp_storage_ungetc(TMPFILE_RD *f) {
|
void temp_storage_ungetc(TMPFILE_RD *f) {
|
||||||
|
|
|
@ -28,11 +28,14 @@ uint32_t temp_storage_read(void *data, uint32_t size, TMPFILE_RD *f);
|
||||||
void temp_storage_skip(TMPFILE_RD *f, int bytes);
|
void temp_storage_skip(TMPFILE_RD *f, int bytes);
|
||||||
|
|
||||||
int *temp_storage_internal_skip_ptr(TMPFILE_RD *f);
|
int *temp_storage_internal_skip_ptr(TMPFILE_RD *f);
|
||||||
void temp_storage_internal_begin_scanf(TMPFILE_RD *f, const char *format, ... ) __attribute__((format(scanf, 2, 3)));
|
int temp_storage_internal_begin_scanf(TMPFILE_RD *f, const char *format, ... ) __attribute__((format(scanf, 2, 3)));
|
||||||
int temp_storage_internal_end_scanf(TMPFILE_RD *f);
|
int temp_storage_internal_end_scanf(TMPFILE_RD *f, int r);
|
||||||
|
|
||||||
|
|
||||||
#define temp_storage_scanf(f, format, ...) (temp_storage_internal_begin_scanf(f, format "%n", __VA_ARGS__, temp_storage_internal_skip_ptr(f)),temp_storage_internal_end_scanf(f))
|
#define temp_storage_scanf(f, format, ...) \
|
||||||
|
temp_storage_internal_end_scanf(f,\
|
||||||
|
temp_storage_internal_begin_scanf(f, format "%n", \
|
||||||
|
__VA_ARGS__, temp_storage_internal_skip_ptr(f)))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -4,6 +4,9 @@
|
||||||
#include "event.h"
|
#include "event.h"
|
||||||
#include "devices.h"
|
#include "devices.h"
|
||||||
#include "bmouse.h"
|
#include "bmouse.h"
|
||||||
|
|
||||||
|
#include "memman.h"
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
char visible=0;
|
char visible=0;
|
||||||
|
@ -74,6 +77,7 @@ void update_mysky(void)
|
||||||
if (x.event)
|
if (x.event)
|
||||||
{
|
{
|
||||||
ms_last_event=x;
|
ms_last_event=x;
|
||||||
|
x.event = 0;
|
||||||
}
|
}
|
||||||
if(!visible) move_ms_cursor(x.x-h_x,x.y-h_y,0);
|
if(!visible) move_ms_cursor(x.x-h_x,x.y-h_y,0);
|
||||||
}
|
}
|
||||||
|
|
|
@ -232,15 +232,16 @@ void enter_event(T_EVENT_ROOT **tree,EVENT_MSG *msg)
|
||||||
va_end(cpy.data);
|
va_end(cpy.data);
|
||||||
p->calls--;
|
p->calls--;
|
||||||
p->nezavora=1;
|
p->nezavora=1;
|
||||||
if (msg->msg==-2)
|
if (cpy.msg==-2)
|
||||||
{
|
{
|
||||||
p->proc=NULL;
|
p->proc=NULL;
|
||||||
msg->msg=ev;
|
cpy.msg=ev;
|
||||||
}
|
}
|
||||||
s=p->next;
|
s=p->next;
|
||||||
if (!p->calls && p->proc==NULL)
|
if (!p->calls && p->proc==NULL)
|
||||||
force_delete_curr(tree,r,p);
|
force_delete_curr(tree,r,p);
|
||||||
if (msg->msg==-1) break;
|
if (cpy.msg==-1)
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
/* if (p->next!=s)
|
/* if (p->next!=s)
|
||||||
if (r->list!=p)
|
if (r->list!=p)
|
||||||
|
|
12
libs/event.h
12
libs/event.h
|
@ -99,6 +99,18 @@ extern char *otevri_zavoru;
|
||||||
//extern int curtask;
|
//extern int curtask;
|
||||||
//extern char *task_info;
|
//extern char *task_info;
|
||||||
|
|
||||||
|
///copies message
|
||||||
|
static inline EVENT_MSG clone_message(EVENT_MSG *msg) {
|
||||||
|
EVENT_MSG out;
|
||||||
|
out.msg = msg->msg;
|
||||||
|
va_copy(out.data, msg->data);
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
///destroys copied message
|
||||||
|
static inline void destroy_message(EVENT_MSG *msg) {
|
||||||
|
va_end(msg->data);
|
||||||
|
}
|
||||||
|
|
||||||
void init_events(void);
|
void init_events(void);
|
||||||
// inicalizuje zakladni strom udalosto
|
// inicalizuje zakladni strom udalosto
|
||||||
void send_message(int message,...);
|
void send_message(int message,...);
|
||||||
|
|
99
libs/gui.c
99
libs/gui.c
|
@ -610,42 +610,58 @@ void do_it_events(EVENT_MSG *msg,void **user_data)
|
||||||
if (msg->msg==E_MOUSE)
|
if (msg->msg==E_MOUSE)
|
||||||
{
|
{
|
||||||
*oz=1;
|
*oz=1;
|
||||||
|
EVENT_MSG fwmsg = clone_message(msg);
|
||||||
|
fwmsg.msg = msg->msg;
|
||||||
|
va_copy(fwmsg.data, msg->data);
|
||||||
msev=get_mouse(msg);
|
msev=get_mouse(msg);
|
||||||
aktivate_window(msev);
|
aktivate_window(msev);
|
||||||
if (o_aktual==NULL)
|
if (o_aktual == NULL) {
|
||||||
if (o_start!=NULL && (msev->tl1 || msev->tl2 || msev->tl3))
|
if (o_start != NULL && (msev->tl1 || msev->tl2 || msev->tl3)) {
|
||||||
{
|
o_aktual = o_start;
|
||||||
o_aktual=o_start;
|
while (o_aktual != NULL
|
||||||
while (o_aktual!=NULL && (!o_aktual->enabled || !mouse_in_object(msev,o_aktual,waktual) || o_aktual->call_event==empty3)) o_aktual=o_aktual->next;
|
&& (!o_aktual->enabled
|
||||||
if (o_aktual==NULL) return;
|
|| !mouse_in_object(msev, o_aktual, waktual)
|
||||||
msg2.msg=E_GET_FOCUS;
|
|| o_aktual->call_event == empty3))
|
||||||
o_aktual->call_event(&msg2,o_aktual);
|
o_aktual = o_aktual->next;
|
||||||
o_aktual->on_enter();
|
if (o_aktual != NULL) {
|
||||||
o_aktual->call_event(msg,o_aktual);
|
msg2.msg = E_GET_FOCUS;
|
||||||
}
|
o_aktual->call_event(&msg2, o_aktual);
|
||||||
else return;
|
o_aktual->on_enter();
|
||||||
else
|
o_aktual->call_event(&fwmsg, o_aktual);
|
||||||
{
|
}
|
||||||
if (o_aktual->enabled) b=mouse_in_object(msev,o_aktual,waktual);else b=0;
|
}
|
||||||
if (b)
|
} else {
|
||||||
o_aktual->call_event(msg,o_aktual);
|
if (o_aktual->enabled) {
|
||||||
if ((msev->tl1 || msev->tl2 || msev->tl3)&& !b)
|
b = mouse_in_object(msev, o_aktual, waktual);
|
||||||
{
|
} else {
|
||||||
o_aktual->on_exit();
|
b = 0;
|
||||||
if (f_cancel_event) return;
|
}
|
||||||
msg2.msg=E_LOST_FOCUS;
|
if (b) {
|
||||||
o_aktual->call_event(&msg2,o_aktual);
|
o_aktual->call_event(&fwmsg, o_aktual);
|
||||||
p=o_start;
|
}
|
||||||
while (p!=NULL && (!p->enabled || !mouse_in_object(msev,p,waktual) || p->call_event==empty3))
|
if ((msev->tl1 || msev->tl2 || msev->tl3) && !b) {
|
||||||
p=p->next;
|
o_aktual->on_exit();
|
||||||
if (p!=NULL) o_aktual=p;
|
if (f_cancel_event)
|
||||||
msg2.msg=E_GET_FOCUS;
|
return;
|
||||||
o_aktual->call_event(&msg2,o_aktual);
|
msg2.msg = E_LOST_FOCUS;
|
||||||
o_aktual->on_enter();
|
o_aktual->call_event(&msg2, o_aktual);
|
||||||
if (p!=NULL) o_aktual->call_event(msg,o_aktual);
|
p = o_start;
|
||||||
}
|
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->call_event(&msg2, o_aktual);
|
||||||
|
o_aktual->on_enter();
|
||||||
|
if (p != NULL)
|
||||||
|
o_aktual->call_event(msg, o_aktual);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
destroy_message(&fwmsg);
|
||||||
|
}
|
||||||
if (msg->msg==E_KEYBOARD)
|
if (msg->msg==E_KEYBOARD)
|
||||||
{
|
{
|
||||||
*oz=1;
|
*oz=1;
|
||||||
|
@ -689,20 +705,23 @@ void do_it_events(EVENT_MSG *msg,void **user_data)
|
||||||
if (msg->msg==E_GUI)
|
if (msg->msg==E_GUI)
|
||||||
{
|
{
|
||||||
OBJREC *o;
|
OBJREC *o;
|
||||||
|
|
||||||
|
EVENT_MSG msg2 = clone_message(msg);
|
||||||
|
|
||||||
int control = va_arg(msg->data, int);
|
int control = va_arg(msg->data, int);
|
||||||
msg->msg = va_arg(msg->data, int);
|
msg->msg = va_arg(msg->data, int);
|
||||||
o=find_object(waktual,control);
|
o=find_object(waktual,control);
|
||||||
|
|
||||||
EVENT_MSG msg2;
|
|
||||||
|
|
||||||
if (o!=NULL)
|
if (o!=NULL)
|
||||||
{
|
{
|
||||||
msg2.msg=msg->msg;
|
EVENT_MSG msg3 = clone_message(msg);
|
||||||
va_copy(msg2.data,msg->data);
|
o->call_event(&msg2,o);
|
||||||
o->call_event(&msg2,o);
|
o->on_event(&msg3,o_aktual);
|
||||||
o->on_event(msg,o_aktual);
|
destroy_message(&msg3);
|
||||||
va_end(msg2.data);
|
|
||||||
}
|
}
|
||||||
|
destroy_message(&msg2);
|
||||||
|
|
||||||
}
|
}
|
||||||
if (msg->msg==E_CHANGE)
|
if (msg->msg==E_CHANGE)
|
||||||
|
|
|
@ -38,7 +38,7 @@ int32_t last_load_size;
|
||||||
void standard_mem_error(size_t size)
|
void standard_mem_error(size_t size)
|
||||||
{
|
{
|
||||||
char buff[256];
|
char buff[256];
|
||||||
SEND_LOG("(ERROR) Memory allocation error detected, %u bytes missing",size,0);
|
SEND_LOG("(ERROR) Memory allocation error detected, %lu bytes missing",size);
|
||||||
DXCloseMode();
|
DXCloseMode();
|
||||||
sprintf(buff,"Memory allocation error\n Application can't allocate %lu bytes of memory (%xh)\n",size,memman_handle);
|
sprintf(buff,"Memory allocation error\n Application can't allocate %lu bytes of memory (%xh)\n",size,memman_handle);
|
||||||
display_error(buff);
|
display_error(buff);
|
||||||
|
@ -48,7 +48,7 @@ void standard_mem_error(size_t size)
|
||||||
void load_error(char *filename)
|
void load_error(char *filename)
|
||||||
{
|
{
|
||||||
char buff[256];
|
char buff[256];
|
||||||
SEND_LOG("(ERROR) Load error detected, system can't load file: %s",filename,0);
|
SEND_LOG("(ERROR) Load error detected, system can't load file: %s",filename);
|
||||||
#ifdef LOGFILE
|
#ifdef LOGFILE
|
||||||
// bonz_table();
|
// bonz_table();
|
||||||
#endif
|
#endif
|
||||||
|
@ -100,7 +100,7 @@ void *load_file(char *filename)
|
||||||
size_t size;
|
size_t size;
|
||||||
|
|
||||||
if (mman_action!=NULL) mman_action(MMA_READ);
|
if (mman_action!=NULL) mman_action(MMA_READ);
|
||||||
SEND_LOG("(LOAD) Loading file '%s'",filename,0);
|
SEND_LOG("(LOAD) Loading file '%s'",filename);
|
||||||
f=fopen(filename, "rb");
|
f=fopen(filename, "rb");
|
||||||
if (f==NULL) {
|
if (f==NULL) {
|
||||||
load_error(filename);
|
load_error(filename);
|
||||||
|
@ -139,10 +139,10 @@ uint32_t bk_global_counter=0;
|
||||||
char *swap_path;
|
char *swap_path;
|
||||||
|
|
||||||
#ifdef LOGFILE
|
#ifdef LOGFILE
|
||||||
static void bonz_table()
|
void bonz_table()
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
if (bmf==-1) return;
|
if (bmf==NULL) return;
|
||||||
for(i=0;i<nmtab_size;i++)
|
for(i=0;i<nmtab_size;i++)
|
||||||
{
|
{
|
||||||
fprintf(stderr,"%-12.12s %12d\n",nametable[i].name,nametable[i].seek);
|
fprintf(stderr,"%-12.12s %12d\n",nametable[i].name,nametable[i].seek);
|
||||||
|
@ -164,9 +164,9 @@ static int test_file_exist_DOS(int group,char *filename)
|
||||||
|
|
||||||
void load_grp_table()
|
void load_grp_table()
|
||||||
{
|
{
|
||||||
int32_t i;
|
int32_t i = 0;;
|
||||||
|
|
||||||
SEND_LOG("(LOAD) Loading Group Table",0,0);
|
SEND_LOG("(LOAD) Loading Group Table");
|
||||||
fseek(bmf,4,SEEK_SET);
|
fseek(bmf,4,SEEK_SET);
|
||||||
fread(&i,4,1,bmf);
|
fread(&i,4,1,bmf);
|
||||||
grptable=(int32_t *)getmem(i+4);
|
grptable=(int32_t *)getmem(i+4);
|
||||||
|
@ -174,7 +174,7 @@ void load_grp_table()
|
||||||
fread(grptable,i,1,bmf);
|
fread(grptable,i,1,bmf);
|
||||||
grptabsiz=i;
|
grptabsiz=i;
|
||||||
for(i=0;i<(grptabsiz>>3);i++) grptable[i*2+1]=(grptable[i*2+1]-grptabsiz)>>4;
|
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);
|
SEND_LOG("(LOAD) Group Table Loaded");
|
||||||
}
|
}
|
||||||
|
|
||||||
void load_file_table()
|
void load_file_table()
|
||||||
|
@ -182,16 +182,17 @@ void load_file_table()
|
||||||
int strsize;
|
int strsize;
|
||||||
void *p;
|
void *p;
|
||||||
|
|
||||||
SEND_LOG("(LOAD) Loading File Table",0,0);
|
SEND_LOG("(LOAD) Loading File Table");
|
||||||
fseek(bmf,grptabsiz,SEEK_SET);
|
fseek(bmf,grptabsiz,SEEK_SET);
|
||||||
fseek(bmf,12,SEEK_CUR);
|
fseek(bmf,12,SEEK_CUR);
|
||||||
fread(&strsize,4,1,bmf);
|
fread(&strsize,4,1,bmf);
|
||||||
strsize-=grptabsiz;
|
strsize-=grptabsiz;
|
||||||
fseek(bmf,grptabsiz,SEEK_SET);
|
fseek(bmf,grptabsiz,SEEK_SET);
|
||||||
p=getmem(strsize);memcpy(&nametable,&p,4);
|
p=getmem(strsize);
|
||||||
|
nametable = p;
|
||||||
fread(nametable,1,strsize,bmf);
|
fread(nametable,1,strsize,bmf);
|
||||||
nmtab_size=strsize/sizeof(*nametable);
|
nmtab_size=strsize/sizeof(*nametable);
|
||||||
SEND_LOG("(LOAD) File Table Loaded",0,0);
|
SEND_LOG("(LOAD) File Table Loaded");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -232,7 +233,7 @@ int swap_block(THANDLE_DATA *h)
|
||||||
fseek(swap,0,SEEK_END);
|
fseek(swap,0,SEEK_END);
|
||||||
wsize=ftell(swap);
|
wsize=ftell(swap);
|
||||||
fseek(swap,pos,SEEK_SET);
|
fseek(swap,pos,SEEK_SET);
|
||||||
SEND_LOG("(SWAP) Swaping block '%-.12hs'",h->src_file,0);
|
SEND_LOG("(SWAP) Swaping block '%-.12s'",h->src_file);
|
||||||
wsize=fwrite(h->blockdata,1,h->size,swap);
|
wsize=fwrite(h->blockdata,1,h->size,swap);
|
||||||
swap_status=1;
|
swap_status=1;
|
||||||
if ((unsigned)wsize==h->size)
|
if ((unsigned)wsize==h->size)
|
||||||
|
@ -244,7 +245,7 @@ int swap_block(THANDLE_DATA *h)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
SEND_LOG("(SWAP) Swap failed!",0,0);
|
SEND_LOG("(SWAP) Swap failed!");
|
||||||
swap_error();
|
swap_error();
|
||||||
}
|
}
|
||||||
swap_free_block(pos,h->size);
|
swap_free_block(pos,h->size);
|
||||||
|
@ -350,10 +351,10 @@ THANDLE_DATA *kill_block(int handle)
|
||||||
h=get_handle(handle);if (h->status==BK_NOT_USED) return h;
|
h=get_handle(handle);if (h->status==BK_NOT_USED) return h;
|
||||||
if (h->flags & BK_LOCKED)
|
if (h->flags & BK_LOCKED)
|
||||||
{
|
{
|
||||||
SEND_LOG("(ERROR) Unable to kill block! It is LOCKED! '%-.12hs' (%04X)",h->src_file,handle);
|
SEND_LOG("(ERROR) Unable to kill block! It is LOCKED! '%-.12s' (%04X)",h->src_file,handle);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
SEND_LOG("(KILL) Killing block '%-.12hs' (%04X)",h->src_file,handle);
|
SEND_LOG("(KILL) Killing block '%-.12s' (%04X)",h->src_file,handle);
|
||||||
if (h->status==BK_SAME_AS) return h;
|
if (h->status==BK_SAME_AS) return h;
|
||||||
if (h->status==BK_PRESENT) free(h->blockdata);
|
if (h->status==BK_PRESENT) free(h->blockdata);
|
||||||
if (h->flags & BK_HSWAP) swap_free_block(h->seekpos,h->size);
|
if (h->flags & BK_HSWAP) swap_free_block(h->seekpos,h->size);
|
||||||
|
@ -405,7 +406,7 @@ void *load_swaped_block(THANDLE_DATA *h)
|
||||||
|
|
||||||
if (mman_action!=NULL) mman_action(MMA_SWAP_READ);
|
if (mman_action!=NULL) mman_action(MMA_SWAP_READ);
|
||||||
i=getmem(h->size);
|
i=getmem(h->size);
|
||||||
SEND_LOG("(LOAD)(SWAP) Loading block from swap named '%-.12hs'",h->src_file,0);
|
SEND_LOG("(LOAD)(SWAP) Loading block from swap named '%-.12s'",h->src_file);
|
||||||
fseek(swap,h->seekpos,SEEK_SET);
|
fseek(swap,h->seekpos,SEEK_SET);
|
||||||
fread(i,1,h->size,swap);
|
fread(i,1,h->size,swap);
|
||||||
h->status=BK_PRESENT;
|
h->status=BK_PRESENT;
|
||||||
|
@ -451,7 +452,7 @@ THANDLE_DATA *def_handle(int handle,char *filename,void *decompress,char path)
|
||||||
if (i==handle) return h;
|
if (i==handle) return h;
|
||||||
if (kill_block(handle)==NULL)
|
if (kill_block(handle)==NULL)
|
||||||
{
|
{
|
||||||
SEND_LOG("(ERROR) File/Block can't be registred, handle is already in use '%-.12hs' handle %04X",filename,handle);
|
SEND_LOG("(ERROR) File/Block can't be registred, handle is already in use '%-.12s' handle %04X",filename,handle);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
if (i!=-1 && i!=handle)
|
if (i!=-1 && i!=handle)
|
||||||
|
@ -466,8 +467,8 @@ THANDLE_DATA *def_handle(int handle,char *filename,void *decompress,char path)
|
||||||
h->loadproc=decompress;
|
h->loadproc=decompress;
|
||||||
if (filename[0])
|
if (filename[0])
|
||||||
h->seekpos=get_file_entry(path,h->src_file);
|
h->seekpos=get_file_entry(path,h->src_file);
|
||||||
SEND_LOG("(REGISTER) File/Block registred '%-.12hs' handle %04X",h->src_file,handle);
|
SEND_LOG("(REGISTER) File/Block registred '%-.12s' handle %04X",h->src_file,handle);
|
||||||
SEND_LOG("(REGISTER) Seekpos=%d",h->seekpos,0);
|
SEND_LOG("(REGISTER) Seekpos=%d",h->seekpos);
|
||||||
h->flags=0;
|
h->flags=0;
|
||||||
h->path=path;
|
h->path=path;
|
||||||
if (h->status!=BK_DIRLIST) h->status=BK_NOT_LOADED;
|
if (h->status!=BK_DIRLIST) h->status=BK_NOT_LOADED;
|
||||||
|
@ -498,7 +499,7 @@ void *afile(char *filename,int group,int32_t *blocksize)
|
||||||
}
|
}
|
||||||
else if (mman_pathlist!=NULL)
|
else if (mman_pathlist!=NULL)
|
||||||
{
|
{
|
||||||
SEND_LOG("(LOAD) Afile is loading file '%s' from disk",d,group);
|
SEND_LOG("(LOAD) Afile is loading file '%s' from disk (group %d)",d,group);
|
||||||
c=alloca(strlen(filename)+strlen(mman_pathlist[group])+2);
|
c=alloca(strlen(filename)+strlen(mman_pathlist[group])+2);
|
||||||
c=strcat(strcpy(c,mman_pathlist[group]),filename);
|
c=strcat(strcpy(c,mman_pathlist[group]),filename);
|
||||||
p=load_file(c);
|
p=load_file(c);
|
||||||
|
@ -531,7 +532,7 @@ void *ablock(int handle)
|
||||||
void *p;int32_t s;
|
void *p;int32_t s;
|
||||||
char c[200];
|
char c[200];
|
||||||
|
|
||||||
SEND_LOG("(LOAD) Loading file as block '%-.12hs' %04X",h->src_file,handle);
|
SEND_LOG("(LOAD) Loading file as block '%-.12s' %04X",h->src_file,handle);
|
||||||
if (h->seekpos==0)
|
if (h->seekpos==0)
|
||||||
{
|
{
|
||||||
if (h->src_file[0]!=0)
|
if (h->src_file[0]!=0)
|
||||||
|
@ -704,7 +705,7 @@ void undef_handle(int handle)
|
||||||
if (h->status!=BK_NOT_USED)
|
if (h->status!=BK_NOT_USED)
|
||||||
{
|
{
|
||||||
if (kill_block(handle)==NULL) return;
|
if (kill_block(handle)==NULL) return;
|
||||||
SEND_LOG("(REGISTER) File/Block unregistred %04X (%-.12hs)",handle,h->src_file);
|
SEND_LOG("(REGISTER) File/Block unregistred %04X (%-.12s)",handle,h->src_file);
|
||||||
}
|
}
|
||||||
h->src_file[0]=0;
|
h->src_file[0]=0;
|
||||||
h->seekpos=0;
|
h->seekpos=0;
|
||||||
|
@ -840,7 +841,7 @@ char add_patch_file(char *filename)
|
||||||
int32_t poc;
|
int32_t poc;
|
||||||
int i,cc=0;
|
int i,cc=0;
|
||||||
TNAMETABLE p;
|
TNAMETABLE p;
|
||||||
SEND_LOG("Adding patch: %s",filename,0);
|
SEND_LOG("Adding patch: %s",filename);
|
||||||
if (!patch) return 2;
|
if (!patch) return 2;
|
||||||
if (!bmf) return 3;
|
if (!bmf) return 3;
|
||||||
patch=fopen(filename,"rb");
|
patch=fopen(filename,"rb");
|
||||||
|
|
|
@ -3,8 +3,15 @@
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
|
|
||||||
#ifndef _MEMMAN_H_
|
#ifndef _MEMMAN_H_
|
||||||
#define _MEMMAN_H_
|
#define _MEMMAN_H_
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#define freemem(size) free(size);
|
#define freemem(size) free(size);
|
||||||
//#define malloc(size) getmem(size)
|
//#define malloc(size) getmem(size)
|
||||||
#define New(typ) (typ *)getmem(sizeof(typ))
|
#define New(typ) (typ *)getmem(sizeof(typ))
|
||||||
|
@ -110,12 +117,19 @@ void display_status(void); //zobrazi na display status memmanageru
|
||||||
#ifdef LOGFILE
|
#ifdef LOGFILE
|
||||||
char *get_time_str(void);
|
char *get_time_str(void);
|
||||||
int q_current_task(void);
|
int q_current_task(void);
|
||||||
|
void send_log_impl(int task, const char *format, ...) __attribute__((format(printf, 2, 3)));
|
||||||
#define OPEN_LOG(log) memcpy(stderr,fopen(log,"w"),sizeof(FILE));
|
#define OPEN_LOG(log) memcpy(stderr,fopen(log,"w"),sizeof(FILE));
|
||||||
#define SEND_LOG(format,parm1,parm2) fprintf(stderr,"%-2d %s "format"\n",q_current_task(void),get_time_str(void),parm1,parm2),fflush(stderr)
|
#define SEND_LOG(...) send_log_impl(q_current_task(), __VA_ARGS__)
|
||||||
#define CLOSE_LOG(void) fclose(logfile);
|
#define CLOSE_LOG(void) fclose(logfile);
|
||||||
#else
|
#else
|
||||||
#define OPEN_LOG(log)
|
#define OPEN_LOG(log)
|
||||||
#define SEND_LOG(format,parm1,parm2)
|
#define SEND_LOG(...)
|
||||||
#define CLOSE_LOG(void)
|
#define CLOSE_LOG(void)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -34,7 +34,7 @@ int mix_back_sound(int synchro);
|
||||||
int open_backsound(char *filename);
|
int open_backsound(char *filename);
|
||||||
void change_music(const char *filename);
|
void change_music(const char *filename);
|
||||||
int get_timer_value(void);
|
int get_timer_value(void);
|
||||||
char *device_name(int device);
|
const char *device_name(int device);
|
||||||
void force_music_volume(int volume);
|
void force_music_volume(int volume);
|
||||||
|
|
||||||
void set_backsnd_freq(int freq);
|
void set_backsnd_freq(int freq);
|
||||||
|
|
|
@ -1,9 +1,28 @@
|
||||||
|
#include <cstdarg>
|
||||||
|
#include <cstdint>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#include "error.h"
|
#include "error.h"
|
||||||
}
|
}
|
||||||
|
#include "platform.h"
|
||||||
|
|
||||||
|
|
||||||
void display_error(const char *text) {
|
void display_error(const char *text) {
|
||||||
std::cerr << "ERROR:" << text << std::endl;
|
std::cerr << "ERROR:" << text << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static std::uint32_t gtick = get_game_tick_count();
|
||||||
|
void send_log_impl(int task, const char *format, ...) {
|
||||||
|
va_list args;
|
||||||
|
char buff2[1000];
|
||||||
|
va_start(args, format);
|
||||||
|
auto reltik = get_game_tick_count() - gtick;
|
||||||
|
double sec = reltik * 0.001;
|
||||||
|
std::cerr << sec << "[" << task << "]";
|
||||||
|
vsnprintf(buff2,1000,format, args);
|
||||||
|
std::cerr << buff2 << std::endl;
|
||||||
|
va_end(args);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
void display_error(const char *text);
|
void display_error(const char *text);
|
||||||
|
void send_log_impl(int task, const char *format, ...);
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
#include <thread>
|
#include <thread>
|
||||||
#include <atomic>
|
#include <atomic>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
#include <queue>
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
|
|
||||||
struct TaskInfo {
|
struct TaskInfo {
|
||||||
|
@ -13,6 +14,7 @@ struct TaskInfo {
|
||||||
std::chrono::system_clock::time_point _wake_up_after = {};
|
std::chrono::system_clock::time_point _wake_up_after = {};
|
||||||
int wake_up_msg = -1;
|
int wake_up_msg = -1;
|
||||||
bool request_exit = false;
|
bool request_exit = false;
|
||||||
|
bool exited = false;
|
||||||
|
|
||||||
TaskInfo(int id):id(id) {}
|
TaskInfo(int id):id(id) {}
|
||||||
};
|
};
|
||||||
|
@ -32,41 +34,83 @@ static std::atomic<bool> resume_master_flag = {false};
|
||||||
static TaskInfo *current_task_inst = NULL;
|
static TaskInfo *current_task_inst = NULL;
|
||||||
static EVENT_MSG *cur_message = NULL;
|
static EVENT_MSG *cur_message = NULL;
|
||||||
|
|
||||||
|
struct MsgQueue {
|
||||||
|
EVENT_MSG *msg;
|
||||||
|
TaskInfo *sender;
|
||||||
|
};
|
||||||
|
|
||||||
|
static std::queue<MsgQueue> msg_queue;
|
||||||
|
|
||||||
|
void flush_message_queue();
|
||||||
|
|
||||||
static void switch_to_task(TaskInfo *task) {
|
static void switch_to_task(TaskInfo *task) {
|
||||||
if (task == current_task_inst) return;
|
if (task == current_task_inst) return;
|
||||||
if (task == NULL) {
|
if (task == NULL) {
|
||||||
TaskInfo *me = current_task_inst;
|
TaskInfo *me = current_task_inst;
|
||||||
current_task_inst = NULL;
|
current_task_inst = NULL;
|
||||||
me->resume_flag = false;
|
|
||||||
resume_master_flag = true;
|
resume_master_flag = true;
|
||||||
resume_master_flag.notify_all();
|
resume_master_flag.notify_all();
|
||||||
me->resume_flag.wait(false);
|
me->resume_flag.wait(false);
|
||||||
|
me->resume_flag = false;
|
||||||
} else if (current_task_inst == NULL) {
|
} else if (current_task_inst == NULL) {
|
||||||
|
if (task->exited) return ;
|
||||||
current_task_inst = task;
|
current_task_inst = task;
|
||||||
resume_master_flag = false;
|
|
||||||
task->resume_flag = true;
|
task->resume_flag = true;
|
||||||
task->resume_flag.notify_all();
|
task->resume_flag.notify_all();
|
||||||
resume_master_flag.wait(false);
|
resume_master_flag.wait(false);
|
||||||
|
resume_master_flag = false;
|
||||||
|
flush_message_queue();
|
||||||
} else {
|
} else {
|
||||||
|
if (task->exited) return ;
|
||||||
TaskInfo *me = current_task_inst;
|
TaskInfo *me = current_task_inst;
|
||||||
me->resume_flag = false;
|
current_task_inst = task;
|
||||||
task->resume_flag = true;
|
task->resume_flag = true;
|
||||||
task->resume_flag.notify_all();
|
task->resume_flag.notify_all();
|
||||||
me->resume_flag.wait(false);
|
me->resume_flag.wait(false);
|
||||||
|
me->resume_flag = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void clean_task_table() {
|
||||||
|
for (auto iter = task_list.begin(); iter != task_list.end();) {
|
||||||
|
if (iter->second->exited) {
|
||||||
|
iter = task_list.erase(iter);
|
||||||
|
} else {
|
||||||
|
++iter;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void clean_up_current_task() {
|
static void clean_up_current_task() {
|
||||||
TaskInfo *me = current_task_inst;
|
TaskInfo *me = current_task_inst;
|
||||||
if (!me) return;
|
if (!me) return;
|
||||||
int id = me->id;
|
|
||||||
me->thr.detach();
|
me->thr.detach();
|
||||||
task_list.erase(id);
|
me->exited = true;
|
||||||
current_task_inst = NULL;
|
current_task_inst = NULL;
|
||||||
resume_master_flag = true;
|
resume_master_flag = true;
|
||||||
resume_master_flag.notify_all();
|
resume_master_flag.notify_all();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void flush_message_queue() {
|
||||||
|
while (!msg_queue.empty()) {
|
||||||
|
auto m = msg_queue.front();
|
||||||
|
msg_queue.pop();
|
||||||
|
for (auto &[id, task]: task_list) {
|
||||||
|
if (task->wake_up_msg == m.msg->msg && task.get() != m.sender) {
|
||||||
|
EVENT_MSG cpy;
|
||||||
|
cpy.msg = m.msg->msg;
|
||||||
|
va_copy(cpy.data, m.msg->data);
|
||||||
|
cur_message = &cpy;
|
||||||
|
switch_to_task(task.get());
|
||||||
|
va_end(cpy.data);
|
||||||
|
cur_message = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
clean_task_table();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
int add_task(int stack,TaskerFunctionName fcname,...) {
|
int add_task(int stack,TaskerFunctionName fcname,...) {
|
||||||
int id = get_new_task_id();
|
int id = get_new_task_id();
|
||||||
auto st = task_list.emplace(id, std::make_unique<TaskInfo>(id));
|
auto st = task_list.emplace(id, std::make_unique<TaskInfo>(id));
|
||||||
|
@ -75,6 +119,7 @@ int add_task(int stack,TaskerFunctionName fcname,...) {
|
||||||
va_start(args, fcname);
|
va_start(args, fcname);
|
||||||
new_task->thr = std::thread([&]{
|
new_task->thr = std::thread([&]{
|
||||||
new_task->resume_flag.wait(false);
|
new_task->resume_flag.wait(false);
|
||||||
|
new_task->resume_flag = false;
|
||||||
fcname(args);
|
fcname(args);
|
||||||
clean_up_current_task();
|
clean_up_current_task();
|
||||||
});
|
});
|
||||||
|
@ -93,17 +138,13 @@ char is_running(int id_num) {
|
||||||
return id_num < 0 || task_list.find(id_num) != task_list.end();
|
return id_num < 0 || task_list.find(id_num) != task_list.end();
|
||||||
}
|
}
|
||||||
void unsuspend_task(EVENT_MSG *msg) {
|
void unsuspend_task(EVENT_MSG *msg) {
|
||||||
for (auto &[id, task]: task_list) {
|
msg_queue.push({msg, current_task_inst});
|
||||||
if (task->wake_up_msg == msg->msg) {
|
if (current_task_inst) {
|
||||||
EVENT_MSG cpy;
|
switch_to_task(NULL);
|
||||||
cpy.msg = msg->msg;
|
} else {
|
||||||
va_copy(cpy.data, msg->data);
|
flush_message_queue();
|
||||||
cur_message = &cpy;
|
|
||||||
switch_to_task(task.get());
|
|
||||||
va_end(cpy.data);
|
|
||||||
cur_message = NULL;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
void task_sleep(void) {
|
void task_sleep(void) {
|
||||||
if (current_task_inst) {
|
if (current_task_inst) {
|
||||||
|
@ -115,13 +156,14 @@ void task_sleep(void) {
|
||||||
switch_to_task(task.get());
|
switch_to_task(task.get());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
clean_task_table();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
EVENT_MSG *task_wait_event(int32_t event_number) {
|
EVENT_MSG *task_wait_event(int32_t event_number) {
|
||||||
if (current_task_inst == NULL) return NULL;
|
if (current_task_inst == NULL) return NULL;
|
||||||
current_task_inst->wake_up_msg = event_number;
|
current_task_inst->wake_up_msg = event_number;
|
||||||
switch_to_task(NULL);
|
switch_to_task(NULL);
|
||||||
return NULL;
|
return cur_message;
|
||||||
}
|
}
|
||||||
int q_any_task() {
|
int q_any_task() {
|
||||||
return task_list.size();
|
return task_list.size();
|
||||||
|
|
|
@ -26,9 +26,10 @@ char DXInit64(char inwindow,int zoom,int monitor, int refresh) {
|
||||||
get_sdl_global_context().init_screen(mode, "Skeldal"); //todo allow change
|
get_sdl_global_context().init_screen(mode, "Skeldal"); //todo allow change
|
||||||
screen_buffer = std::make_unique<uint16_t[]>(screen_pitch*480);
|
screen_buffer = std::make_unique<uint16_t[]>(screen_pitch*480);
|
||||||
buffer2nd = std::make_unique<uint16_t[]>(screen_pitch*480);
|
buffer2nd = std::make_unique<uint16_t[]>(screen_pitch*480);
|
||||||
|
std::fill(screen_buffer.get(), screen_buffer.get()+screen_pitch*480,0);
|
||||||
render_target = screen_buffer.get();
|
render_target = screen_buffer.get();
|
||||||
|
|
||||||
return 0;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DXCloseMode() {
|
void DXCloseMode() {
|
||||||
|
@ -77,7 +78,7 @@ void StripBlt(void *data, unsigned int startline, uint32_t width) {
|
||||||
while (width--)
|
while (width--)
|
||||||
{
|
{
|
||||||
memcpy(start,data,640*2);
|
memcpy(start,data,640*2);
|
||||||
data=(void *)(reinterpret_cast<char *>(data)+get_sdl_global_context().get_surface_pitch());
|
data=(void *)(reinterpret_cast<short *>(data)+GetScreenPitch());
|
||||||
start=start+GetScreenPitch();
|
start=start+GetScreenPitch();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
add_subdirectory(tests)
|
add_subdirectory(tests)
|
||||||
|
|
||||||
add_library(skeldal_sdl sdl_context.cpp BGraph2.cpp input.cpp sound.cpp)
|
add_library(skeldal_sdl sdl_context.cpp BGraph2.cpp input.cpp sound.cpp)
|
||||||
|
set_property(TARGET skeldal_sdl PROPERTY CXX_STANDARD 20)
|
||||||
|
|
|
@ -15,14 +15,15 @@ void SetWheelMapping(char up, char down) { //todo
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static MS_EVENT ms_event = {};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void get_ms_event(MS_EVENT *event) {
|
void get_ms_event(MS_EVENT *event) {
|
||||||
*event = ms_event;
|
*event = get_sdl_global_context().getMsEvent();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ShareCPU() {
|
void ShareCPU() {
|
||||||
|
if (q_is_mastertask()) {
|
||||||
|
std::this_thread::sleep_for(std::chrono::milliseconds(10));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,7 @@
|
||||||
#include "sdl_context.h"
|
#include "sdl_context.h"
|
||||||
|
|
||||||
|
#include <atomic>
|
||||||
|
#include <cassert>
|
||||||
#include "../platform.h"
|
#include "../platform.h"
|
||||||
|
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
|
@ -44,6 +47,11 @@ SDLContext::SDLContext() {
|
||||||
|
|
||||||
void SDLContext::init_screen(DisplayMode mode, const char *title) {
|
void SDLContext::init_screen(DisplayMode mode, const char *title) {
|
||||||
char buff[256];
|
char buff[256];
|
||||||
|
static Uint32 update_request_event = SDL_RegisterEvents(1);
|
||||||
|
_update_request_event = update_request_event;
|
||||||
|
|
||||||
|
assert(!_render_thread.joinable());
|
||||||
|
|
||||||
|
|
||||||
int width = 640;
|
int width = 640;
|
||||||
int height = 480;
|
int height = 480;
|
||||||
|
@ -51,90 +59,137 @@ void SDLContext::init_screen(DisplayMode mode, const char *title) {
|
||||||
width*=2;
|
width*=2;
|
||||||
height*=2;
|
height*=2;
|
||||||
}
|
}
|
||||||
SDL_Window *window = SDL_CreateWindow(title,
|
|
||||||
SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED,
|
|
||||||
width, height, SDL_WINDOW_RESIZABLE|(mode==fullscreen?SDL_WINDOW_FULLSCREEN_DESKTOP:0));
|
|
||||||
|
|
||||||
if (!window) {
|
|
||||||
snprintf(buff, sizeof(buff), "SDL Error create window: %s\n", SDL_GetError());
|
|
||||||
throw std::runtime_error(buff);
|
|
||||||
}
|
|
||||||
|
|
||||||
_window.reset(window);
|
|
||||||
SDL_Renderer *renderer = SDL_CreateRenderer(_window.get(), -1, 0);
|
|
||||||
if (!renderer) {
|
|
||||||
snprintf(buff,sizeof(buff), "Chyba při vytváření rendereru: %s\n", SDL_GetError());
|
|
||||||
throw std::runtime_error(buff);
|
|
||||||
}
|
|
||||||
_renderer.reset(renderer);
|
|
||||||
// Vytvoření softwarového backbufferu (surface)
|
|
||||||
SDL_Surface *backbuffer = SDL_CreateRGBSurfaceWithFormat(0, 640, 480, 16, SDL_PIXELFORMAT_RGB565);
|
|
||||||
if (!backbuffer) {
|
|
||||||
snprintf(buff,sizeof(buff), "Chyba při vytváření surface: %s\n", SDL_GetError());
|
|
||||||
throw std::runtime_error(buff);
|
|
||||||
}
|
|
||||||
_surface.reset(backbuffer);
|
|
||||||
// Vytvoření textury pro zobrazení backbufferu
|
|
||||||
SDL_Texture *texture = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_RGB565, SDL_TEXTUREACCESS_STREAMING, 640, 480);
|
|
||||||
if (!texture) {
|
|
||||||
snprintf(buff, sizeof(buff), "Chyba při vytváření textury: %s\n", SDL_GetError());
|
|
||||||
throw std::runtime_error(buff);
|
|
||||||
}
|
|
||||||
_texture.reset(texture);
|
|
||||||
|
|
||||||
SDL_LockSurface(_surface.get());
|
|
||||||
|
|
||||||
if (!_timer_event) _timer_event = SDL_RegisterEvents(1);
|
|
||||||
_fullscreen_mode = mode == fullscreen;
|
_fullscreen_mode = mode == fullscreen;
|
||||||
|
|
||||||
|
std::atomic<bool> done = false;
|
||||||
|
std::exception_ptr e;
|
||||||
|
_render_thread = std::jthread([&](std::stop_token stp){
|
||||||
|
bool err = false;
|
||||||
|
try {
|
||||||
|
SDL_Window *window = SDL_CreateWindow(title,
|
||||||
|
SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED,
|
||||||
|
width, height, SDL_WINDOW_RESIZABLE|(mode==fullscreen?SDL_WINDOW_FULLSCREEN_DESKTOP:0));
|
||||||
|
|
||||||
|
if (!window) {
|
||||||
|
snprintf(buff, sizeof(buff), "SDL Error create window: %s\n", SDL_GetError());
|
||||||
|
throw std::runtime_error(buff);
|
||||||
|
}
|
||||||
|
|
||||||
|
_window.reset(window);
|
||||||
|
SDL_Renderer *renderer = SDL_CreateRenderer(_window.get(), -1, 0);
|
||||||
|
if (!renderer) {
|
||||||
|
snprintf(buff,sizeof(buff), "Chyba při vytváření rendereru: %s\n", SDL_GetError());
|
||||||
|
throw std::runtime_error(buff);
|
||||||
|
}
|
||||||
|
_renderer.reset(renderer);
|
||||||
|
// Vytvoření textury pro zobrazení backbufferu
|
||||||
|
SDL_Texture *texture = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_RGB565, SDL_TEXTUREACCESS_STREAMING, 640, 480);
|
||||||
|
if (!texture) {
|
||||||
|
snprintf(buff, sizeof(buff), "Chyba při vytváření textury: %s\n", SDL_GetError());
|
||||||
|
throw std::runtime_error(buff);
|
||||||
|
}
|
||||||
|
_texture.reset(texture);
|
||||||
|
} catch (...) {
|
||||||
|
e = std::current_exception();
|
||||||
|
err = true;
|
||||||
|
}
|
||||||
|
done = true;
|
||||||
|
done.notify_all();
|
||||||
|
if (!err) event_loop(stp);
|
||||||
|
_texture.reset();
|
||||||
|
_renderer.reset();
|
||||||
|
_window.reset();
|
||||||
|
});
|
||||||
|
|
||||||
|
done.wait(false);
|
||||||
|
if (e) {
|
||||||
|
_render_thread.join();
|
||||||
|
std::rethrow_exception(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SDLContext::close_screen() {
|
void SDLContext::close_screen() {
|
||||||
SDL_UnlockSurface(_surface.get());
|
_render_thread.request_stop();
|
||||||
_texture.reset();
|
_render_thread.join();
|
||||||
_surface.reset();
|
|
||||||
_renderer.reset();
|
|
||||||
_window.reset();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
uint16_t* SDLContext::get_surface_addr() {
|
void SDLContext::event_loop(std::stop_token stp) {
|
||||||
return reinterpret_cast<uint16_t *>(_surface->pixels);
|
|
||||||
|
static Uint32 exit_loop_event = SDL_RegisterEvents(1);
|
||||||
|
std::stop_callback stopcb(stp,[&]{
|
||||||
|
SDL_Event event;
|
||||||
|
event.type = exit_loop_event;
|
||||||
|
SDL_PushEvent(&event);
|
||||||
|
});
|
||||||
|
|
||||||
|
SDL_Event e;
|
||||||
|
while (SDL_WaitEvent(&e)) {
|
||||||
|
if (e.type == SDL_QUIT) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (e.type == exit_loop_event) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (e.type == _update_request_event) {
|
||||||
|
update_screen();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (e.type == SDL_KEYDOWN) {
|
||||||
|
if (e.key.keysym.sym == SDLK_RETURN && (e.key.keysym.mod & KMOD_ALT)) {
|
||||||
|
_fullscreen_mode = !_fullscreen_mode;
|
||||||
|
SDL_SetWindowFullscreen(_window.get(), _fullscreen_mode ? SDL_WINDOW_FULLSCREEN_DESKTOP : 0);
|
||||||
|
}
|
||||||
|
} else if (e.type == SDL_MOUSEMOTION) {
|
||||||
|
int mouseX = e.motion.x;
|
||||||
|
int mouseY = e.motion.y;
|
||||||
|
int windowWidth;
|
||||||
|
int windowHeight;
|
||||||
|
SDL_GetWindowSize(_window.get(), &windowWidth, &windowHeight);
|
||||||
|
float normalizedX = (float)mouseX / windowWidth;
|
||||||
|
float normalizedY = (float)mouseY / windowHeight;
|
||||||
|
ms_event.event = 1;
|
||||||
|
ms_event.event_type = 1;
|
||||||
|
ms_event.x = (int16_t)(640*normalizedX);
|
||||||
|
ms_event.y = (int16_t)(480*normalizedY);
|
||||||
|
} else if (e.type == SDL_MOUSEBUTTONDOWN || e.type == SDL_MOUSEBUTTONUP) {
|
||||||
|
int button = e.button.button;
|
||||||
|
int up = e.type == SDL_MOUSEBUTTONUP?1:0;
|
||||||
|
ms_event.event = 1;
|
||||||
|
ms_event.event_type = (1<<(2*button-1+up));
|
||||||
|
switch (button) {
|
||||||
|
default: break;
|
||||||
|
case 1: ms_event.tl1 = !up; break;
|
||||||
|
case 2: ms_event.tl2 = !up; break;
|
||||||
|
case 3: ms_event.tl3 = !up; break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int32_t SDLContext::get_surface_pitch() {
|
/*
|
||||||
return _surface->pitch;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void SDLContext::charge_timer() {
|
|
||||||
_active_timer = SDL_AddTimer(1000/TIMERSPEED, [](Uint32 interval, void *param) -> Uint32 {
|
|
||||||
SDLContext *me = reinterpret_cast<SDLContext *>(param);
|
|
||||||
SDL_Event* event = (SDL_Event*)param;
|
|
||||||
event->type = me->_timer_event;
|
|
||||||
SDL_PushEvent(event);
|
|
||||||
return 0;
|
|
||||||
}, this);
|
|
||||||
|
|
||||||
}
|
|
||||||
void SDLContext::pool_events() {
|
void SDLContext::pool_events() {
|
||||||
if (!_active_timer.has_value()) charge_timer();
|
SDL_RenderClear(_renderer.get());
|
||||||
|
SDL_RenderCopy(_renderer.get(), _texture.get(), NULL, NULL);
|
||||||
|
SDL_RenderPresent(_renderer.get());
|
||||||
|
ms_event.event = 0;
|
||||||
SDL_Event e;
|
SDL_Event e;
|
||||||
while (true) {
|
while (true) {
|
||||||
if (SDL_WaitEvent(&e)) {
|
if (SDL_WaitEvent(&e)) {
|
||||||
if (e.type == SDL_QUIT) {
|
if (e.type == SDL_QUIT) {
|
||||||
_quit_requested = true;
|
_quit_requested = true;
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
if (e.type == _timer_event) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (e.type == SDL_KEYDOWN) {
|
if (e.type == SDL_KEYDOWN) {
|
||||||
if (e.key.keysym.sym == SDLK_RETURN && (e.key.keysym.mod & KMOD_ALT)) {
|
if (e.key.keysym.sym == SDLK_RETURN && (e.key.keysym.mod & KMOD_ALT)) {
|
||||||
_fullscreen_mode = !_fullscreen_mode;
|
_fullscreen_mode = !_fullscreen_mode;
|
||||||
SDL_SetWindowFullscreen(_window.get(), _fullscreen_mode ? SDL_WINDOW_FULLSCREEN_DESKTOP : 0);
|
SDL_SetWindowFullscreen(_window.get(), _fullscreen_mode ? SDL_WINDOW_FULLSCREEN_DESKTOP : 0);
|
||||||
}
|
}
|
||||||
} else if (e.type == SDL_MOUSEMOTION) {
|
} else if (e.type == SDL_MOUSEMOTION) {
|
||||||
|
std::lock_guard _(_mx);
|
||||||
int mouseX = e.motion.x;
|
int mouseX = e.motion.x;
|
||||||
int mouseY = e.motion.y;
|
int mouseY = e.motion.y;
|
||||||
int windowWidth;
|
int windowWidth;
|
||||||
|
@ -147,6 +202,7 @@ void SDLContext::pool_events() {
|
||||||
ms_event.x = (int16_t)(640*normalizedX);
|
ms_event.x = (int16_t)(640*normalizedX);
|
||||||
ms_event.y = (int16_t)(480*normalizedY);
|
ms_event.y = (int16_t)(480*normalizedY);
|
||||||
} else if (e.type == SDL_MOUSEBUTTONDOWN || e.type == SDL_MOUSEBUTTONUP) {
|
} else if (e.type == SDL_MOUSEBUTTONDOWN || e.type == SDL_MOUSEBUTTONUP) {
|
||||||
|
std::lock_guard _(_mx);
|
||||||
int button = e.button.button;
|
int button = e.button.button;
|
||||||
int up = e.type == SDL_MOUSEBUTTONUP?1:0;
|
int up = e.type == SDL_MOUSEBUTTONUP?1:0;
|
||||||
ms_event.event = 1;
|
ms_event.event = 1;
|
||||||
|
@ -164,21 +220,46 @@ void SDLContext::pool_events() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
charge_timer();
|
charge_timer();
|
||||||
|
}*/
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void SDLContext::present_rect(uint16_t *pixels, unsigned int pitch,
|
void SDLContext::present_rect(uint16_t *pixels, unsigned int pitch,
|
||||||
unsigned int x, unsigned int y, unsigned int xs, unsigned ys) {
|
unsigned int x, unsigned int y, unsigned int xs, unsigned ys) {
|
||||||
|
|
||||||
auto beg = pixels + y * pitch + y;
|
|
||||||
|
auto beg = pixels + y * pitch + x;
|
||||||
SDL_Rect r = {static_cast<int>(x),
|
SDL_Rect r = {static_cast<int>(x),
|
||||||
static_cast<int>(y),
|
static_cast<int>(y),
|
||||||
static_cast<int>(xs),
|
static_cast<int>(xs),
|
||||||
static_cast<int>(ys)};
|
static_cast<int>(ys)};
|
||||||
SDL_UpdateTexture(_texture.get(), &r, beg, pitch*2);
|
std::vector<short> data;
|
||||||
SDL_RenderClear(_renderer.get());
|
data.resize(xs*ys);
|
||||||
SDL_RenderCopy(_renderer.get(), _texture.get(), NULL, NULL);
|
auto iter = data.begin();
|
||||||
SDL_RenderPresent(_renderer.get());
|
for (unsigned int yp = 0; yp <ys; ++yp) {
|
||||||
|
iter = std::copy(beg, beg+xs,iter );
|
||||||
|
beg+=pitch;
|
||||||
|
}
|
||||||
|
std::lock_guard _(_mx);
|
||||||
|
if (_display_update_queue.empty()) {
|
||||||
|
SDL_Event event;
|
||||||
|
event.type = _update_request_event;
|
||||||
|
SDL_PushEvent(&event);
|
||||||
|
}
|
||||||
|
_display_update_queue.push_back({std::move(r), std::move(data)});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SDLContext::update_screen() {
|
||||||
|
{
|
||||||
|
std::lock_guard _(_mx);
|
||||||
|
for (const UpdateMsg &msg:_display_update_queue) {
|
||||||
|
SDL_UpdateTexture(_texture.get(), &msg.rc, msg.data.data(), msg.rc.w*2);
|
||||||
|
}
|
||||||
|
_display_update_queue.clear();
|
||||||
|
}
|
||||||
|
SDL_RenderClear(_renderer.get());
|
||||||
|
SDL_RenderCopy(_renderer.get(), _texture.get(), NULL, NULL);
|
||||||
|
SDL_RenderPresent(_renderer.get());
|
||||||
|
}
|
||||||
|
|
|
@ -3,6 +3,8 @@
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <optional>
|
#include <optional>
|
||||||
#include <SDL2/SDL.h>
|
#include <SDL2/SDL.h>
|
||||||
|
#include <thread>
|
||||||
|
#include <vector>
|
||||||
#include <mouse.h>
|
#include <mouse.h>
|
||||||
|
|
||||||
class SDLContext {
|
class SDLContext {
|
||||||
|
@ -22,14 +24,15 @@ public:
|
||||||
void close_screen();
|
void close_screen();
|
||||||
|
|
||||||
|
|
||||||
uint16_t *get_surface_addr();
|
|
||||||
int32_t get_surface_pitch();
|
|
||||||
|
|
||||||
|
|
||||||
void pool_events();
|
|
||||||
|
|
||||||
void present_rect(uint16_t *pixels, unsigned int pitch, unsigned int x, unsigned int y, unsigned int xs,unsigned ys);
|
void present_rect(uint16_t *pixels, unsigned int pitch, unsigned int x, unsigned int y, unsigned int xs,unsigned ys);
|
||||||
|
|
||||||
|
MS_EVENT getMsEvent() {
|
||||||
|
std::lock_guard _(_mx);
|
||||||
|
MS_EVENT out = ms_event;
|
||||||
|
ms_event.event = 0;
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
struct SDL_Deleter {
|
struct SDL_Deleter {
|
||||||
|
@ -43,13 +46,26 @@ protected:
|
||||||
|
|
||||||
std::unique_ptr<SDL_Window, SDL_Deleter> _window;
|
std::unique_ptr<SDL_Window, SDL_Deleter> _window;
|
||||||
std::unique_ptr<SDL_Renderer, SDL_Deleter> _renderer;
|
std::unique_ptr<SDL_Renderer, SDL_Deleter> _renderer;
|
||||||
std::unique_ptr<SDL_Surface, SDL_Deleter> _surface;
|
|
||||||
std::unique_ptr<SDL_Texture, SDL_Deleter> _texture;
|
std::unique_ptr<SDL_Texture, SDL_Deleter> _texture;
|
||||||
|
|
||||||
std::optional<SDL_TimerID> _active_timer;
|
std::jthread _render_thread;
|
||||||
Uint32 _timer_event = 0;
|
|
||||||
|
|
||||||
bool _quit_requested = false;
|
bool _quit_requested = false;
|
||||||
bool _fullscreen_mode = false;
|
bool _fullscreen_mode = false;
|
||||||
|
bool _present = false;
|
||||||
void charge_timer();
|
void charge_timer();
|
||||||
|
|
||||||
|
void event_loop(std::stop_token stp);
|
||||||
|
std::mutex _mx;
|
||||||
|
|
||||||
|
struct UpdateMsg {
|
||||||
|
SDL_Rect rc;
|
||||||
|
std::vector<short> data;
|
||||||
|
};
|
||||||
|
|
||||||
|
std::vector<UpdateMsg> _display_update_queue;
|
||||||
|
Uint32 _update_request_event;
|
||||||
|
|
||||||
|
void update_screen();
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -74,5 +74,10 @@ void DoneVideoSound(void *buffer) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const char *device_name(int )
|
||||||
|
{
|
||||||
|
return "SDL sound device";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue