mirror of
https://github.com/ondra-novak/gates_of_skeldal.git
synced 2025-07-05 14:10:27 -04:00
return to 555, it is more native for this game and SDL supports it
This commit is contained in:
parent
f8a1501289
commit
e717badc45
12 changed files with 67 additions and 76 deletions
|
@ -469,12 +469,12 @@ static void MaskPutPicture(int x, int y, char mask, word color, char blend, cons
|
|||
char *data=(char *)(info+3+256);
|
||||
int32_t scr_linelen2 = GetScreenPitch();
|
||||
word *pos=GetScreenAdr()+x+y*scr_linelen2;
|
||||
if (blend) color=color & 0xF7DE;
|
||||
if (blend) color=color & 0x7BDE;
|
||||
for (y=0;y<info[1];y++,pos+=scr_linelen2,data+=info[0])
|
||||
for (x=0;x<info[0];x++)
|
||||
if (data[x]==mask) {
|
||||
if (blend) {
|
||||
pos[x]=((pos[x] & 0xF7DE)+color)>>1;
|
||||
pos[x]=((pos[x] & 0x7BDE)+color)>>1;
|
||||
} else {
|
||||
pos[x]=color;
|
||||
}
|
||||
|
|
|
@ -215,7 +215,6 @@ void klicovani_anm(void *target,void *source,char mirror)
|
|||
while (c > 0) {
|
||||
word p = *s++;
|
||||
if ((p & 0x8000 ) == 0) {
|
||||
p = p + (p & ~0x1F);
|
||||
--c;
|
||||
t[c] = p;
|
||||
t[c+scr_linelen2] = p;
|
||||
|
@ -237,7 +236,6 @@ void klicovani_anm(void *target,void *source,char mirror)
|
|||
while (c > 0) {
|
||||
word p = *s++;
|
||||
if ((p & 0x8000 ) == 0) {
|
||||
p = p + (p & ~0x1F);
|
||||
t[0] = p;
|
||||
t[scr_linelen2] = p;
|
||||
++t;
|
||||
|
@ -638,7 +636,7 @@ void enemy_draw(const void *src,void *trg,int shade,int scale,int maxspace,int c
|
|||
int xpos = xiter;
|
||||
unsigned char p = row[xtable[xiter]];
|
||||
if (p != 0) {
|
||||
if (p == 1) screen[xpos] = (screen[xpos] & 0xF7DE) >> 1;
|
||||
if (p == 1) screen[xpos] = (screen[xpos] & 0x7BDE) >> 1;
|
||||
else screen[xpos] = palette[p];
|
||||
}
|
||||
++xiter;
|
||||
|
@ -735,7 +733,7 @@ ed_lp3: mov eax,[edx]
|
|||
stosw ;zapis barvu
|
||||
jmp ed_skp2
|
||||
ed_shd: movzx eax,short ptr[edi];vem barvu
|
||||
and eax,0xF7DE ;stmav
|
||||
and eax,0x7BDE ;stmav
|
||||
shr eax,1
|
||||
stosw ;zapis
|
||||
jmp ed_skp2 ;skok na konec
|
||||
|
@ -825,7 +823,7 @@ void enemy_draw_transp(const void *src,void *trg,const void *shade,int scale,int
|
|||
int xpos = xiter -clipl;
|
||||
unsigned char p = row[xtable[xiter]];
|
||||
if (p != 0) {
|
||||
if (p & 0x80) screen[xpos] = ((screen[xpos] & 0xF7DE) + (palette[p] & 0xF7DE))>>1;
|
||||
if (p & 0x80) screen[xpos] = ((screen[xpos] & 0x7BDE) + (palette[p] & 0x7BDE))>>1;
|
||||
else screen[xpos] = palette[p];
|
||||
}
|
||||
++xiter;
|
||||
|
@ -921,9 +919,9 @@ et_lp3: mov eax,[edx]
|
|||
mov eax,[ebx+eax*2];vyzvedni hicolor
|
||||
stosw ;zapis barvu
|
||||
jmp et_skp2
|
||||
et_shd: and short ptr[edi],0xF7DE ;1111 0111 1101 1110
|
||||
et_shd: and short ptr[edi],0x7BDE ;1111 0111 1101 1110
|
||||
mov eax,[ebx+eax*2];vyzvedni hicolor
|
||||
and eax,0xF7DE ;stmav
|
||||
and eax,0x7BDE ;stmav
|
||||
add ax,short ptr[edi]
|
||||
rcr ax,1
|
||||
stosw ;zapis
|
||||
|
@ -1014,8 +1012,12 @@ void enemy_draw_mirror_transp(const void *src,void *trg,const void *shade,int sc
|
|||
int xpos = xiter -clipl;
|
||||
unsigned char p = row[xtable[xiter]];
|
||||
if (p != 0) {
|
||||
if (p & 0x80) screen[xpos] = ((screen[xpos] & 0xF7DE) + (palette[p] & 0xF7DE))>>1;
|
||||
else screen[xpos] = palette[p];
|
||||
if (p & 0x80) {
|
||||
screen[xpos] = ((screen[xpos] & 0x7BDE) + (palette[p] & 0x7BDE))>>1;
|
||||
}
|
||||
else {
|
||||
screen[xpos] = palette[p];
|
||||
}
|
||||
}
|
||||
++xiter;
|
||||
}
|
||||
|
@ -1108,9 +1110,9 @@ etmlp3: mov eax,[edx]
|
|||
mov eax,[ebx+eax*2];vyzvedni hicolor
|
||||
stosw ;zapis barvu
|
||||
jmp etmskp2
|
||||
etmshd: and short ptr[edi],0xF7DE
|
||||
etmshd: and short ptr[edi],0x7BDE
|
||||
mov eax,[ebx+eax*2];vyzvedni hicolor
|
||||
and eax,0xF7DE ;stmav
|
||||
and eax,0x7BDE ;stmav
|
||||
add ax,short ptr[edi]
|
||||
rcr ax,1
|
||||
stosw ;zapis
|
||||
|
@ -1200,7 +1202,7 @@ void enemy_draw_mirror(const void *src,void *trg,int shade,int scale,int maxspac
|
|||
int xpos = xiter;
|
||||
unsigned char p = row[xtable[xiter]];
|
||||
if (p != 0) {
|
||||
if (p == 1) screen[xpos] = (screen[xpos] & 0xF7DE) >> 1;
|
||||
if (p == 1) screen[xpos] = (screen[xpos] & 0x7BDE) >> 1;
|
||||
else screen[xpos] = palette[p];
|
||||
}
|
||||
++xiter;
|
||||
|
@ -1294,7 +1296,7 @@ edmlp3: mov eax,[edx]
|
|||
stosw ;zapis barvu
|
||||
jmp edmskp2
|
||||
edmshd: movzx eax,short ptr[edi];vem barvu
|
||||
and eax,0xF7DE ;stmav
|
||||
and eax,0x7BDE ;stmav
|
||||
shr eax,1
|
||||
stosw ;zapis
|
||||
jmp edmskp2 ;skok na konec
|
||||
|
|
22
game/inv.c
22
game/inv.c
|
@ -143,26 +143,6 @@ void item_sound_event(int item,int sector)
|
|||
play_sample_at_sector(glob_items[item].sound+sound_handle,viewsector,sector,0,0);
|
||||
}
|
||||
|
||||
static const void *items_15to16_correct(const void *p,int32_t *s)
|
||||
{
|
||||
int i,j;
|
||||
void *np = getmem(*s);
|
||||
memcpy(np, p, *s);
|
||||
char *cur=(char *)(np);
|
||||
for (i=0;i<IT_LIB_SIZE;i++)
|
||||
{
|
||||
int pos=IT_ICONE_SIZE*i;
|
||||
word *pal;
|
||||
|
||||
if (pos>=*s) return np;
|
||||
pal=((word *)(cur+pos))+3;
|
||||
for (j=0;j<256;j++,pal++)
|
||||
{
|
||||
*pal=RGB555(*pal>>10,(*pal>>5)& 0x1F,(*pal & 0x1F));
|
||||
}
|
||||
}
|
||||
return np;
|
||||
}
|
||||
|
||||
void load_items()
|
||||
{
|
||||
|
@ -179,7 +159,7 @@ void load_items()
|
|||
char name[200];
|
||||
sprintf(name, IT_LIB_NAME, i++);
|
||||
if (test_file_exist(SR_ITEMS, name)) {
|
||||
def_handle(hl_ptr++, name, items_15to16_correct, SR_ITEMS);
|
||||
def_handle(hl_ptr++, name, NULL, SR_ITEMS);
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -180,7 +180,7 @@ static void animace_kouzla(int act,const void *data, int ssize)
|
|||
case MGIF_LZW:
|
||||
case MGIF_COPY:show_full_lfb12e(anim_render_buffer,data,paleta);break;
|
||||
case MGIF_DELTA:show_delta_lfb12e(anim_render_buffer,data,paleta);break;
|
||||
case MGIF_PAL:memcpy(paleta,data,sizeof(paleta));paleta[0]|=0x8000;break;
|
||||
case MGIF_PAL:memcpy(paleta,data,sizeof(paleta));paleta[0]|=BGSWITCHBIT;break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1847,7 +1847,8 @@ char mask_click(int id,int xa,int ya,int xr,int yr)
|
|||
souboje_stisknout(d);
|
||||
switch(d)
|
||||
{
|
||||
case AC_RUN: postavy[select_player].utek=5+postavy[select_player].actions;break;
|
||||
case AC_RUN: postavy[select_player].utek=5+postavy[select_player].actions;
|
||||
[[fallthrough]];
|
||||
case AC_ATTACK:
|
||||
case AC_STAND:
|
||||
case AC_ARMOR:
|
||||
|
|
|
@ -120,6 +120,10 @@ void line_32(int x,int y,int xs,int ys)
|
|||
}
|
||||
}
|
||||
|
||||
static inline word avg_pixels(word a, word b) {
|
||||
return ((a & 0x7BDE)+(b & 0x7BDE)) >> 1;
|
||||
}
|
||||
|
||||
|
||||
void char_32(word *posit,const word *font,char znak)
|
||||
//#pragma aux char_32 parm [edi] [esi] [eax] modify [eax ebx ecx edx]
|
||||
|
@ -149,7 +153,7 @@ chr5:
|
|||
ax = charcolors[(al-1)];
|
||||
if (ax == 0xFFFF) goto chr4;
|
||||
if (ax & BGSWITCHBIT) {
|
||||
ax = ((*ebx & 0xF7DF) + (ax & 0xF7DF)) >> 1;
|
||||
ax = avg_pixels(*ebx ,ax);
|
||||
}
|
||||
*ebx = ax;
|
||||
goto chr4;
|
||||
|
@ -339,7 +343,8 @@ void put_picture(word x,word y,const void *p)
|
|||
for (i=0;i<yss;i++,adr+=scr_linelen2,data+=(xs-xss))
|
||||
for (j=0;j<xss;j++)
|
||||
{
|
||||
adr[j]=((*data & ~0x1f)<<1) | (*data & 0x1f);
|
||||
// adr[j]=((*data & ~0x1f)<<1) | (*data & 0x1f);
|
||||
adr[j]=*data;
|
||||
data++;
|
||||
}
|
||||
}
|
||||
|
@ -400,7 +405,7 @@ void get_picture(word x,word y,word xs,word ys,void *p)
|
|||
|
||||
data[0]=xss;
|
||||
data[1]=yss;
|
||||
data[2]=16;
|
||||
data[2]=15;
|
||||
data+=3;
|
||||
{
|
||||
int i;
|
||||
|
@ -644,7 +649,7 @@ ptb_skip2:
|
|||
}
|
||||
}
|
||||
*/
|
||||
#define MIXTRANSP(a,b) ((((a) & 0xF7DE)+((b) & 0xF7DE))>>1)
|
||||
#define MIXTRANSP(a,b) ((((a) & 0x7BDE)+((b) & 0x7BDE))>>1)
|
||||
|
||||
void trans_bar(int x,int y,int xs,int ys,int barva)
|
||||
{
|
||||
|
|
|
@ -13,14 +13,14 @@ static short mgif_accnums[2];
|
|||
static int32_t mgif_writepos;
|
||||
|
||||
|
||||
static word *paleta;
|
||||
static const word *paleta;
|
||||
|
||||
static word *picture;
|
||||
static word *anim_render_buffer;
|
||||
static void *sound;
|
||||
|
||||
static inline word avg_pixels(word a, word b) {
|
||||
return ((a & 0xF7DE)+(a & 0xF7DE)) >> 1;
|
||||
return ((a & 0x7BDE)+(b & 0x7BDE)) >> 1;
|
||||
}
|
||||
|
||||
static void StretchImageHQ(word *src, word *trg, int32_t linelen, char full)
|
||||
|
@ -86,7 +86,7 @@ static void StretchImageHQ(word *src, word *trg, int32_t linelen, char full)
|
|||
word n5 = avg_pixels(n1, n2);
|
||||
word n6 = avg_pixels(n3, n4);
|
||||
word n7 = avg_pixels(n5, n6);
|
||||
trg_row[x+linelen] = n7;
|
||||
trg_row[x+linelen] = avg_pixels(n7,0);
|
||||
}
|
||||
trg_row += 2*linelen;
|
||||
}
|
||||
|
@ -167,13 +167,7 @@ void show_delta_lfb12e_dx(void *target,void *buff,void *paleta);
|
|||
void show_full_lfb12e_dx(void *target,void *buff,void *paleta);
|
||||
|
||||
|
||||
word * load_mgf_palette(const word *pal) {
|
||||
static word paleta[256];
|
||||
for (int i = 0; i < 256; ++i) {
|
||||
paleta[i] = pal[i]+(pal[i]&0x7fe0);
|
||||
}
|
||||
return paleta;
|
||||
}
|
||||
|
||||
|
||||
void BigPlayProc(int act,const void *data,int csize)
|
||||
{
|
||||
|
@ -182,7 +176,7 @@ void BigPlayProc(int act,const void *data,int csize)
|
|||
case MGIF_LZW:
|
||||
case MGIF_COPY:show_full_lfb12e(anim_render_buffer,data,paleta);break;
|
||||
case MGIF_DELTA:show_delta_lfb12e(anim_render_buffer,data,paleta);break;
|
||||
case MGIF_PAL:paleta=load_mgf_palette(data);break;
|
||||
case MGIF_PAL:paleta=data;break;
|
||||
case MGIF_SOUND:
|
||||
while (LoadNextVideoFrame(sound,data,csize,mgif_header->ampl_table,mgif_accnums,&mgif_writepos)==0);
|
||||
}
|
||||
|
|
|
@ -24,9 +24,8 @@ public:
|
|||
iter += 4;
|
||||
blocks = read_int();
|
||||
iter += 8;
|
||||
std::memcpy(btable,iter,sizeof(btable));
|
||||
iter += sizeof(btable);
|
||||
btable[0] = -31767;
|
||||
btable = reinterpret_cast<const short *>(iter);
|
||||
iter += 512;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -65,7 +64,7 @@ protected:
|
|||
std::int16_t chans;
|
||||
std::int32_t freq;
|
||||
std::int32_t blocks;
|
||||
short btable[256];
|
||||
const short *btable;
|
||||
const uint8_t *iter;
|
||||
std::vector<int16_t> outbuff;
|
||||
std::string_view unprocessed_buffer;
|
||||
|
@ -96,12 +95,10 @@ protected:
|
|||
uint8_t p = *iter++;
|
||||
short val=accum[c]+btable[p];
|
||||
accum[c]=val;
|
||||
/*
|
||||
if (p==0) //pridano jako provizorni reseni pro korekci chyby komprimacniho programu
|
||||
if (p==0) //a bug in compression algorithm
|
||||
{
|
||||
val-=31767;
|
||||
}
|
||||
*/
|
||||
c = (c + 1) % chans;
|
||||
outbuff.push_back(val);
|
||||
}
|
||||
|
|
14
libs/pcx.c
14
libs/pcx.c
|
@ -68,7 +68,7 @@ void palette_shadow(const char *pal1,unsigned short pal2[][256],int tr,int tg,in
|
|||
r=(tr+(*(bt++)-tr)*(3*SHADE_STEPS-3*j-1)/(3*SHADE_STEPS-1))>>3;
|
||||
g=(tg+(*(bt++)-tg)*(3*SHADE_STEPS-3*j-1)/(3*SHADE_STEPS-1))>>3;
|
||||
b=(tb+(*(bt++)-tb)*(3*SHADE_STEPS-3*j-1)/(3*SHADE_STEPS-1))>>3;
|
||||
hi=(r<<11)+(g<<6)+b;
|
||||
hi=RGB555(r,g,b);
|
||||
pal2[j][i]=hi;
|
||||
}
|
||||
while (++i & 0xff);
|
||||
|
@ -82,7 +82,7 @@ void palette_shadow(const char *pal1,unsigned short pal2[][256],int tr,int tg,in
|
|||
r=((*(bt++))*(SHADE_STEPS-j)/SHADE_STEPS)>>3;
|
||||
g=((*(bt++))*(SHADE_STEPS-j)/SHADE_STEPS)>>3;
|
||||
b=((*(bt++))*(SHADE_STEPS-j)/SHADE_STEPS)>>3;
|
||||
hi=(r<<11)+(g<<6)+b;
|
||||
hi=RGB555(r,g,b);
|
||||
pal2[j+SHADE_STEPS][i]=hi;
|
||||
}
|
||||
while (++i & 0xff);
|
||||
|
@ -111,10 +111,12 @@ int load_pcx(const char *pcx,int32_t fsize,int conv_type,char **buffer, ... )
|
|||
memcpy(get_palette_ptr,ptr1,768);
|
||||
for (i=0;i<256;i++)
|
||||
{
|
||||
*ptr2=*(ptr1++)>>3;
|
||||
*ptr2=(*ptr2<<5)+(*(ptr1++)>>3);
|
||||
*ptr2=(*ptr2<<6)+(*(ptr1++)>>3);
|
||||
ptr2++;
|
||||
int r = ptr1[0];
|
||||
int g = ptr1[1];
|
||||
int b = ptr1[2];
|
||||
*ptr2 = RGB888(r,g,b);
|
||||
++ptr2;
|
||||
ptr1+=3;
|
||||
}
|
||||
|
||||
memcpy(&pcxdata,pcx,sizeof(pcxdata));
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
#ifndef _SKELDAL_PLATFORM_HEADER_
|
||||
#define _SKELDAL_PLATFORM_HEADER_
|
||||
|
||||
#define BGSWITCHBIT 0x0020
|
||||
#define BGSWITCHBIT 0x8000
|
||||
|
||||
|
||||
#define SKELDALINI "skeldal.ini"
|
||||
|
@ -24,9 +24,9 @@ extern "C"
|
|||
uint32_t _bios_keybrd(int mode);
|
||||
|
||||
|
||||
#define RGB888(r,g,b) ((unsigned short)((((r)<<8)&0xF800) | (((g)<<3) & 0x7C0) | ((b)>>3)))
|
||||
#define RGB555(r,g,b) (((unsigned short)(((r)<<11) | ((g)<<6) | (b))) & ~BGSWITCHBIT)
|
||||
#define RGB555_ALPHA(r,g,b) (((unsigned short)(((r)<<11) | ((g)<<6) | (b))) | BGSWITCHBIT)
|
||||
#define RGB888(r,g,b) ((unsigned short)((((r)<<7)&0x7C00) | (((g)<<2) & 0x3E0) | ((b)>>3)))
|
||||
#define RGB555(r,g,b) (((unsigned short)(((r)<<10) | ((g)<<5) | (b))) & ~BGSWITCHBIT)
|
||||
#define RGB555_ALPHA(r,g,b) (((unsigned short)(((r)<<10) | ((g)<<5) | (b))) | BGSWITCHBIT)
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -135,14 +135,14 @@ void SDLContext::init_video(const VideoConfig &config, const char *title) {
|
|||
}
|
||||
|
||||
_renderer.reset(renderer);
|
||||
SDL_Texture *texture = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_RGB565, SDL_TEXTUREACCESS_STREAMING, 640, 480);
|
||||
SDL_Texture *texture = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_ARGB1555, 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);
|
||||
}
|
||||
SDL_SetTextureBlendMode(texture, SDL_BLENDMODE_BLEND);
|
||||
_texture.reset(texture);
|
||||
texture = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_RGB565, SDL_TEXTUREACCESS_STREAMING, 640, 480);
|
||||
texture = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_ARGB1555, 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);
|
||||
|
@ -400,8 +400,14 @@ void SDLContext::push_item(const std::string_view &item) {
|
|||
void SDLContext::push_update_msg(const SDL_Rect &rc, const uint16_t *data, int pitch) {
|
||||
push_item(DisplayRequest::update);
|
||||
push_item(rc);
|
||||
auto sz = _display_update_queue.size();
|
||||
_display_update_queue.resize(sz+rc.w*rc.h*2);
|
||||
short *trg = reinterpret_cast<short *>(_display_update_queue.data()+sz);
|
||||
for (int yp = 0; yp < rc.h; ++yp) {
|
||||
push_item(std::string_view(reinterpret_cast<const char *>(data), rc.w*2));
|
||||
for (int xp = 0; xp < rc.w; ++xp) {
|
||||
*trg = data[xp] ^ 0x8000;
|
||||
++trg;
|
||||
}
|
||||
data += pitch;
|
||||
}
|
||||
}
|
||||
|
|
10
skeldal.ini
10
skeldal.ini
|
@ -14,9 +14,6 @@
|
|||
# data=./
|
||||
# savegame = determine default
|
||||
|
||||
|
||||
|
||||
|
||||
#### video settings
|
||||
#
|
||||
# fullscreen = run game in fullscreen mode
|
||||
|
@ -42,4 +39,11 @@
|
|||
#aspect_ratio=4:3
|
||||
|
||||
|
||||
### audio settings
|
||||
#
|
||||
# device = name of sound device, optionally with arguments (see SDL_OpenAudioDevice)
|
||||
# (default - use the most suitable device)
|
||||
[audio]
|
||||
#device=
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue