-
Notifications
You must be signed in to change notification settings - Fork 130
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Strife: add true color support #1183
Changes from 15 commits
ad8376b
8dc3570
26fd68d
e870b44
3309930
9cdce80
00cd040
a2db299
81f9886
b658e7b
606dc34
e176cd5
0ea49bc
656c3f8
80e407b
999da5c
93f36f3
479d92b
a711fe8
ee486ae
9594624
faea87f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,6 +19,7 @@ | |
#include <string.h> | ||
|
||
#include "z_zone.h" | ||
#include "v_trans.h" // [crispy] blending functions | ||
#include "i_video.h" | ||
#include "v_video.h" | ||
#include "m_random.h" | ||
|
@@ -37,28 +38,31 @@ | |
// when zero, stop the wipe | ||
static boolean go = 0; | ||
|
||
static byte* wipe_scr_start; | ||
static byte* wipe_scr_end; | ||
static byte* wipe_scr; | ||
static pixel_t* wipe_scr_start; | ||
static pixel_t* wipe_scr_end; | ||
static pixel_t* wipe_scr; | ||
|
||
// [crispy] Additional fail-safe counter for performing crossfade effect. | ||
// Full crossfading takes 13 game tics and counter is armed in D_Display. | ||
int fade_safe_tics; | ||
|
||
void | ||
wipe_shittyColMajorXform | ||
( short* array, | ||
( dpixel_t* array, | ||
int width, | ||
int height ) | ||
{ | ||
int x; | ||
int y; | ||
short* dest; | ||
dpixel_t* dest; | ||
|
||
dest = (short*) Z_Malloc(width*height*2, PU_STATIC, 0); | ||
dest = (dpixel_t*) Z_Malloc(width*height*sizeof(*dest), PU_STATIC, 0); | ||
|
||
for(y=0;y<height;y++) | ||
for(x=0;x<width;x++) | ||
dest[x*height+y] = array[y*width+x]; | ||
|
||
memcpy(array, dest, width*height*2); | ||
memcpy(array, dest, width*height*sizeof(*dest)); | ||
|
||
Z_Free(dest); | ||
|
||
|
@@ -71,7 +75,7 @@ wipe_initColorXForm | |
int height, | ||
int ticks ) | ||
{ | ||
memcpy(wipe_scr, wipe_scr_start, width*height); | ||
memcpy(wipe_scr, wipe_scr_start, width*height*sizeof(*wipe_scr)); | ||
return 0; | ||
} | ||
|
||
|
@@ -88,18 +92,27 @@ wipe_doColorXForm | |
int height, | ||
int ticks ) | ||
{ | ||
byte *cur_screen = wipe_scr; | ||
byte *end_screen = wipe_scr_end; | ||
pixel_t *cur_screen = wipe_scr; | ||
pixel_t *end_screen = wipe_scr_end; | ||
int pix = width*height; | ||
int i; | ||
boolean changed = false; | ||
|
||
// [crispy] reduce fail-safe crossfade counter tics | ||
fade_safe_tics--; | ||
fabiangreffrath marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
for(i = pix; i > 0; i--) | ||
{ | ||
if(*cur_screen != *end_screen) | ||
if(*cur_screen != *end_screen && fade_safe_tics) | ||
fabiangreffrath marked this conversation as resolved.
Show resolved
Hide resolved
|
||
{ | ||
changed = true; | ||
#ifndef CRISPY_TRUECOLOR | ||
*cur_screen = xlatab[(*cur_screen << 8) + *end_screen]; | ||
#else | ||
// [crispy] perform crossfading effect with 13 given opacity steps, multipled by 19: | ||
// 247, 228, 209, 190, 171, 152, 133, 114, 95, 76, 57, 38, 19 | ||
*cur_screen = I_BlendOverCrossfade(*end_screen, *cur_screen, fade_safe_tics * 19); | ||
#endif | ||
} | ||
++cur_screen; | ||
++end_screen; | ||
|
@@ -130,12 +143,12 @@ wipe_initMelt | |
int i, r; | ||
|
||
// copy start screen to main screen | ||
memcpy(wipe_scr, wipe_scr_start, width*height); | ||
memcpy(wipe_scr, wipe_scr_start, width*height*sizeof(*wipe_scr)); | ||
|
||
// makes this wipe faster (in theory) | ||
// to have stuff in column-major format | ||
wipe_shittyColMajorXform((short*)wipe_scr_start, width/2, height); | ||
wipe_shittyColMajorXform((short*)wipe_scr_end, width/2, height); | ||
wipe_shittyColMajorXform((dpixel_t*)wipe_scr_start, width/2, height); | ||
wipe_shittyColMajorXform((dpixel_t*)wipe_scr_end, width/2, height); | ||
|
||
// setup initial column positions | ||
// (y<0 => not ready to scroll yet) | ||
|
@@ -163,8 +176,8 @@ wipe_doMelt | |
int dy; | ||
int idx; | ||
|
||
short* s; | ||
short* d; | ||
dpixel_t* s; | ||
dpixel_t* d; | ||
boolean done = true; | ||
|
||
width/=2; | ||
|
@@ -181,17 +194,17 @@ wipe_doMelt | |
{ | ||
dy = (y[i] < 16) ? y[i]+1 : 8; | ||
if (y[i]+dy >= height) dy = height - y[i]; | ||
s = &((short *)wipe_scr_end)[i*height+y[i]]; | ||
d = &((short *)wipe_scr)[y[i]*width+i]; | ||
s = &((dpixel_t *)wipe_scr_end)[i*height+y[i]]; | ||
d = &((dpixel_t *)wipe_scr)[y[i]*width+i]; | ||
idx = 0; | ||
for (j=dy;j;j--) | ||
{ | ||
d[idx] = *(s++); | ||
idx += width; | ||
} | ||
y[i] += dy; | ||
s = &((short *)wipe_scr_start)[i*height]; | ||
d = &((short *)wipe_scr)[y[i]*width+i]; | ||
s = &((dpixel_t *)wipe_scr_start)[i*height]; | ||
d = &((dpixel_t *)wipe_scr)[y[i]*width+i]; | ||
idx = 0; | ||
for (j=height-y[i];j;j--) | ||
{ | ||
|
@@ -227,7 +240,7 @@ wipe_StartScreen | |
int width, | ||
int height ) | ||
{ | ||
wipe_scr_start = Z_Malloc(SCREENWIDTH * SCREENHEIGHT, PU_STATIC, NULL); | ||
wipe_scr_start = Z_Malloc(SCREENWIDTH * SCREENHEIGHT * sizeof(*wipe_scr_start), PU_STATIC, NULL); | ||
I_ReadScreen(wipe_scr_start); | ||
return 0; | ||
} | ||
|
@@ -240,7 +253,7 @@ wipe_EndScreen | |
int width, | ||
int height ) | ||
{ | ||
wipe_scr_end = Z_Malloc(SCREENWIDTH * SCREENHEIGHT, PU_STATIC, NULL); | ||
wipe_scr_end = Z_Malloc(SCREENWIDTH * SCREENHEIGHT * sizeof(*wipe_scr_end), PU_STATIC, NULL); | ||
I_ReadScreen(wipe_scr_end); | ||
V_DrawBlock(x, y, width, height, wipe_scr_start); // restore start scr. | ||
return 0; | ||
|
@@ -268,17 +281,25 @@ wipe_ScreenWipe | |
{ | ||
go = 1; | ||
// haleyjd 20110629 [STRIFE]: We *must* use a temp buffer here. | ||
wipe_scr = (byte *) Z_Malloc(width*height, PU_STATIC, 0); // DEBUG | ||
#ifndef CRISPY_TRUECOLOR | ||
wipe_scr = (pixel_t *) Z_Malloc(width*height, PU_STATIC, 0); // DEBUG | ||
//wipe_scr = I_VideoBuffer; | ||
#else | ||
// [crispy] In TrueColor render perform everything in common buffer. | ||
// Otherwise serious malloc errors will happen. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Really, even if you allocate the correct amount of memory with There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, I'm afraid. "Debug" build type can survive it, but "Release" type almost imideatelly crashes after crossfade or next hitting of
Since it's not a simple game of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd like to have a closer look at this, probably this weekend, before I wave it through. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This works for me: --- a/src/strife/f_wipe.c
+++ b/src/strife/f_wipe.c
@@ -283,14 +283,8 @@ wipe_ScreenWipe
{
go = 1;
// haleyjd 20110629 [STRIFE]: We *must* use a temp buffer here.
-#ifndef CRISPY_TRUECOLOR
- wipe_scr = (pixel_t *) Z_Malloc(width*height, PU_STATIC, 0); // DEBUG
+ wipe_scr = (pixel_t *) Z_Malloc(width*height*sizeof(*wipe_scr), PU_STATIC, 0); // DEBUG
//wipe_scr = I_VideoBuffer;
-#else
- // [crispy] In TrueColor render perform everything in common buffer.
- // Otherwise serious malloc errors will happen.
- wipe_scr = I_VideoBuffer;
-#endif
(*wipes[wipeno*3])(width, height, ticks);
}
@@ -298,10 +292,8 @@ wipe_ScreenWipe
V_MarkRect(0, 0, width, height);
rc = (*wipes[wipeno*3+1])(width, height, ticks);
-#ifndef CRISPY_TRUECOLOR
// haleyjd 20110629 [STRIFE]: Copy temp buffer to the real screen.
V_DrawBlock(x, y, width, height, wipe_scr);
-#endif
// final stuff
if (rc) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah, I have missed most important part just like in other parts of wiping functions - There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd say let's go the Doom way. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. But for some reason there is this comment: // haleyjd 20110629 [STRIFE]: We *must* use a temp buffer here. So, better explicitly call There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Hm, didn't worked for me, that's odd. 🤔 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Well, There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You right, turns out, it's not a wipe, it's something else. Even if wipe is disabled here as:
...leak still happening. Probably something around with |
||
wipe_scr = I_VideoBuffer; | ||
#endif | ||
(*wipes[wipeno*3])(width, height, ticks); | ||
} | ||
|
||
// do a piece of wipe-in | ||
V_MarkRect(0, 0, width, height); | ||
rc = (*wipes[wipeno*3+1])(width, height, ticks); | ||
|
||
#ifndef CRISPY_TRUECOLOR | ||
// haleyjd 20110629 [STRIFE]: Copy temp buffer to the real screen. | ||
V_DrawBlock(x, y, width, height, wipe_scr); | ||
#endif | ||
|
||
// final stuff | ||
if (rc) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think now we have reached the point where we can leave this as the only actual implementation of
I_BlendOver()
and have all the other variants turned into macros with hard-codedamount
values.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've read all of your remarks, but let's please start from this one. I've got your idea of simplification and reducing amount of existing duplications and opacity values. This should be something like this:
But... You mean exactly to macrocize such "passing"
pixel_t
functions? Is it possible at all, without writing them in .c files? I never tried to write whole function as macro, so small hint or example will be very appreciated.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Something like
with the corresponding comment in
v_video.h
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Didn't worked on my side. In Doom all
I_BlendOver
calls replaced withI_BlendOverTranmap
(this one no longer exist ini_video.c
file), and header file contains:Compiler gives following multiple errors like:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, dammit, function pointers. Right this won't work. The solution you suggested before looked reasonable, though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in 999da5c. Yeah, to make pointers and cases like this happy, my another idea was to extend
I_BlendAdd
with incomingamount
parameter, but this is doesn't reasonable, since additive blending doesn't have any meanings of "amount" at all, and such parameter will be simply useless.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!