doomlegacy-devel: Import patchset d42_blockmap_endian.diff

Proposed by upstream.
Former pkgsrc blockmap patch dropped.
This commit is contained in:
Michael Baeuerle 2019-08-29 13:54:37 +02:00
parent 2e907e229d
commit c3b28ef631
10 changed files with 379 additions and 25 deletions

View File

@ -13,6 +13,8 @@ Build system doesn't support NetBSD.
=> Tested to work with SVN revision 1448
[X] Remove NetBSD specific patches after upstream integration
Part 1 finished.
Part 2: Fix large blockmaps on big endian machines
==================================================
@ -31,6 +33,9 @@ terminate the engine.
Note: This should never happen on little endian machines
=> PKGREVISION not bumped (SVN based packages use build date in version)
[X] Sent Blockmap patch to upstream (Bug #653)
[X] Imported proposed patchset d42_blockmap_endian.diff from upstream
=> Drop former pkgsrc patch
=> PKGREVISION not bumped (SVN based packages use build date in version)
Part 3: Torches are displayed crippled with software renderer
@ -54,5 +59,8 @@ Set "Corona" option to "Off" (verified to work on NetBSD).
Other workaround: It seems that only the option "Corona_Draw" set to "Additive"
is problematic. Coronas with other settings work.
[ ] Test patch d41_draw8_alpha.diff from upstream
Patch not released yet
EOF

View File

@ -6,4 +6,11 @@ SHA512 (doomlegacy_1.47.2_common.zip) = 7c7c2a0cbab5b9b4645a3fe166addd597de533db
Size (doomlegacy_1.47.2_common.zip) = 981654 bytes
SHA1 (patch-src_am__map.c) = 8d7d17d29c0934c92ca933e8976a5ecc692e465d
SHA1 (patch-src_d__main.c) = 3311e44522e863fa3e1a855754b876c03c96f128
SHA1 (patch-src_p__setup.c) = 615fda1d190ae20d2ee8fe662a13fd9ee6aff70d
SHA1 (patch-src_m__misc.c) = 1093a3f39bc71c1046d46aa6fc95f288695da533
SHA1 (patch-src_p__setup.c) = 22d03eee78910fea720e9956cdb9693a3302c1ec
SHA1 (patch-src_p__switch.c) = 5a050a1b84f36face057ebedb97d8e227d6f40d8
SHA1 (patch-src_qmus2mid.c) = 6a0febd16f99e508dadc086fab50202ad5a0d432
SHA1 (patch-src_r__data.c) = 07c1c7f544e12fcc929fefc86191feb6c272f73b
SHA1 (patch-src_r__sky.c) = 80facc839459585b197c529a4b8d6c6322bd9ff3
SHA1 (patch-src_r__things.c) = 40cddd63e9dfee6e6759b584a0cade0392d3f7ad
SHA1 (patch-src_w__wad.c) = 62d57f07d9118c25dbeb29478b4c200e25358527

View File

@ -0,0 +1,40 @@
$NetBSD$
Typecast signed result from LE_SWAP16 macro to unsigned where required.
Only relevant for big endian machines.
Proposed by upstream for test.
--- src/m_misc.c.orig 2019-08-21 09:16:46.000000000 +0000
+++ src/m_misc.c
@@ -713,14 +713,14 @@ boolean Write_PCXfile ( const char * fil
pcx->xmin = 0;
pcx->ymin = 0;
// [WDJ] The PCX format must be little-endian, must swap when big-endian
- pcx->xmax = LE_SWAP16(width-1);
- pcx->ymax = LE_SWAP16(height-1);
- pcx->hres = LE_SWAP16(width);
- pcx->vres = LE_SWAP16(height);
+ pcx->xmax = (uint16_t)( LE_SWAP16(width-1) );
+ pcx->ymax = (uint16_t)( LE_SWAP16(height-1) );
+ pcx->hres = (uint16_t)( LE_SWAP16(width) );
+ pcx->vres = (uint16_t)( LE_SWAP16(height) );
memset (pcx->palette,0,sizeof(pcx->palette));
pcx->color_planes = 1; // chunky image
- pcx->bytes_per_line = LE_SWAP16(width);
- pcx->palette_type = LE_SWAP16(1); // Color (2=grey scale)
+ pcx->bytes_per_line = (uint16_t)( LE_SWAP16(width) );
+ pcx->palette_type = (uint16_t)( LE_SWAP16(1) ); // Color (2=grey scale)
memset (pcx->filler,0,sizeof(pcx->filler));
@@ -788,8 +788,8 @@ boolean Write_TGA( const char * filenam
memset(&tga_hdr, 0, sizeof(tga_hdr));
// TGA format is little-endian
- tga_hdr.width = LE_SWAP16(width);
- tga_hdr.height = LE_SWAP16(height);
+ tga_hdr.width = (uint16_t)( LE_SWAP16(width) );
+ tga_hdr.height = (uint16_t)( LE_SWAP16(height) );
tga_hdr.image_pix_size = bitpp; // normal, 24 bits per pixel
tga_hdr.image_type = 2; // Uncompressed, RGB
tga_hdr.image_descriptor = 0x20; // bit 5, origin in upper left-hand corner

View File

@ -1,37 +1,174 @@
$NetBSD$
Correctly convert the 16-Bit blockmap offset (as imported from wad) to the
32-Bit format of the engine. On big endian machines this can overrun the
int16_t data type which leads to 32-Bit values padded with ones instead of
zeros.
Typecast signed result from LE_SWAP16 macro to unsigned where required.
Only relevant for big endian machines.
Proposed by upstream for test.
--- src/p_setup.c.orig 2019-08-21 08:45:39.000000000 +0000
Last hunk contains the former pkgsrc patch that was sent to upstream.
--- src/p_setup.c.orig 2019-08-21 09:16:38.000000000 +0000
+++ src/p_setup.c
@@ -149,6 +149,8 @@
//
//-----------------------------------------------------------------------------
@@ -348,6 +348,7 @@ void P_LoadVertexes (lumpnum_t lumpnum)
// internal representation as fixed.
for (i=0 ; i<numvertexes ; i++, li++, ml++)
{
+ // signed
li->x = LE_SWAP16(ml->x)<<FRACBITS;
li->y = LE_SWAP16(ml->y)<<FRACBITS;
}
@@ -404,6 +405,7 @@ void P_LoadSegs ( lumpnum_t lumpnum )
for (i=0 ; i<numsegs ; i++, li++, ml++)
{
// [WDJ] Detect buggy wad, bad vertex number
+ // signed
vn1 = LE_SWAP16(ml->v1);
vn2 = LE_SWAP16(ml->v2);
if( vn1 > numvertexes || vn2 > numvertexes )
@@ -429,7 +431,7 @@ void P_LoadSegs ( lumpnum_t lumpnum )
+#include "inttypes.h"
+
#include "doomincl.h"
#include "p_local.h"
#include "p_tick.h"
@@ -1338,6 +1340,7 @@ void P_LoadBlockMap (int lump)
li->angle = (LE_SWAP16(ml->angle))<<16;
li->offset = (LE_SWAP16(ml->offset))<<16;
- linedef = LE_SWAP16(ml->linedef);
+ linedef = (uint16_t)( LE_SWAP16(ml->linedef) );
// [WDJ] Detect buggy wad, bad linedef number
if( linedef > numlines ) {
I_SoftError( "P_LoadSegs, linedef #%i, > numlines %i\n", linedef, numlines );
@@ -437,7 +439,7 @@ void P_LoadSegs ( lumpnum_t lumpnum )
}
ldef = &lines[linedef];
li->linedef = ldef;
- side = LE_SWAP16(ml->side);
+ side = (uint16_t)( LE_SWAP16(ml->side) );
if( side != 0 && side != 1 )
{
// [WDJ] buggy wad
@@ -497,8 +499,8 @@ void P_LoadSubsectors( lumpnum_t lumpnum
for (i=0 ; i<numsubsectors ; i++, ss++, ms++)
{
- ss->numlines = LE_SWAP16(ms->numsegs);
- ss->firstline = LE_SWAP16(ms->firstseg); // unsigned
+ ss->numlines = (uint16_t)( LE_SWAP16(ms->numsegs) );
+ ss->firstline = (uint16_t)( LE_SWAP16(ms->firstseg) ); // unsigned
// cannot check if valid, segs not loaded yet
}
@@ -679,6 +681,7 @@ void P_LoadSectors( lumpnum_t lumpnum )
ss = sectors;
for (i=0 ; i<numsectors ; i++, ss++, ms++)
{
+ // signed
ss->floorheight = LE_SWAP16(ms->floorheight)<<FRACBITS;
ss->ceilingheight = LE_SWAP16(ms->ceilingheight)<<FRACBITS;
@@ -702,9 +705,10 @@ void P_LoadSectors( lumpnum_t lumpnum )
ss->floorpic = P_AddLevelFlat (ms->floorpic);
ss->ceilingpic = P_AddLevelFlat (ms->ceilingpic);
- ss->lightlevel = LE_SWAP16(ms->lightlevel);
- ss->special = LE_SWAP16(ms->special);
- ss->tag = LE_SWAP16(ms->tag);
+ ss->lightlevel = (uint16_t)( LE_SWAP16(ms->lightlevel) );
+ // all values are unsigned, but special field is signed short
+ ss->special = (uint16_t)( LE_SWAP16(ms->special) );
+ ss->tag = (uint16_t)( LE_SWAP16(ms->tag) ); // unsigned
ss->thinglist = NULL;
ss->touching_thinglist = NULL; //SoM: 4/7/2000
@@ -789,7 +793,7 @@ void P_LoadNodes (int lump)
no->dy = LE_SWAP16(mn->dy)<<FRACBITS;
for (j=0 ; j<2 ; j++)
{
- no->children[j] = LE_SWAP16(mn->children[j]);
+ no->children[j] = (uint16_t)( LE_SWAP16(mn->children[j]) );
for (k=0 ; k<4 ; k++)
no->bbox[j][k] = LE_SWAP16(mn->bbox[j][k])<<FRACBITS;
}
@@ -843,8 +847,8 @@ void P_LoadThings (int lump)
mt->x = LE_SWAP16(dmt->x);
mt->y = LE_SWAP16(dmt->y);
mt->angle = LE_SWAP16(dmt->angle);
- mt->type = LE_SWAP16(dmt->type);
- mt->options = LE_SWAP16(dmt->flags);
+ mt->type = LE_SWAP16(dmt->type); // DoomEd number
+ mt->options = (uint16_t)( LE_SWAP16(dmt->flags) ); // bit flags
mt->mobj = NULL; //SoM:
if( gamedesc_id == GDESC_tnt && gamemap == 31)
@@ -897,9 +901,9 @@ void P_LoadLineDefs (int lump)
ld = lines;
for (i=0 ; i<numlines ; i++, mld++, ld++)
{
- ld->flags = (uint16_t) LE_SWAP16(mld->flags);
- ld->special = LE_SWAP16(mld->special);
- ld->tag = LE_SWAP16(mld->tag);
+ ld->flags = (uint16_t)( LE_SWAP16(mld->flags) ); // bit flags
+ ld->special = (uint16_t)( LE_SWAP16(mld->special) );
+ ld->tag = (uint16_t)( LE_SWAP16(mld->tag) );
v1 = ld->v1 = &vertexes[ LE_SWAP16(mld->v1) ];
v2 = ld->v2 = &vertexes[ LE_SWAP16(mld->v2) ];
ld->dx = v2->x - v1->x;
@@ -942,8 +946,8 @@ void P_LoadLineDefs (int lump)
// Set soundorg in P_GroupLines
// NULL_INDEX = no sidedef
- ld->sidenum[0] = LE_SWAP16(mld->sidenum[0]);
- ld->sidenum[1] = LE_SWAP16(mld->sidenum[1]);
+ ld->sidenum[0] = (uint16_t)( LE_SWAP16(mld->sidenum[0]) );
+ ld->sidenum[1] = (uint16_t)( LE_SWAP16(mld->sidenum[1]) );
// [WDJ] detect common wad errors and make playable, similar to prboom
if( ld->sidenum[0] == NULL_INDEX )
@@ -1057,7 +1061,7 @@ void P_LoadSideDefs (int lump)
sd->bottomtexture = R_TextureNumForName(msd->bottomtexture);
sd->midtexture = R_TextureNumForName(msd->midtexture);
- sd->sector = &sectors[LE_SWAP16(msd->sector)];
+ sd->sector = &sectors[ (uint16_t)( LE_SWAP16(msd->sector) )];
}
Z_Free (data);
@@ -1123,7 +1127,7 @@ void P_LoadSideDefs2(int lump)
// Check if valid texture first, on failure check if valid colormap,
// because we have func that can check texture without error.
- uint16_t secnum = LE_SWAP16(msd->sector);
+ uint16_t secnum = (uint16_t)( LE_SWAP16(msd->sector) );
// [WDJ] Check for buggy wad, like prboom
if( secnum >= numsectors )
{
@@ -1331,8 +1335,8 @@ void P_LoadBlockMap (int lump)
blockmaphead[0] = LE_SWAP16(wadblockmaplump[0]); // map orgin_x
blockmaphead[1] = LE_SWAP16(wadblockmaplump[1]); // map orgin_y
- blockmaphead[2] = LE_SWAP16(wadblockmaplump[2]); // number columns (x size)
- blockmaphead[3] = LE_SWAP16(wadblockmaplump[3]); // number rows (y size)
+ blockmaphead[2] = (uint16_t)( LE_SWAP16(wadblockmaplump[2]) ); // number columns (x size)
+ blockmaphead[3] = (uint16_t)( LE_SWAP16(wadblockmaplump[3]) ); // number rows (y size)
bmaporgx = blockmaphead[0]<<FRACBITS;
bmaporgy = blockmaphead[1]<<FRACBITS;
bmapwidth = blockmaphead[2];
bmapheight = blockmaphead[3];
+ printf("[MB] Blockmap size (X/Y): %d/%d\n", bmapwidth, bmapheight);
blockmapindex = & blockmaphead[4];
firstlist = 4 + (bmapwidth*bmapheight);
lastlist = count - 1;
@@ -1348,7 +1351,9 @@ void P_LoadBlockMap (int lump)
@@ -1348,7 +1352,10 @@ void P_LoadBlockMap (int lump)
// read blockmap index array
for (i=4 ; i<firstlist ; i++) // for all entries in wad offset index
{
- uint32_t bme = LE_SWAP16(wadblockmaplump[i]); // offset
+ printf("[MB] Raw blockmap offset: %d\n", LE_SWAP16(wadblockmaplump[i]));
+ uint32_t bme = (uint16_t) LE_SWAP16(wadblockmaplump[i]); // offset
+ printf("[MB] Cooked blockmap offset: 0x%08"PRIX32"\n", bme);
+ // [WDJ] LE_SWAP16 returns a 16 bit signed value on a big-endian machine,
+ // so must make it unsigned, otherwise it can get sign extended.
+ // Found by Michael Bauerle.
+ uint32_t bme = (uint16_t)( LE_SWAP16(wadblockmaplump[i]) ); // offset
// upon overflow, the bme will wrap to low values
if ( (bme < firstlist) // too small to be valid
&& (bme < 0x1000) && (prev_bme > 0xf000)) // wrapped
@@ -1384,8 +1391,9 @@ void P_LoadBlockMap (int lump)
for (i=firstlist ; i<count ; i++) // for all list entries in wad blockmap
{
// killough 3/1/98
- // keep -1 (0xffff), but other values are unsigned
- uint16_t bme = LE_SWAP16(wadblockmaplump[i]);
+ // Unsigned except for -1, which will be read as 0xFFFF.
+ // [WDJ] LE_SWAP16 is signed on big-endian machines, so convert to prevent errors.
+ uint16_t bme = (uint16_t)( LE_SWAP16(wadblockmaplump[i]) );
blockmaphead[i] = (bme == 0xffff)? ((uint32_t) -1) : ((uint32_t) bme);
}

View File

@ -0,0 +1,17 @@
$NetBSD$
Typecast signed result from LE_SWAP16 macro to unsigned where required.
Only relevant for big endian machines.
Proposed by upstream for test.
--- src/p_switch.c.orig 2019-08-21 09:16:55.000000000 +0000
+++ src/p_switch.c
@@ -190,7 +190,7 @@ void P_Init_SwitchList(void)
{
// endian conversion only when loading from extra lump
for (i=0;alphSwitchList[i].episode!=0;i++)
- alphSwitchList[i].episode = LE_SWAP16(alphSwitchList[i].episode);
+ alphSwitchList[i].episode = (uint16_t)( LE_SWAP16(alphSwitchList[i].episode) );
}
#endif
}

View File

@ -0,0 +1,33 @@
$NetBSD$
Typecast signed result from LE_SWAP16 macro to unsigned where required.
Only relevant for big endian machines.
Proposed by upstream for test.
--- src/qmus2mid.c.orig 2019-08-21 09:16:55.000000000 +0000
+++ src/qmus2mid.c
@@ -113,17 +113,17 @@ void* S_CacheMusicLump(int lump)
if (lump_read && memcmp(data, MUSHEADER, 4) == 0) {
/* Header should be at beginning of opaque data pointer */
MUSheader *mh = (MUSheader*)data;
- mh->scoreLength = LE_SWAP16(mh->scoreLength);
- mh->scoreStart = LE_SWAP16(mh->scoreStart);
- mh->channels = LE_SWAP16(mh->channels);
- mh->sec_channels = LE_SWAP16(mh->sec_channels);
- mh->instrCnt = LE_SWAP16(mh->instrCnt);
+ mh->scoreLength = (uint16_t)( LE_SWAP16(mh->scoreLength) );
+ mh->scoreStart = (uint16_t)( LE_SWAP16(mh->scoreStart) );
+ mh->channels = (uint16_t)( LE_SWAP16(mh->channels) );
+ mh->sec_channels = (uint16_t)( LE_SWAP16(mh->sec_channels) );
+ mh->instrCnt = (uint16_t)( LE_SWAP16(mh->instrCnt) );
/* Probably unnecessary if this is just padding */
- mh->dummy = LE_SWAP16(mh->dummy);
+ mh->dummy = (uint16_t)( LE_SWAP16(mh->dummy) );
uint16_t i;
for (i = 0; i < mh->instrCnt; ++i) {
- mh->instruments[i] = LE_SWAP16(mh->instruments[i]);
+ mh->instruments[i] = (uint16_t)( LE_SWAP16(mh->instruments[i]) );
}
}

View File

@ -0,0 +1,35 @@
$NetBSD$
Typecast signed result from LE_SWAP16 macro to unsigned where required.
Only relevant for big endian machines.
Proposed by upstream for test.
--- src/r_data.c.orig 2019-08-21 09:16:38.000000000 +0000
+++ src/r_data.c
@@ -1587,13 +1587,13 @@ void R_Load_Textures (void)
// Texture struct allocation is dependent upon number of patches.
texture = textures[i] =
Z_Malloc (sizeof(texture_t)
- + sizeof(texpatch_t)*(LE_SWAP16(mtexture->patchcount)-1),
+ + sizeof(texpatch_t)*((uint16_t)(LE_SWAP16(mtexture->patchcount))-1),
PU_STATIC, 0);
// get texture info from texture lump
- texture->width = LE_SWAP16(mtexture->width);
- texture->height = LE_SWAP16(mtexture->height);
- texture->patchcount = LE_SWAP16(mtexture->patchcount);
+ texture->width = (uint16_t)( LE_SWAP16(mtexture->width) );
+ texture->height = (uint16_t)( LE_SWAP16(mtexture->height) );
+ texture->patchcount = (uint16_t)( LE_SWAP16(mtexture->patchcount) );
texture->texture_model = (mtexture->masked)? TM_masked : TM_none; // hint
// Sparc requires memmove, becuz gcc doesn't know mtexture is not aligned.
@@ -1611,7 +1611,7 @@ void R_Load_Textures (void)
// get texture patch info from texture lump
texpatch->originx = LE_SWAP16(mpatch->originx);
texpatch->originy = LE_SWAP16(mpatch->originy);
- texpatch->patchnum = patch_to_num[LE_SWAP16(mpatch->patchnum)];
+ texpatch->patchnum = patch_to_num[ (uint16_t)( LE_SWAP16(mpatch->patchnum) )];
if (texpatch->patchnum == -1)
{
I_Error ("R_Load_Textures: Missing patch in texture %s\n",

View File

@ -0,0 +1,17 @@
$NetBSD$
Typecast signed result from LE_SWAP16 macro to unsigned where required.
Only relevant for big endian machines.
Proposed by upstream for test.
--- src/r_sky.c.orig 2019-08-21 09:16:38.000000000 +0000
+++ src/r_sky.c
@@ -112,7 +112,7 @@ void R_Setup_SkyDraw (void)
{
W_ReadLumpHeader (texpatch->patchnum, &wpatch, sizeof(patch_t));
// [WDJ] Do endian fix as this is read.
- wpatch.height = LE_SWAP16(wpatch.height);
+ wpatch.height = (uint16_t)( LE_SWAP16(wpatch.height) );
if( wpatch.height > max_height )
max_height = wpatch.height;
texpatch++;

View File

@ -0,0 +1,30 @@
$NetBSD$
Typecast signed result from LE_SWAP16 macro to unsigned where required.
Only relevant for big endian machines.
Proposed by upstream for test.
--- src/r_things.c.orig 2019-08-21 09:16:38.000000000 +0000
+++ src/r_things.c
@@ -572,10 +572,10 @@ boolean R_AddSingleSpriteDef (char* sprn
// [WDJ] Do endian while translate temp to internal.
spritelump_id = R_Get_spritelump(); // get next index, may expand and move the table
spritelump_t * sl = &spritelumps[spritelump_id]; // sprite patch header
- sl->width = LE_SWAP16(patch.width)<<FRACBITS;
+ sl->width = ((uint16_t)( LE_SWAP16(patch.width) ))<<FRACBITS;
sl->leftoffset = LE_SWAP16(patch.leftoffset)<<FRACBITS;
sl->topoffset = LE_SWAP16(patch.topoffset)<<FRACBITS;
- sl->height = LE_SWAP16(patch.height)<<FRACBITS;
+ sl->height = ((uint16_t)( LE_SWAP16(patch.height) ))<<FRACBITS;
#ifdef HWRENDER
//BP: we cannot use special trick in hardware mode because feet in ground caused by z-buffer
@@ -583,7 +583,7 @@ boolean R_AddSingleSpriteDef (char* sprn
{
// topoffset may be negative, use signed compare
int16_t p_topoffset = LE_SWAP16(patch.topoffset);
- int16_t p_height = LE_SWAP16(patch.height);
+ int16_t p_height = (uint16_t)( LE_SWAP16(patch.height) );
if( p_topoffset>0 && p_topoffset<p_height) // not for psprite
{
// perfect is patch.height but sometime it is too high

View File

@ -0,0 +1,30 @@
$NetBSD$
Typecast signed result from LE_SWAP16 macro to unsigned where required.
Only relevant for big endian machines.
Proposed by upstream for test.
--- src/w_wad.c.orig 2019-08-21 09:16:55.000000000 +0000
+++ src/w_wad.c
@@ -900,8 +900,8 @@ void* W_CachePatchNum_Endian ( lumpnum_t
// [WDJ] If newly read patch then fix endian.
if( lump_read )
{
- patch->height = LE_SWAP16(patch->height);
- patch->width = LE_SWAP16(patch->width);
+ patch->height = (uint16_t)( LE_SWAP16(patch->height) );
+ patch->width = (uint16_t)( LE_SWAP16(patch->width) );
patch->topoffset = LE_SWAP16(patch->topoffset);
patch->leftoffset = LE_SWAP16(patch->leftoffset);
{
@@ -1094,8 +1094,8 @@ void* W_CachePicNum( lumpnum_t lumpnum,
// [WDJ] If newly read pic then fix endian.
if( lump_read )
{
- pt->height = LE_SWAP16(pt->height);
- pt->width = LE_SWAP16(pt->width);
+ pt->height = (uint16_t)( LE_SWAP16(pt->height) );
+ pt->width = (uint16_t)( LE_SWAP16(pt->width) );
// pt->reserved = LE_SWAP16(pt->reserved);
}
return pt;