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