X-Git-Url: http://deadsoftware.ru/gitweb?a=blobdiff_plain;f=src%2Fsoft%2Fvga.c;h=292fdde1f48114c496073fb9e240e9857993ea6b;hb=925644f91de70623a42e8c07e6c326aa171575c4;hp=ef97ca7afa9103bae141e77173ba343e3c84290d;hpb=23ff2420fe9bb02152cdb47c90acf4262b863414;p=flatwaifu.git diff --git a/src/soft/vga.c b/src/soft/vga.c index ef97ca7..292fdde 100644 --- a/src/soft/vga.c +++ b/src/soft/vga.c @@ -1,24 +1,19 @@ -/* - Copyright (C) Prikol Software 1996-1997 - Copyright (C) Aleksey Volynskov 1996-1997 - Copyright (C) 2011 - - This file is part of the Doom2D:Rembo project. - - Doom2D:Rembo is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License version 2 as - published by the Free Software Foundation. - - Doom2D:Rembo 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 or - write to the Free Software Foundation, Inc., - 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -*/ +/* 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 . + */ #include "glob.h" #include "vga.h" @@ -29,6 +24,8 @@ #include "files.h" #include "system.h" +#include "common/endianness.h" + #include #include @@ -37,11 +34,11 @@ int SCRH = 600; char fullscreen = OFF; byte bright[256]; -byte mixmap[256][256]; -byte clrmap[256*12]; +byte *mixmap; /* [256][256] */ +byte *clrmap; /* [256*12] */ -static byte *buffer; -static int buf_w, buf_h, pitch; +byte *buffer; +int buf_w, buf_h, pitch; static int offx, offy; static int cx1, cx2, cy1, cy2; static byte flametab[16] = { @@ -64,22 +61,9 @@ vgaimg *V_loadvgaimg (char *name) { return V_getvgaimg(F_getresid(name)); } -short V_init (void) { - int flags = fullscreen ? SYSTEM_USE_FULLSCREEN : 0; - int res = Y_set_videomode(SCRW, SCRH, flags); - if (res == 0) { - ERR_failinit("Unable to set video mode"); - } +void V_update_buffer (void) { Y_get_buffer(&buffer, &buf_w, &buf_h, &pitch); - return 0; -} - -void V_done (void) { - buffer = NULL; - buf_w = 0; - buf_h = 0; - pitch = 0; - Y_unset_videomode(); + V_setrect(0, 0, buf_w, buf_h); } static void draw_rect (int x, int y, int w, int h, int c) { @@ -95,10 +79,12 @@ static void draw_rect (int x, int y, int w, int h, int c) { } void V_setrect (short x, short w, short y, short h) { + assert(w >= 0); + assert(h >= 0); cx1 = max(x, 0); - cx2 = min(x + w - 1, SCRW - 1); + cx2 = min(x + w - 1, buf_w - 1); cy1 = max(y, 0); - cy2 = min(y + h - 1, SCRH - 1); + cy2 = min(y + h - 1, buf_h - 1); } static void putpixel (int x, int y, byte color) { @@ -118,7 +104,7 @@ static void mappixel (int x, int y, byte *cmap) { void V_center (int f) { if (f) { - V_offset(SCRW / 2 - 320 / 2, SCRH / 2 - 200 / 2); + V_offset(buf_w / 2 - 320 / 2, buf_h / 2 - 200 / 2); } else { V_offset(0, 0); } @@ -181,7 +167,8 @@ void smoke_sprf (int x, int y, byte c) { 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) { @@ -241,7 +228,3 @@ void V_remap_rect (int x, int y, int w, int h, byte *cmap) { for (cy=y; cy