summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 1958dd7)
raw | patch | inline | side by side (parent: 1958dd7)
author | DeaDDooMER <deaddoomer@deadsoftware.ru> | |
Mon, 13 Apr 2020 09:47:57 +0000 (13:47 +0400) | ||
committer | DeaDDooMER <deaddoomer@deadsoftware.ru> | |
Mon, 13 Apr 2020 09:47:57 +0000 (13:47 +0400) |
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 83cd7f2147ebd6ae5fbbda0e827ffd9252c8ea0a..9028b81778374219276b037ba5a6178574b74339 100644 (file)
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
set(D2D_SDLMIXER_ROOT ${D2D_GAME_ROOT}/sdlmixer)
set(D2D_OPENAL_ROOT ${D2D_GAME_ROOT}/openal)
set(D2D_STUBSOUND_ROOT ${D2D_GAME_ROOT}/stubsnd)
+set(D2D_LIBCP866_ROOT ${D2D_GAME_ROOT}/libs/cp866)
aux_source_directory(${D2D_GAME_ROOT} D2D_GAME_SRC)
aux_source_directory(${D2D_SDL_ROOT} D2D_SDL_SRC)
aux_source_directory(${D2D_SDLMIXER_ROOT} D2D_SDLMIXER_SRC)
aux_source_directory(${D2D_OPENAL_ROOT} D2D_OPENAL_SRC)
aux_source_directory(${D2D_STUBSOUND_ROOT} D2D_STUBSOUND_SRC)
+aux_source_directory(${D2D_LIBCP866_ROOT} D2D_LIBCP866_SRC)
if(WITH_SDL)
if(D2D_FOR_EMSCRIPTEN)
message(STATUS "RENDER: " "${RENDER_DRIVER}")
message(STATUS "SOUND: " "${SOUND_DRIVER}")
-add_executable(doom2d ${D2D_GAME_SRC} ${D2D_SYSTEM_SRC} ${D2D_RENDER_SRC} ${D2D_SOUND_SRC})
-target_include_directories(doom2d PRIVATE "${D2D_GAME_ROOT}" "${D2D_SYSTEM_INCLUDE_DIR}" "${D2D_RENDER_INCLUDE_DIR}" "${D2D_SOUND_INCLUDE_DIR}")
+set(D2D_USED_SRC ${D2D_GAME_SRC} ${D2D_SYSTEM_SRC} ${D2D_RENDER_SRC} ${D2D_SOUND_SRC} ${D2D_LIBCP866_SRC})
+set(D2D_USED_INCLUDE_DIR "${D2D_GAME_ROOT}" "${D2D_SYSTEM_INCLUDE_DIR}" "${D2D_RENDER_INCLUDE_DIR}" "${D2D_SOUND_INCLUDE_DIR}" "${D2D_LIBCP866_ROOT}")
+set(D2D_USED_LIBRARY "${D2D_SYSTEM_LIBRARY}" "${D2D_RENDER_LIBRARY}" "${D2D_SOUND_LIBRARY}")
+#message(STATUS "USED SRC: ${D2D_USED_SRC}")
+#message(STATUS "USED INC: ${D2D_USED_INCLUDE_DIR}")
+#message(STATUS "USED LIB: ${D2D_USED_LIBRARY}")
+add_executable(doom2d ${D2D_USED_SRC})
+target_include_directories(doom2d PRIVATE ${D2D_USED_INCLUDE_DIR})
if(D2D_FOR_EMSCRIPTEN)
set(CMAKE_EXECUTABLE_SUFFIX ".html")
configure_file(${D2D_GAME_ROOT}/doom2d.wad doom2d.wad COPYONLY)
set(D2D_DOOM2D_WAD doom2d.wad)
configure_file(${D2D_GAME_ROOT}/default.cfg default.cfg COPYONLY)
set(D2D_DEFAULT_CFG default.cfg)
- set_target_properties(doom2d PROPERTIES LINK_FLAGS "-s WASM=0 -s DISABLE_EXCEPTION_CATCHING=1 -s SAFE_HEAP=1 -s ASSERTIONS=1 -s GL_ASSERTIONS=1 ${D2D_SYSTEM_LINKFLAGS} ${D2D_RENDER_LINKFLAGS} ${D2D_SOUND_LINKFLAGS} --preload-file ${D2D_DOOM2D_WAD} --preload-file ${D2D_DEFAULT_CFG}")
+ set(D2D_USED_LINKFLAGS ${D2D_SYSTEM_LINKFLAGS} ${D2D_RENDER_LINKFLAGS} ${D2D_SOUND_LINKFLAGS})
+ set_target_properties(doom2d PROPERTIES LINK_FLAGS "-s WASM=0 -s DISABLE_EXCEPTION_CATCHING=1 -s SAFE_HEAP=1 -s ASSERTIONS=1 -s GL_ASSERTIONS=1 ${D2D_USED_LINKFLAGS} --preload-file ${D2D_DOOM2D_WAD} --preload-file ${D2D_DEFAULT_CFG}")
else()
- target_link_libraries(doom2d "${D2D_SYSTEM_LIBRARY}" "${D2D_RENDER_LIBRARY}" "${D2D_SOUND_LIBRARY}")
+ target_link_libraries(doom2d ${D2D_USED_LIBRARY})
endif()
diff --git a/src/files.c b/src/files.c
index f7037cf435be55a4cee9f25d344a48ee0389f3ef..1b470913c6c4aaf56958889ddfe5c55f43dc730e 100644 (file)
--- a/src/files.c
+++ b/src/files.c
#include "switch.h"
#include "weapons.h"
#include "error.h"
+#include "cp866.h"
typedef struct {
byte n, i, v, d;
ERR_failinit("Не могу открыть файл2: %s", wads[i]);
}
mysplitpath(wads[i], f_drive, f_dir, f_name, f_ext);
- if (strcasecmp(f_ext, ".lmp") == 0) {
+ if (cp866_strcasecmp(f_ext, ".lmp") == 0) {
for (k = 0; k < MAX_WAD; ++k) {
- if (strncasecmp(wad[k].n, f_name, 8) == 0) {
+ if (cp866_strncasecmp(wad[k].n, f_name, 8) == 0) {
wad[k].o = 0;
wad[k].l = myfilelength(h);
wad[k].f = i;
w.o = myfread32(h); // len
myfread(w.n, 1, 8, h); // name
for (k = 0; k < MAX_WAD; ++k) {
- if (strncasecmp(wad[k].n, w.n, 8) == 0) {
+ if (cp866_strncasecmp(wad[k].n, w.n, 8) == 0) {
wad[k].o = w.o;
wad[k].l = w.l;
wad[k].f = i;
int F_findres (const char n[8]) {
int i;
for (i = 0; i < wad_num; i++) {
- if (strncasecmp(wad[i].n, n, 8) == 0) {
+ if (cp866_strncasecmp(wad[i].n, n, 8) == 0) {
return i;
}
}
s+='A';d+='0';
for(i=s_start+1;i<s_end;++i)
- if(strncasecmp(wad[i].n,n,4)==0 && (wad[i].n[4]==s || wad[i].n[6]==s)) {
+ if(cp866_strncasecmp(wad[i].n,n,4)==0 && (wad[i].n[4]==s || wad[i].n[6]==s)) {
if(wad[i].n[4]==s) a=wad[i].n[5]; else a=0;
if(wad[i].n[6]==s) b=wad[i].n[7]; else b=0;
if(a=='0') return i;
for(++i;;++i) {
if(i>=m_end) i=m_start+1;
- if (strcasecmp(wad[i].n,"MENU") == 0 ||
- strcasecmp(wad[i].n,"INTERMUS") == 0 ||
- strcasecmp(wad[i].n,"\x8a\x8e\x8d\x85\x96\x0") == 0)
+ if (cp866_strcasecmp(wad[i].n,"MENU") == 0 ||
+ cp866_strcasecmp(wad[i].n,"INTERMUS") == 0 ||
+ cp866_strcasecmp(wad[i].n,"\x8a\x8e\x8d\x85\x96\x0") == 0)
continue;
- if(strncasecmp(wad[i].n,"DMI",3)!=0) break;
+ if(cp866_strncasecmp(wad[i].n,"DMI",3)!=0) break;
}
memcpy(s,wad[i].n,8);
}
diff --git a/src/gl/render.c b/src/gl/render.c
index c057b90e4fa84bc6d0d1a7d3647089995c33c047..f7180f9b0b8cbace0399c9827b5c6e42c0070e8d 100644 (file)
--- a/src/gl/render.c
+++ b/src/gl/render.c
#include "view.h"
#include "switch.h" // sw_secrets
+#include "cp866.h"
+
#ifdef __APPLE__
# include <OpenGL/gl.h>
#else
#include <stdarg.h>
#include <stdlib.h>
#include <string.h>
-#include <ctype.h>
#include <assert.h>
#define VGA_TRANSPARENT_COLOR 0
static image *Z_get_char_image (image *img, int ch) {
image *p = NULL;
+ ch = cp866_toupper(ch);
if (ch > 32 && ch < 160) {
p = &img[ch - '!'];
- if (p->n == NULL) {
- p = &img[toupper(ch) - '!'];
- }
}
return p;
}
diff --git a/src/libs/cp866/cp866.c b/src/libs/cp866/cp866.c
index 90d1bbdd643dd7c2708a4f23ec66011ce8a9f16f..3494b61751ae729d3aa3a807074aa147e892bea0 100644 (file)
--- a/src/libs/cp866/cp866.c
+++ b/src/libs/cp866/cp866.c
#include "cp866.h"
-int cp866_isalpha (char c) {
- unsigned char ch = c;
+int cp866_isalpha (int ch) {
return (ch >= 0x41 && ch <= 0x5A) || (ch >= 0x61 && ch <= 0x7A) || (ch >= 0x80 && ch <= 0xAF) || (ch >= 0xE0 && ch <= 0xF7);
}
-int cp866_isupper (char c) {
- unsigned char ch = c;
+int cp866_isupper (int ch) {
return (ch >= 0x41 && ch <= 0x5A) || (ch >= 0x80 && ch <= 0x9F) || ch == 0xF0 || ch == 0xF2 || ch == 0xF4 || ch == 0xF6;
}
-int cp866_islower (char c) {
- unsigned char ch = c;
+int cp866_islower (int ch) {
return (ch >= 0x61 && ch <= 0x7A) || (ch >= 0xA0 && ch <= 0xAF) || (ch >= 0xE0 && ch <= 0xEF) || ch == 0xF1 || ch == 0xF3 || ch == 0xF5 || ch == 0xF7;
}
-char cp866_toupper (char c) {
- unsigned char ch = c;
+int cp866_toupper (int ch) {
if (ch >= 0x61 && ch <= 0x7A) {
return ch - 0x61 + 0x41;
} else if (ch >= 0xA0 && ch <= 0xAF) {
}
}
-char cp866_tolower (char c) {
- unsigned char ch = c;
+int cp866_tolower (int ch) {
if (ch >= 0x41 && ch <= 0x5A) {
return ch - 0x41 + 0x61;
} else if (ch >= 0x80 && ch <= 0x8F) {
return i == 0 ? 0 : *(const unsigned char *)aa - *(const unsigned char *)bb;
}
-int cp866_ctou (char c) {
- unsigned char ch = c;
+int cp866_ctou (int ch) {
switch (ch) {
case 0xB0: return 0x2591;
case 0xB1: return 0x2592;
}
}
-int cp866_ctoug (char c) {
- unsigned char ch = c;
+int cp866_ctoug (int ch) {
switch (ch) {
case 0x00: return 0x0000;
case 0x01: return 0x263A;
diff --git a/src/libs/cp866/cp866.h b/src/libs/cp866/cp866.h
index 57c3ee728e8a7d03f878d17c9baa66bbd5c8afb2..7a8d697c22e0714fce5714723291fe8a7c0fd244 100644 (file)
--- a/src/libs/cp866/cp866.h
+++ b/src/libs/cp866/cp866.h
#ifndef CP866_H_INCLUDED
#define CP866_H_INCLUDED
-int cp866_isalpha (char ch);
-int cp866_isupper (char ch);
-int cp866_islower (char ch);
-char cp866_toupper (char ch);
-char cp866_tolower (char ch);
+int cp866_isalpha (int ch);
+int cp866_isupper (int ch);
+int cp866_islower (int ch);
+int cp866_toupper (int ch);
+int cp866_tolower (int ch);
int cp866_strcasecmp (const char *a, const char *b);
int cp866_strncasecmp (const char *a, const char *b, unsigned int n);
-int cp866_ctou (char ch);
-int cp866_ctoug (char ch);
+int cp866_ctou (int ch);
+int cp866_ctoug (int ch);
int cp866_utoc (int ch);
#endif /* CP866_H_INCLUDED */
diff --git a/src/sdl/main.c b/src/sdl/main.c
index 9227725c9876a90f48dd1c9380ab3695acda90ae..4f529db45c1667da9e7b40e0c3b1e41444174cd2 100644 (file)
--- a/src/sdl/main.c
+++ b/src/sdl/main.c
#include <stdio.h>
#include <stdarg.h>
#include <stdlib.h> // srand exit
-#include <string.h> // strcasecmp
-#include <ctype.h>
#include <assert.h>
#include "system.h"
#include "input.h"
diff --git a/src/sdl2/main.c b/src/sdl2/main.c
index 1a25886799791e976727ca56a7a36e381f97ef7f..5b111de3af1ca4196a4165bed012aad3849a7dd6 100644 (file)
--- a/src/sdl2/main.c
+++ b/src/sdl2/main.c
#include "system.h"
#include "input.h"
+#include "cp866.h"
+
#include "my.h" // fexists
#include "player.h" // pl1 pl2
#include "menu.h" // G_keyf
break;
case SDL_TEXTINPUT:
uch = utf8_to_wchar(ev.text.text);
- ch = wchar_to_cp866(uch);
- GM_input(ch);
+ ch = cp866_utoc(uch);
+ if (ch >= 0) {
+ GM_input(ch);
+ }
break;
}
}