summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: bc1fa78)
raw | patch | inline | side by side (parent: bc1fa78)
author | DeaDDooMER <deaddoomer@deadsoftware.ru> | |
Thu, 8 Apr 2021 09:21:30 +0000 (12:21 +0300) | ||
committer | DeaDDooMER <deaddoomer@deadsoftware.ru> | |
Thu, 8 Apr 2021 09:21:30 +0000 (12:21 +0300) |
src/soft/render.c | patch | blob | history | |
src/soft/vga.c | patch | blob | history | |
src/soft/vga.h | patch | blob | history |
diff --git a/src/soft/render.c b/src/soft/render.c
index 6c804a9a0d5f1832085ba0c9e68119f5cd5f40f3..174c3ea750e37529898df6034dd286ad6da293f0 100644 (file)
--- a/src/soft/render.c
+++ b/src/soft/render.c
* 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 "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 *ltn[2][2];
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"
};
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;
diff --git a/src/soft/vga.c b/src/soft/vga.c
index 5f9078533aea39957dfa1c9ae8acaaabbb7010da..292fdde1f48114c496073fb9e240e9857993ea6b 100644 (file)
--- a/src/soft/vga.c
+++ b/src/soft/vga.c
char fullscreen = OFF;
byte bright[256];
-byte mixmap[256][256];
-byte clrmap[256*12];
+byte *mixmap; /* [256][256] */
+byte *clrmap; /* [256*12] */
byte *buffer;
int buf_w, buf_h, pitch;
c = c + bright[t];
c += 0x60;
c ^= 0xF;
- putpixel(x,y,mixmap[c][t]);
+ //putpixel(x,y,mixmap[c][t]);
+ putpixel(x, y, mixmap[t * 256 + c]);
}
void flame_sprf (int x, int y, byte c) {
diff --git a/src/soft/vga.h b/src/soft/vga.h
index cf69e16805b71c8810bcbb856493d1a4a8dad6e0..7b4d231ce56975b1e8fe0cd386e9bf49148b9c1f 100644 (file)
--- a/src/soft/vga.h
+++ b/src/soft/vga.h
extern int buf_w, buf_h, pitch;
extern byte bright[256];
-extern byte mixmap[256][256];
-extern byte clrmap[256*12];
+extern byte *mixmap; /* [256][256] */
+extern byte *clrmap; /* [256*12] */
vgaimg *V_getvgaimg (int id);
vgaimg *V_loadvgaimg (char *name);