diff --git a/src/soft/render.c b/src/soft/render.c
index bf0ca079c2684f103e47f176c067e43f2be97d4f..174c3ea750e37529898df6034dd286ad6da293f0 100644 (file)
--- a/src/soft/render.c
+++ b/src/soft/render.c
+/* Copyright (C) 1996-1997 Aleksey Volynskov
+ * Copyright (C) 2011 Rambo
+ * Copyright (C) 2020 SovietPony
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, version 3 of the License ONLY.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <stdio.h>
#include <string.h>
#include <stdarg.h>
#include <stdlib.h> // abs()
#include "music.h"
#include "system.h"
-#include "cp866.h"
+#include "common/cp866.h"
+
+#pragma pack(push, 1)
+typedef struct rgb_t {
+ byte r, g, b;
+} rgb_t;
+#pragma pack(pop)
// game
static vgaimg *scrnh[3]; // TITLEPIC INTERPIC ENDPIC
static vgaimg *msklh[2], *mbarl, *mbarm, *mbarr, *mbaro, *mslotl, *mslotm, *mslotr;
// low level
static int gammaa = 0;
-static char main_pal[256][3];
-static char std_pal[256][3];
+static rgb_t *main_pal;
+static byte std_pal[256][3];
static byte gamcor[5][64]={
#include "gamma.dat"
};
void R_alloc (void) {
int i, j, n;
char s[10];
- logo("R_alloc: загрузка графики\n");
+ logo("R_alloc: load graphics\n");
// game
scrnh[0] = V_loadvgaimg("TITLEPIC");
scrnh[1] = V_loadvgaimg("INTERPIC");
}
static short getani (char n[8]) {
- if (strncasecmp(n, "WALL22_1", 8) == 0) {
+ if (cp866_strncasecmp(n, "WALL22_1", 8) == 0) {
return 1;
- } else if (strncasecmp(n, "WALL58_1", 8) == 0) {
+ } else if (cp866_strncasecmp(n, "WALL58_1", 8) == 0) {
return 2;
- } else if (strncasecmp(n, "W73A_1", 8) == 0) {
+ } else if (cp866_strncasecmp(n, "W73A_1", 8) == 0) {
return 3;
- } else if (strncasecmp(n, "RP2_1", 8) == 0) {
+ } else if (cp866_strncasecmp(n, "RP2_1", 8) == 0) {
return 4;
} else {
return 0;
walh[max_textures] = -1;
walp[max_textures] = NULL;
} else {
- if (strncasecmp(s, "_WATER_", 7) == 0) {
+ if (cp866_strncasecmp(s, "_WATER_", 7) == 0) {
walh[max_textures] = -2;
walp[max_textures] = (void*)((intptr_t)s[7] - '0' + 1);
} else {
g = g < 0 ? 0 : (g > 4 ? 4 : g);
gammaa = g;
for (t = 0; t < 256; ++t) {
- std_pal[t][0]=gamcor[gammaa][main_pal[t][0]];
- std_pal[t][1]=gamcor[gammaa][main_pal[t][1]];
- std_pal[t][2]=gamcor[gammaa][main_pal[t][2]];
+ std_pal[t][0] = gamcor[gammaa][main_pal[t].r];
+ std_pal[t][1] = gamcor[gammaa][main_pal[t].g];
+ std_pal[t][2] = gamcor[gammaa][main_pal[t].b];
}
- Y_set_vga_palette(std_pal);
+ Y_set_vga_palette(&std_pal[0][0]);
}
int R_getgamma (void) {
R_setgamma(gammaa);
}
-static int video_menu_handler (menu_msg_t *msg, const menu_t *m, void *data, int i) {
+static int video_menu_handler (menu_msg_t *msg, const menu_t *m, int i) {
static int cur;
static int w, h, fullscreen;
static char buf[16];
return conf;
}
+static void *R_load_fixed (char *name, int size) {
+ int id = F_getresid(name);
+ if (F_getreslen(id) < size) {
+ ERR_fatal("invalid %s (%i)", name, F_getreslen(id));
+ }
+ return M_lock(id);
+}
+
void R_init () {
int i;
logo("R_init: initialize software render\n");
- F_loadres(F_getresid("PLAYPAL"), main_pal, 0, 768);
+ main_pal = R_load_fixed("PLAYPAL", 256 * 3);
+ clrmap = R_load_fixed("COLORMAP", 256 * 12);
+ mixmap = R_load_fixed("MIXMAP", 256 * 256);
for (i = 0; i < 256; ++i) {
- bright[i] = ((int) main_pal[i][0] + main_pal[i][1] + main_pal[i][2]) * 8 / (63 * 3);
+ bright[i] = ((int)main_pal[i].r + main_pal[i].g + main_pal[i].b) * 8 / (63 * 3);
}
- F_loadres(F_getresid("MIXMAP"), mixmap, 0, 0x10000);
- F_loadres(F_getresid("COLORMAP"), clrmap, 0, 256*12);
SCRW = init_screen_width > 0 ? init_screen_width : SCRW;
SCRH = init_screen_height > 0 ? init_screen_height : SCRH;
fullscreen = init_screen_full != 0xFF ? init_screen_full : fullscreen;