mirror of
https://github.com/ondra-novak/gates_of_skeldal.git
synced 2025-07-05 06:00:33 -04:00
new filters, cztable, fix crash in enemy drawing
This commit is contained in:
parent
83933755df
commit
a8556070ad
10 changed files with 176 additions and 98 deletions
|
@ -513,7 +513,7 @@ void enemy_draw(const void *src,void *trg,int shade,int scale,int maxspace,int c
|
|||
int rwofs = pcx*(pcy-1);
|
||||
int accu = 0;
|
||||
int *w = ytable;
|
||||
int sp = maxspace*2;
|
||||
int sp = maxspace;
|
||||
|
||||
while (sp > 0 && rwofs >= 0) {
|
||||
*w++ = rwofs;
|
||||
|
@ -700,7 +700,7 @@ void enemy_draw_transp(const void *src,void *trg,const void *shade,int scale,int
|
|||
int rwofs = pcx*(pcy-1);
|
||||
int accu = 0;
|
||||
int *w = ytable;
|
||||
int sp = maxspace*2;
|
||||
int sp = maxspace;
|
||||
|
||||
while (sp > 0 && rwofs >= 0) {
|
||||
*w++ = rwofs;
|
||||
|
@ -889,7 +889,7 @@ void enemy_draw_mirror_transp(const void *src,void *trg,const void *shade,int sc
|
|||
int rwofs = pcx*(pcy-1);
|
||||
int accu = 0;
|
||||
int *w = ytable;
|
||||
int sp = maxspace*2;
|
||||
int sp = maxspace;
|
||||
|
||||
while (sp > 0 && rwofs >= 0) {
|
||||
*w++ = rwofs;
|
||||
|
@ -1079,7 +1079,7 @@ void enemy_draw_mirror(const void *src,void *trg,int shade,int scale,int maxspac
|
|||
int rwofs = pcx*(pcy-1);
|
||||
int accu = 0;
|
||||
int *w = ytable;
|
||||
int sp = maxspace*2;
|
||||
int sp = maxspace;
|
||||
|
||||
while (sp > 0 && rwofs >= 0) {
|
||||
*w++ = rwofs;
|
||||
|
|
24
game/kniha.c
24
game/kniha.c
|
@ -1,4 +1,5 @@
|
|||
#include <platform/platform.h>
|
||||
#include <libs/cztable.h>
|
||||
/*
|
||||
|
||||
Popis jazyka pro psani textu do knihy
|
||||
|
@ -98,20 +99,6 @@ static int picture_len=0;
|
|||
static char winconv=0;
|
||||
static int relpos=0;
|
||||
|
||||
//static char xlat_table[128]="<22>__<5F><5F>_____<5F>_____<5F>__<5F><5F>__________________________________<5F>___<5F>__<5F><5F>__<5F><5F>_<EFBFBD>__<5F><5F>____<5F><5F><EFBFBD>__<5F>___<5F>___<5F>__<5F><5F>__<5F><5F>_<EFBFBD>__<5F><5F>____<5F><5F><EFBFBD>__<5F>";
|
||||
static char xlat_table[128] = {
|
||||
0x9b, 0x5f, 0x5f, 0x86, 0x92, 0x5f, 0x5f, 0x5f, 0x5f, 0x5f, 0xad, 0x5f,
|
||||
0x5f, 0x5f, 0x5f, 0x5f, 0xa8, 0x5f, 0x5f, 0x9f, 0x91, 0x5f, 0x5f, 0x5f,
|
||||
0x5f, 0x5f, 0x5f, 0x5f, 0x5f, 0x5f, 0x5f, 0x5f, 0x5f, 0x5f, 0x5f, 0x5f,
|
||||
0x5f, 0x5f, 0x5f, 0x5f, 0x5f, 0x5f, 0x5f, 0x5f, 0x5f, 0x5f, 0x5f, 0x5f,
|
||||
0x5f, 0x5f, 0x5f, 0x5f, 0x5f, 0x5f, 0x5f, 0x8f, 0x5f, 0x5f, 0x5f, 0x8a,
|
||||
0x5f, 0x5f, 0x80, 0x90, 0x5f, 0x5f, 0x89, 0x8b, 0x5f, 0x85, 0x5f, 0x5f,
|
||||
0xa5, 0x95, 0x5f, 0x5f, 0x5f, 0x5f, 0x9e, 0xa6, 0x97, 0x5f, 0x5f, 0x9d,
|
||||
0x5f, 0x5f, 0x5f, 0xa0, 0x5f, 0x5f, 0x5f, 0x8d, 0x5f, 0x5f, 0x87, 0x82,
|
||||
0x5f, 0x5f, 0x88, 0xa1, 0x5f, 0x83, 0x5f, 0x5f, 0xa4, 0xa2, 0x5f, 0x5f,
|
||||
0x5f, 0x5f, 0xa9, 0x96, 0xa3, 0x5f, 0x5f, 0x98, 0x0a
|
||||
};
|
||||
|
||||
static int insert_num(char *text,int pos,int num)
|
||||
{
|
||||
char c=0x80;
|
||||
|
@ -449,11 +436,7 @@ static char skip_section(TMPFILE_RD *txt)
|
|||
|
||||
void prekodovat(char *c)
|
||||
{
|
||||
while (*c)
|
||||
{
|
||||
if (*c>137) *c=xlat_table[*c-138];
|
||||
c++;
|
||||
}
|
||||
windows2kamenik(c, strlen(c), c);
|
||||
}
|
||||
|
||||
static void read_text(TMPFILE_RD *txt)
|
||||
|
@ -493,7 +476,7 @@ static void read_text(TMPFILE_RD *txt)
|
|||
}
|
||||
else wsp=0;
|
||||
if (i=='&') i=temp_storage_getc(txt);
|
||||
if (winconv && i>137) i=xlat_table[i-138];
|
||||
if (winconv) i=windows2kamenik_chr(i);
|
||||
ss[0]=i;
|
||||
xs+=text_width(ss);
|
||||
read_buff[buff_end++]=i;
|
||||
|
@ -528,7 +511,6 @@ static void seek_section(TMPFILE_RD *txt,int sect_number)
|
|||
}
|
||||
if (i==sect_number)
|
||||
{
|
||||
c=temp_storage_getc(txt);
|
||||
while(c!=']')
|
||||
{
|
||||
if (c=='W' || c=='w') winconv=1;
|
||||
|
|
|
@ -14,6 +14,7 @@ SET(files basicobj.c
|
|||
strlite.c
|
||||
wav_mem.c
|
||||
strlists.c
|
||||
cztable.c
|
||||
music.cpp
|
||||
swaper.c )
|
||||
|
||||
|
|
|
@ -1,51 +1,51 @@
|
|||
#include <string.h>
|
||||
|
||||
struct czxlat
|
||||
typedef struct czxlat
|
||||
{
|
||||
unsigned char kamenik;
|
||||
unsigned char windows;
|
||||
};
|
||||
} CZXLAT;
|
||||
|
||||
|
||||
static czxlat czxlattab[]=
|
||||
static CZXLAT czxlattab[]=
|
||||
{
|
||||
{0xA0,'á'},
|
||||
{0x87,'è'},
|
||||
{0x83,'ï'},
|
||||
{0x82,'é'},
|
||||
{0x88,'ì'},
|
||||
{0xA1,'í'},
|
||||
{0x8D,'å'},
|
||||
{0x8C,'¾'},
|
||||
{0xA4,'ò'},
|
||||
{0xA2,'ó'},
|
||||
{0xAA,'à'},
|
||||
{0xA9,'ø'},
|
||||
{0xA8,'š'},
|
||||
{0x9f,'<EFBFBD>'},
|
||||
{0xA3,'ú'},
|
||||
{0x96,'ù'},
|
||||
{0x98,'ý'},
|
||||
{0x91,'ž'},
|
||||
{0xA0,0xE1},
|
||||
{0x87,0xE8},
|
||||
{0x83,0xEF},
|
||||
{0x82,0xE9},
|
||||
{0x88,0xEC},
|
||||
{0xA1,0xED},
|
||||
{0x8D,0xE5},
|
||||
{0x8C,0xBE},
|
||||
{0xA4,0xF2},
|
||||
{0xA2,0xF3},
|
||||
{0xAA,0xE0},
|
||||
{0xA9,0xF8},
|
||||
{0xA8,0x9A},
|
||||
{0x9f,0x9D},
|
||||
{0xA3,0xFA},
|
||||
{0x96,0xF9},
|
||||
{0x98,0xFD},
|
||||
{0x91,0x9E},
|
||||
|
||||
{0x8F,'Á'},
|
||||
{0x80,'È'},
|
||||
{0x85,'Ï'},
|
||||
{0x90,'É'},
|
||||
{0x89,'Ì'},
|
||||
{0x8B,'Í'},
|
||||
{0x8A,'Å'},
|
||||
{0x9C,'¼'},
|
||||
{0xA5,'Ò'},
|
||||
{0x95,'Ó'},
|
||||
{0xAB,'À'},
|
||||
{0x9E,'Ø'},
|
||||
{0x9B,'Š'},
|
||||
{0x86,'<EFBFBD>'},
|
||||
{0x97,'Ú'},
|
||||
{0xA6,'Ù'},
|
||||
{0x9D,'Ý'},
|
||||
{0x92,'Ž'},
|
||||
{0x8F,0xC1},
|
||||
{0x80,0xC8},
|
||||
{0x85,0xCF},
|
||||
{0x90,0xC9},
|
||||
{0x89,0xCC},
|
||||
{0x8B,0xCD},
|
||||
{0x8A,0xC5},
|
||||
{0x9C,0xBC},
|
||||
{0xA5,0xD2},
|
||||
{0x95,0xD3},
|
||||
{0xAB,0xC0},
|
||||
{0x9E,0xD8},
|
||||
{0x9B,0x8A},
|
||||
{0x86,0x8D},
|
||||
{0x97,0xDA},
|
||||
{0xA6,0xD9},
|
||||
{0x9D,0xDD},
|
||||
{0x92,0x8E},
|
||||
};
|
||||
|
||||
static char xlatkm2win[256];
|
||||
|
@ -54,7 +54,7 @@ static char prepare=1;
|
|||
|
||||
static void PrepareTabs()
|
||||
{
|
||||
int i;
|
||||
unsigned int i;
|
||||
for (i=0;i<256;i++) {xlatkm2win[i]=i;xlatwin2km[i]=i;}
|
||||
for (i=0;i<sizeof(czxlattab)/sizeof(czxlattab[0]);i++)
|
||||
{
|
||||
|
@ -64,8 +64,6 @@ static void PrepareTabs()
|
|||
prepare=0;
|
||||
}
|
||||
|
||||
extern "C"
|
||||
{
|
||||
|
||||
void windows2kamenik(const char *src, int size, char *trg)
|
||||
{
|
||||
|
@ -81,4 +79,13 @@ void kamenik2windows(const char *src, int size, char *trg)
|
|||
for (int i=0;i<size;i++) *trg++=xlatkm2win[(unsigned char)*src++];
|
||||
}
|
||||
|
||||
|
||||
int windows2kamenik_chr(int chr){
|
||||
if (prepare) PrepareTabs();
|
||||
return xlatwin2km[chr & 0xFF];
|
||||
|
||||
}
|
||||
int kamenik2windows_chr(int chr) {
|
||||
if (prepare) PrepareTabs();
|
||||
return xlatkm2win[chr & 0xFF];
|
||||
}
|
|
@ -8,7 +8,8 @@ extern "C" {
|
|||
|
||||
void windows2kamenik(const char *src, int size, char *trg);
|
||||
void kamenik2windows(const char *src, int size, char *trg);
|
||||
|
||||
int windows2kamenik_chr(int chr);
|
||||
int kamenik2windows_chr(int chr);
|
||||
|
||||
|
||||
|
|
@ -31,12 +31,14 @@ char game_display_init(const INI_CONFIG_SECTION *display_section, const char *ti
|
|||
cfg.scale_quality = ini_get_string(display_section, "scale_quality", "auto");
|
||||
cfg.window_height = ini_get_int(display_section, "window_height", 480);
|
||||
cfg.window_width = ini_get_int(display_section, "window_width", 640);
|
||||
cfg.crt_filter = ini_get_boolean(display_section, "crt_filter", 1) == 1;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
const char *filter = ini_get_string(display_section, "crt_filter", "auto");
|
||||
if (stricmp(filter,"none") == 0) cfg.crt_filter = SDLContext::CrtFilterType::none;
|
||||
else if (stricmp(filter,"scanlines") == 0) cfg.crt_filter = SDLContext::CrtFilterType::scanlines;
|
||||
else if (stricmp(filter,"scanlines_2") == 0) cfg.crt_filter = SDLContext::CrtFilterType::scanlines_2;
|
||||
else if (stricmp(filter,"rgbmatrix_2") == 0) cfg.crt_filter = SDLContext::CrtFilterType::rgb_matrix_2;
|
||||
else if (stricmp(filter,"rgbmatrix_3") == 0) cfg.crt_filter = SDLContext::CrtFilterType::rgb_matrix_3;
|
||||
else cfg.crt_filter = SDLContext::CrtFilterType::autoselect;
|
||||
|
||||
|
||||
screen_pitch = 640;
|
||||
|
|
|
@ -38,7 +38,7 @@ protected:
|
|||
constexpr auto sdl_keycode_map = KeyCodeMap({
|
||||
{SDL_SCANCODE_A, 0x1E61, 0x1E41, 0x1E01},
|
||||
{SDL_SCANCODE_B,0x3062,0x3042,0x3002},
|
||||
{SDL_SCANCODE_C,0x2E63,0x2E42,0x2E03},
|
||||
{SDL_SCANCODE_C,0x2E63,0x2E43,0x2E03},
|
||||
{SDL_SCANCODE_D,0x2064,0x2044,0x2004},
|
||||
{SDL_SCANCODE_E,0x1265,0x1245,0x1205},
|
||||
{SDL_SCANCODE_F,0x2166,0x2146,0x2106},
|
||||
|
|
|
@ -53,8 +53,18 @@ SDLContext::SDLContext() {
|
|||
|
||||
}
|
||||
|
||||
void SDLContext::generateCRTTexture(SDL_Renderer* renderer, SDL_Texture** texture, int width, int height) {
|
||||
|
||||
void SDLContext::generateCRTTexture(SDL_Renderer* renderer, SDL_Texture** texture, int width, int height, CrtFilterType type) {
|
||||
|
||||
if (type == CrtFilterType::autoselect) {
|
||||
if (height > 1680) type = CrtFilterType::rgb_matrix_3;
|
||||
else if (height >= 1200) type = CrtFilterType::scanlines_2;
|
||||
else type = CrtFilterType::scanlines;
|
||||
}
|
||||
|
||||
if (type == CrtFilterType::scanlines || type == CrtFilterType::scanlines_2) {
|
||||
width = 32;
|
||||
}
|
||||
// Vytvoř novou texturu ve správné velikosti
|
||||
*texture = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_RGBA8888, SDL_TEXTUREACCESS_STREAMING, width, height);
|
||||
SDL_SetTextureBlendMode(*texture, SDL_BLENDMODE_MUL);
|
||||
|
@ -65,19 +75,67 @@ void SDLContext::generateCRTTexture(SDL_Renderer* renderer, SDL_Texture** textur
|
|||
int pitch;
|
||||
SDL_LockTexture(*texture, nullptr, &pixels, &pitch);
|
||||
|
||||
bool wider_lines = height > 1350;
|
||||
|
||||
Uint32* pixelArray = (Uint32*)pixels;
|
||||
Uint32 darkPixel = wider_lines?0x808080FF:0xA0A0A0FF;
|
||||
Uint32 transparentPixel = wider_lines ?0xFFFFFFE0:0xFFFFFFC0;
|
||||
int step = wider_lines ?3:2;
|
||||
|
||||
if (type == CrtFilterType::scanlines) {
|
||||
|
||||
|
||||
|
||||
Uint32 darkPixel = 0xA0A0A0FF;
|
||||
Uint32 transparentPixel = 0xFFFFFFC0;
|
||||
|
||||
for (int y = 0; y < height; y++) {
|
||||
Uint32 color = (y % step == 0) ? darkPixel : transparentPixel;
|
||||
Uint32 color = ((y & 1)== 0) ? darkPixel : transparentPixel;
|
||||
for (int x = 0; x < width; x++) {
|
||||
pixelArray[y * (pitch / 4) + x] = color;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (type == CrtFilterType::scanlines_2) {
|
||||
|
||||
|
||||
Uint32 darkPixel = 0x808080FF;
|
||||
Uint32 transparentPixel = 0xFFFFFFE0;
|
||||
|
||||
for (int y = 0; y < height; y++) {
|
||||
Uint32 color = (y % 3== 2) ? darkPixel : transparentPixel;
|
||||
for (int x = 0; x < width; x++) {
|
||||
pixelArray[y * (pitch / 4) + x] = color;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
||||
static Uint32 red_pixel = 0xFF8080A0;
|
||||
static Uint32 green_pixel = 0x80FF80A0;
|
||||
static Uint32 blue_pixel = 0x8080FFA0;
|
||||
static Uint32 dark_pixel = 0x000000C0;
|
||||
for (int y = 2; y < height; y++) {
|
||||
if (type == CrtFilterType::rgb_matrix_2) {
|
||||
for (int x = 2; x < width; x+=3) {
|
||||
Uint32 *pos = pixelArray+y*(pitch/4)+x-2;
|
||||
if ((y % 3) == 2) {
|
||||
pos[0] = pos[1] = pos[2] = dark_pixel;
|
||||
} else {
|
||||
pos[0] = red_pixel;
|
||||
pos[1] = green_pixel;
|
||||
pos[2] = blue_pixel;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (int x = 2; x < width; x+=3) {
|
||||
Uint32 *pos = pixelArray+y*(pitch/4)+x-2;
|
||||
if ((y & 3) == 3) {
|
||||
pos[0] = pos[1] = pos[2] = dark_pixel;
|
||||
} else {
|
||||
pos[0] = red_pixel;
|
||||
pos[1] = green_pixel;
|
||||
pos[2] = blue_pixel;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Odemkni texturu
|
||||
SDL_UnlockTexture(*texture);
|
||||
|
@ -97,7 +155,7 @@ void SDLContext::init_video(const VideoConfig &config, const char *title) {
|
|||
int height = config.window_height;
|
||||
aspect_x = config.aspect_x;
|
||||
aspect_y = config.aspect_y;
|
||||
crt_filter_enabled = config.crt_filter;
|
||||
_crt_filter = config.crt_filter ;
|
||||
|
||||
|
||||
_fullscreen_mode = config.fullscreen;
|
||||
|
@ -370,10 +428,10 @@ void SDLContext::update_screen() {
|
|||
SDL_SetTextureAlphaMod(_visible_texture, 255);
|
||||
SDL_RenderCopy(_renderer.get(), _visible_texture, NULL, &winrc);
|
||||
}
|
||||
if (winrc.h > 900 && crt_filter_enabled) {
|
||||
if (winrc.h >= 720 && _crt_filter != CrtFilterType::none) {
|
||||
if (!_crt_effect) {
|
||||
SDL_Texture *txt;
|
||||
generateCRTTexture(_renderer.get(), &txt, 128, std::min<int>(1440, winrc.h));
|
||||
generateCRTTexture(_renderer.get(), &txt, winrc.w, winrc.h, _crt_filter);
|
||||
_crt_effect.reset(txt);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,10 +15,20 @@ public:
|
|||
|
||||
SDLContext();
|
||||
|
||||
enum class CrtFilterType {
|
||||
none,
|
||||
autoselect,
|
||||
scanlines,
|
||||
scanlines_2,
|
||||
rgb_matrix_2,
|
||||
rgb_matrix_3
|
||||
|
||||
};
|
||||
|
||||
struct VideoConfig {
|
||||
int window_width;
|
||||
int window_height;
|
||||
bool crt_filter;
|
||||
CrtFilterType crt_filter;
|
||||
int composer;
|
||||
const char *scale_quality;
|
||||
bool fullscreen;
|
||||
|
@ -121,7 +131,7 @@ protected:
|
|||
mutable std::mutex _mx;
|
||||
int aspect_x = 4;
|
||||
int aspect_y = 3;
|
||||
bool crt_filter_enabled = false;
|
||||
CrtFilterType _crt_filter= CrtFilterType::autoselect;
|
||||
std::function<void()> _quit_callback;
|
||||
|
||||
std::unique_ptr<SDL_Window, SDL_Deleter> _window;
|
||||
|
@ -173,7 +183,7 @@ protected:
|
|||
static SDL_Point to_source_point(const SDL_Rect &win_rec, const SDL_Point &win_pt) ;
|
||||
static SDL_Rect transition_rect(const SDL_Rect &beg, const SDL_Rect &end, float phase);
|
||||
static int transition_int(int beg, int end, float phase);
|
||||
void generateCRTTexture(SDL_Renderer* renderer, SDL_Texture** texture, int width, int height);
|
||||
void generateCRTTexture(SDL_Renderer* renderer, SDL_Texture** texture, int width, int height, CrtFilterType type);
|
||||
void signal_push();
|
||||
|
||||
|
||||
|
|
23
skeldal.ini
23
skeldal.ini
|
@ -19,7 +19,15 @@
|
|||
# fullscreen = run game in fullscreen mode
|
||||
# window_width = set window with (in windowed mode)
|
||||
# window_height = set window height (in windowed mode)
|
||||
# crt_filter = enable filter simmulates lowres CRT monitor for higher resolution
|
||||
# crt_filter = enable filter simmulates lowres CRT monitor for higher resolution (>720p)
|
||||
# none = disabled
|
||||
# auto = auto select depend on resolution (default)
|
||||
# scanline = 1 pixel wide scanline (best for HD resolution, 960p-1080p)
|
||||
# scanline_2 = 2 pixels wide scanline (best for QHD resolution, 1440p)
|
||||
# rgbmatrix_2 = emulates CRT shadow mask (best for QHD resolution, 1440p)
|
||||
# rgbmatrix_3 = emulates CRT shadow mask (best for 4K resolution, 1920p+)
|
||||
# (hardware composer and linear filtering is recommended)
|
||||
#
|
||||
# composer = auto - choose best supported driver
|
||||
# hardware,hw - use hardware for composition
|
||||
# software,sw - use software for composition
|
||||
|
@ -33,7 +41,7 @@
|
|||
#fullscreen=on
|
||||
#window_width=640
|
||||
#window_height=480
|
||||
#crt_filter=on
|
||||
#crt_filter=auto
|
||||
#scale_quality=auto
|
||||
#composer=auto
|
||||
#aspect_ratio=4:3
|
||||
|
@ -46,4 +54,13 @@
|
|||
[audio]
|
||||
#device=
|
||||
|
||||
|
||||
### localization settings
|
||||
#
|
||||
# keyboard_layout = cz_querty, cz_quertz, us
|
||||
# string_table = path to a stringtable file. (default=none)
|
||||
# (note, internal fonts supports only characters from KEYBCS2/CP895 code page)
|
||||
# (https://en.wikipedia.org/wiki/Kamenick%C3%BD_encoding)
|
||||
#
|
||||
[localization]
|
||||
#keyboard_layout=cz_querty
|
||||
#string_table=
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue