Commit 60d51311 authored by Steven Fuller's avatar Steven Fuller

id_vh.c: optimized most of the new draw functions (now VW_Bar runs at decent

speeds)

wl_draw.c: reenabled the DrawPlayBorder call (see above)

wl_game.c: changed a VW_Bar to VL_Bar in Died() (it wants to draw over the
game area)

wl_menu.c: Got StartCPMusic to stop causing the error message at the
beginning

wl_play.c: Music functions now just call the ones in wl_menu.c
parent 847eeadc
......@@ -58,6 +58,9 @@ boolean FizzleFade(unsigned xx, unsigned yy, unsigned width, unsigned height, un
frame = 0;
set_TimeCount(0);
if (vwidth != 320)
return false;
do {
if (abortable && IN_CheckAck())
return true;
......@@ -256,7 +259,27 @@ static void VL_Plot(int x, int y, int color)
void VW_Plot(int x, int y, int color)
{
int xend, yend, xfrac, yfrac, xs, ys;
xend = x + 1;
yend = y + 1;
xfrac = (vwidth << 16) / 320;
yfrac = (vheight << 16) / 200;
x *= xfrac;
y *= yfrac;
xend *= xfrac;
yend *= yfrac;
xfrac = (320 << 16) / vwidth;
yfrac = (200 << 16) / vheight;
for (xs = x; xs < xend; xs += xfrac)
for (ys = y; ys < yend; ys += yfrac)
*(gfxbuf + (ys >> 16) * vwidth + (xs >> 16)) = color;
/*
*(gfxbuf + vwidth * y + x) = color;
*/
}
void VW_DrawPropString(char *string)
......@@ -310,16 +333,15 @@ void VW_DrawPropString(char *string)
*/
}
void VWL_MeasureString(char *string, word *width, word *height,
fontstruct *font)
void VWL_MeasureString(char *string, word *width, word *height, fontstruct *font)
{
/* proportional width */
*height = font->height;
for (*width = 0;*string;string++)
for (*width = 0; *string; string++)
*width += font->width[*((byte *)string)];
}
void VW_MeasurePropString (char *string, word *width, word *height)
void VW_MeasurePropString(char *string, word *width, word *height)
{
VWL_MeasureString(string,width,height,(fontstruct *)grsegs[STARTFONT+fontnumber]);
}
......@@ -352,11 +374,36 @@ void VWB_DrawPic(int x, int y, int chunknum)
void VL_Hlin(unsigned x, unsigned y, unsigned width, unsigned color)
{
int xend, yend, xfrac, yfrac;
int w, h;
byte *ptr;
xend = x + width;
yend = y + 1;
xfrac = (vwidth << 16) / 320;
yfrac = (vheight << 16) / 200;
x *= xfrac;
y *= yfrac;
xend *= xfrac;
yend *= yfrac;
w = (xend - x) >> 16;
h = (yend - y) >> 16;
ptr = gfxbuf + vwidth * (y >> 16) + (x >> 16);
while (h--) {
memset(ptr, color, w);
ptr += vwidth;
}
/*
int w;
for (w = 0; w < width; w++)
VL_Plot(x+w, y, color);
*/
/*
memset(gfxbuf + vwidth * y + x, color, width);
*/
......@@ -372,10 +419,36 @@ void VL_Hlin(unsigned x, unsigned y, unsigned width, unsigned color)
void VL_Vlin(int x, int y, int height, int color)
{
int xend, yend, xfrac, yfrac;
int w, h;
byte *ptr;
xend = x + 1;
yend = y + height;
xfrac = (vwidth << 16) / 320;
yfrac = (vheight << 16) / 200;
x *= xfrac;
y *= yfrac;
xend *= xfrac;
yend *= yfrac;
w = (xend - x) >> 16;
h = (yend - y) >> 16;
ptr = gfxbuf + vwidth * (y >> 16) + (x >> 16);
while (h--) {
memset(ptr, color, w);
ptr += vwidth;
}
/*
int h;
for (h = 0; h < height; h++)
VL_Plot(x, y+h, color);
*/
/*
byte *ptr = gfxbuf + vwidth * y + x;
while (height--) {
......@@ -395,12 +468,45 @@ void VL_Vlin(int x, int y, int height, int color)
void VW_Bar(int x, int y, int width, int height, int color)
{
//int xend, yend;
int xfrac, yfrac;
int w, h;
byte *ptr;
//xend = x + width;
//yend = y + height;
xfrac = (vwidth << 16) / 320;
yfrac = (vheight << 16) / 200;
x *= xfrac;
y *= yfrac;
//xend *= xfrac;
//yend *= yfrac;
//w = (xend - x) >> 16;
//h = (yend - y) >> 16;
w = (width * xfrac) >> 16;
h = (height * yfrac) >> 16;
//if ((w != ((width * xfrac) >> 16)) || (h != ((height * yfrac) >> 16)))
// printf("test\n");
ptr = gfxbuf + vwidth * (y >> 16) + (x >> 16);
while (h--) {
memset(ptr, color, w);
ptr += vwidth;
}
/*
int w, h;
for (w = 0; w < width; w++)
for (h = 0; h < height; h++)
VL_Plot(x+w, y+h, color);
*/
/*
byte *ptr;
width *= vwidth / 320;
......
......@@ -651,7 +651,7 @@ void ThreeDRefresh()
//
// follow the walls from there to the right, drawwing as we go
//
//DrawPlayBorder();
DrawPlayBorder();
#ifndef DRAWCEIL
ClearScreen();
#endif
......
......@@ -988,7 +988,7 @@ void Died()
//
FinishPaletteShifts();
VW_Bar(xoffset, yoffset, viewwidth, viewheight, 4);
VL_Bar(xoffset, yoffset, viewwidth, viewheight, 4);
IN_ClearKeysDown();
FizzleFade(xoffset, yoffset, viewwidth, viewheight, 70, false);
......@@ -1008,12 +1008,12 @@ void Died()
gamestate.attackframe = gamestate.attackcount =
gamestate.weaponframe = 0;
DrawKeys ();
DrawWeapon ();
DrawAmmo ();
DrawHealth ();
DrawFace ();
DrawLives ();
DrawKeys();
DrawWeapon();
DrawAmmo();
DrawHealth();
DrawFace();
DrawLives();
}
}
......
......@@ -3235,25 +3235,24 @@ void Message(char *string)
VW_UpdateScreen();
}
static int lastmusic;
static int lastmusic = -1;
void StartCPMusic(int song)
{
musicnames chunk;
SD_MusicOff();
CA_UnCacheAudioChunk(STARTMUSIC + lastmusic);
FreeMusic();
lastmusic = song;
chunk = song;
CA_CacheAudioChunk(STARTMUSIC + chunk);
MM_SetLock((memptr *)&(audiosegs[STARTMUSIC + chunk]),true);
SD_StartMusic((MusicGroup *)audiosegs[STARTMUSIC + chunk]);
CA_CacheAudioChunk(STARTMUSIC + song);
MM_SetLock((memptr *)&(audiosegs[STARTMUSIC + song]), true);
SD_StartMusic((MusicGroup *)audiosegs[STARTMUSIC + song]);
}
void FreeMusic()
{
SD_MusicOff();
if (lastmusic >= 0)
CA_UnCacheAudioChunk(STARTMUSIC + lastmusic);
}
......
......@@ -873,20 +873,9 @@ static void RemoveObj(objtype *gone)
void StopMusic()
{
int i;
SD_MusicOff();
for (i = 0;i < LASTMUSIC;i++)
if (audiosegs[STARTMUSIC + i])
{
MM_SetPurge((memptr)&(audiosegs[STARTMUSIC + i]),3);
MM_SetLock((memptr)&(audiosegs[STARTMUSIC + i]),false);
}
FreeMusic();
}
//==========================================================================
/*
=================
=
......@@ -897,14 +886,7 @@ void StopMusic()
void StartMusic()
{
musicnames chunk;
SD_MusicOff();
chunk = songs[gamestate.mapon+gamestate.episode*10];
CA_CacheAudioChunk(STARTMUSIC + chunk);
MM_SetLock((memptr)&(audiosegs[STARTMUSIC + chunk]),true);
SD_StartMusic((MusicGroup *)audiosegs[STARTMUSIC + chunk]);
StartCPMusic(songs[gamestate.mapon+gamestate.episode*10]);
}
......
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