Commit 73be6e3d authored by Steven Fuller's avatar Steven Fuller

Yay! Graphics work; now to make some cosmetic fixes, input, etc...

parent 609432be
CC = gcc
#CFLAGS = -Wall -O6 -fomit-frame-pointer -mpentiumpro -mcpu=pentiumpro -march=pentiumpro -DUSEVGA
CFLAGS = -g -DUSEVGA -fwritable-strings
#CFLAGS = -Os -fwritable-strings
#CFLAGS = -g -Wall -DUSEVGA -DDEBUG
#CFLAGS = -g -DUSEVGA -DDEBUG
#CFLAGS = -g -pg -DDEBUG
......@@ -9,8 +10,8 @@ OBJS = objs.o misc.o id_ca.o id_in.o id_sd.o id_vl.o id_vh.o id_us.o \
wl_inter.o wl_menu.o wl_play.o wl_state.o wl_text.o wl_main.o \
wl_debug.o
#LFLAGS = -lm -lvga -pg
LFLAGS = -lm -lvga ElectricFence-2.2.2/libefence.a -lpthread
LFLAGS = -lm -lvga
#LFLAGS = -lm -lvga ElectricFence-2.2.2/libefence.a -lpthread
NASM = nasm
......
......@@ -380,7 +380,7 @@ void CAL_HuffExpand(byte *source, byte *dest, long length, huffnode *hufftable)
#define NEARTAG 0xa7
#define FARTAG 0xa8
/* TODO: very correctness of byteinc */
/* TODO: verify correctness of byteinc */
void CAL_CarmackExpand(word *source, word *dest, word length)
{
word ch, chhigh, count, offset;
......@@ -852,7 +852,9 @@ cachein:
void CAL_ExpandGrChunk(int chunk, byte *source)
{
long expanded;
int width = 0, height = 0;
if (chunk >= STARTTILE8 && chunk < STARTEXTERNS)
{
//
......@@ -874,22 +876,26 @@ void CAL_ExpandGrChunk(int chunk, byte *source)
expanded = BLOCK*16;
else
expanded = MASKBLOCK*16;
}
else
{
} else if (chunk >= STARTPICS && chunk < STARTSPRITES) {
width = pictable[chunk - STARTPICS].width;
height = pictable[chunk - STARTPICS].height;
expanded = *((long *)source);
source += 4;
} else {
//
// everything else has an explicit size longword
//
expanded = *((long *)source);
source += 4; // skip over length
source += 4;
}
//
// allocate final space, decompress it, and free bigbuffer
// Sprites need to have shifts made and various other junk
// allocate final space and decompress it
//
MM_GetPtr(&grsegs[chunk], expanded);
CAL_HuffExpand(source, grsegs[chunk], expanded, grhuffman);
if (width && height)
VL_DeModeXize(grsegs[chunk], width, height);
}
......@@ -1002,6 +1008,8 @@ void CA_CacheScreen(int chunk)
//
/* TODO: this cheats and expands to the 320x200 screen buffer */
CAL_HuffExpand(source, gfxbuf, expanded, grhuffman);
/* and then fixes it also! */
VL_DeModeXize(gfxbuf, 320, 200);
MM_FreePtr(&bigbufferseg);
}
......
......@@ -14,6 +14,8 @@
#include <glob.h>
#include <math.h>
#include <vga.h>
#include "misc.h"
#include "version.h"
......
......@@ -10,10 +10,12 @@ byte *gfxbuf = NULL;
void VL_WaitVBL(int vbls)
{
vga_waitretrace();
}
void VL_UpdateScreen()
{
memcpy(graph_mem, gfxbuf, 64000);
}
/*
......@@ -28,6 +30,9 @@ void VL_Startup (void)
{
if (gfxbuf == NULL)
gfxbuf = malloc(320 * 200 * 1);
vga_init();
vga_setmode(G320x200x256);
}
/*
......@@ -44,6 +49,7 @@ void VL_Shutdown (void)
free(gfxbuf);
gfxbuf = NULL;
}
vga_setmode(TEXT);
}
//===========================================================================
......@@ -58,8 +64,9 @@ void VL_Shutdown (void)
=================
*/
void VL_ClearVideo (byte color)
void VL_ClearVideo(byte color)
{
memset(gfxbuf, color, 64000);
}
/*
......@@ -83,6 +90,10 @@ void VL_ClearVideo (byte color)
void VL_FillPalette(int red, int green, int blue)
{
int i;
for (i = 0; i < 256; i++)
vga_setpalette(i, red, green, blue);
}
//===========================================================================
......@@ -97,6 +108,7 @@ void VL_FillPalette(int red, int green, int blue)
void VL_SetColor(int color, int red, int green, int blue)
{
vga_setpalette(color, red, green, blue);
}
//===========================================================================
......@@ -111,6 +123,7 @@ void VL_SetColor(int color, int red, int green, int blue)
void VL_GetColor(int color, int *red, int *green, int *blue)
{
vga_getpalette(color, red, green, blue);
}
//===========================================================================
......@@ -120,14 +133,15 @@ void VL_GetColor(int color, int *red, int *green, int *blue)
=
= VL_SetPalette
=
= If fast palette setting has been tested for, it is used
= (some cards don't like outsb palette setting)
=
=================
*/
void VL_SetPalette(byte *palette)
{
int i;
for (i = 0; i < 256; i++)
vga_setpalette(i, palette[i*3+0], palette[i*3+1], palette[i*3+2]);
}
......@@ -138,14 +152,19 @@ void VL_SetPalette(byte *palette)
=
= VL_GetPalette
=
= This does not use the port string instructions,
= due to some incompatabilities
=
=================
*/
void VL_GetPalette(byte *palette)
{
int i, r, g, b;
for (i = 0; i < 256; i++) {
vga_getpalette(i, &r, &g, &b);
palette[i*3+0] = r;
palette[i*3+1] = g;
palette[i*3+2] = b;
}
}
......@@ -441,3 +460,27 @@ asm mov ds,ax
VGAWRITEMODE(0);
#endif
}
void VL_DeModeXize(byte *buf, int width, int height)
{
byte *mem, *ptr, *destline;
int plane, x, y;
if (width & 3) {
printf("Not divisible by 4?\n");
return;
}
mem = malloc(width * height);
ptr = buf;
for (plane = 0; plane < 4; plane++) {
destline = mem;
for (y = 0; y < height; y++) {
for (x = 0; x < width / 4; x++)
*(destline + x*4 + plane) = *ptr++;
destline += width;
}
}
memcpy(buf, mem, width * height);
free(mem);
}
......@@ -16,25 +16,24 @@ void VL_ClearVideo (byte color);
void VL_WaitVBL (int vbls);
void VL_FillPalette (int red, int green, int blue);
void VL_SetColor (int color, int red, int green, int blue);
void VL_GetColor (int color, int *red, int *green, int *blue);
void VL_SetPalette (byte *palette);
void VL_GetPalette (byte *palette);
void VL_FadeOut (int start, int end, int red, int green, int blue, int steps);
void VL_FadeIn (int start, int end, byte *palette, int steps);
void VL_FillPalette(int red, int green, int blue);
void VL_SetColor(int color, int red, int green, int blue);
void VL_GetColor(int color, int *red, int *green, int *blue);
void VL_SetPalette(byte *palette);
void VL_GetPalette(byte *palette);
void VL_FadeOut(int start, int end, int red, int green, int blue, int steps);
void VL_FadeIn(int start, int end, byte *palette, int steps);
void VL_ColorBorder (int color);
void VL_Plot (int x, int y, int color);
void VL_Hlin (unsigned x, unsigned y, unsigned width, unsigned color);
void VL_Vlin (int x, int y, int height, int color);
void VL_Bar (int x, int y, int width, int height, int color);
void VL_Plot(int x, int y, int color);
void VL_Hlin(unsigned x, unsigned y, unsigned width, unsigned color);
void VL_Vlin(int x, int y, int height, int color);
void VL_Bar(int x, int y, int width, int height, int color);
void VL_MemToLatch (byte *source, int width, int height, word dest);
void VL_MemToScreen (byte *source, int width, int height, int x, int y);
void VL_MemToLatch(byte *source, int width, int height, word dest);
void VL_MemToScreen(byte *source, int width, int height, int x, int y);
void VL_DrawPropString (char *str, unsigned tile8ptr, int printx, int printy);
void VL_SizePropString (char *str, int *width, int *height, char *font);
void VL_DeModeXize(byte *buf, int width, int height);
#elif
#error "fix me: TODO"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment