IPU renders floor and ceiling geometry (untextured)

This commit is contained in:
jndean
2023-11-11 19:02:06 +00:00
parent 0c00d97494
commit eeb4bb38d2
9 changed files with 67 additions and 229 deletions
+3 -1
View File
@@ -8,9 +8,11 @@
// #define IPUMALLOC_DEBUGPRINT 0
__attribute__ ((aligned (4)))
static unsigned char IPUMALLOC_STATIC_pool[10000];
__attribute__ ((aligned (4)))
static unsigned char IPUMALLOC_LEVEL_pool[200000];
__attribute__ ((aligned (4)))
static unsigned char IPUMALLOC_TMP_pool[512]; // This is a category I made up, for fleeting allocations
static unsigned char* pools[IPUMALLOC_NUMPOOLS] = {
+3
View File
@@ -61,6 +61,9 @@ struct DivWorker : public poplar::Vertex {
}
};
extern "C"
__SUPER__
fixed_t FixedDiv(fixed_t a, fixed_t b)
{
if ((abs(a) >> 14) >= abs(b)) {
-1
View File
@@ -36,5 +36,4 @@ __SUPER__ fixed_t FixedMul (fixed_t a, fixed_t b);
__SUPER__ fixed_t FixedDiv (fixed_t a, fixed_t b);
#endif
-1
View File
@@ -13,7 +13,6 @@
extern "C" {
__SUPER__ void R_InitTextures(int* maptex);
__SUPER__ void R_InitTextures_TT(int* maptex);
__SUPER__ void R_RenderPlayerView(player_t *player);
__SUPER__ void R_ExecuteSetViewSize(void);
};
+2 -183
View File
@@ -545,8 +545,8 @@ void R_InitTextures(int* maptex) {
// "textures[i]"
// );
texture->width = SHORT(mtexture->width);
texture->height = SHORT(mtexture->height);
texture->width = (int)SHORT(mtexture->width);
texture->height = (int)SHORT(mtexture->height);
// texture->patchcount = SHORT(mtexture->patchcount); // JOSEF
// memcpy(texture->name, mtexture->name, sizeof(texture->name)); // JOSEF
@@ -604,187 +604,6 @@ void R_InitTextures(int* maptex) {
}
//
// R_InitTextures__
// Initializes the texture list
// with the textures from the world map.
// JOSEF: This is the version that runs on the texture tiles
//
void R_InitTextures_TT(void) {
maptexture_t *mtexture;
texture_t *texture;
mappatch_t *mpatch;
texpatch_t *patch;
/*
int i;
int j;
int *maptex;
int *maptex2;
int *maptex1;
char name[9];
char *names;
char *name_p;
int *patchlookup;
int totalwidth;
int nummappatches;
int offset;
int maxoff;
int maxoff2;
int numtextures1;
int numtextures2;
int *directory;
int temp1;
int temp2;
int temp3;
// Load the patch names from pnames.lmp.
name[8] = 0;
names = W_CacheLumpName(("PNAMES"), PU_STATIC);
nummappatches = LONG(*((int *)names));
name_p = names + 4;
patchlookup = Z_Malloc(nummappatches * sizeof(*patchlookup), PU_STATIC, NULL);
for (i = 0; i < nummappatches; i++) {
M_StringCopy(name, name_p + i * 8, sizeof(name));
patchlookup[i] = W_CheckNumForName(name);
}
W_ReleaseLumpName(("PNAMES"));
// Load the map texture definitions from textures.lmp.
// The data is contained in one or two lumps,
// TEXTURE1 for shareware, plus TEXTURE2 for commercial.
maptex = maptex1 = W_CacheLumpName(("TEXTURE1"), PU_STATIC);
numtextures1 = LONG(*maptex);
maxoff = W_LumpLength(W_GetNumForName(("TEXTURE1")));
directory = maptex + 1;
if (W_CheckNumForName(("TEXTURE2")) != -1) {
maptex2 = W_CacheLumpName(("TEXTURE2"), PU_STATIC);
numtextures2 = LONG(*maptex2);
maxoff2 = W_LumpLength(W_GetNumForName(("TEXTURE2")));
} else {
maptex2 = NULL;
numtextures2 = 0;
maxoff2 = 0;
}
numtextures = numtextures1 + numtextures2;
textures = Z_Malloc(numtextures * sizeof(*textures), PU_STATIC, 0);
texturecolumnlump =
Z_Malloc(numtextures * sizeof(*texturecolumnlump), PU_STATIC, 0);
texturecolumnofs =
Z_Malloc(numtextures * sizeof(*texturecolumnofs), PU_STATIC, 0);
texturecomposite =
Z_Malloc(numtextures * sizeof(*texturecomposite), PU_STATIC, 0);
texturecompositesize =
Z_Malloc(numtextures * sizeof(*texturecompositesize), PU_STATIC, 0);
texturewidthmask =
Z_Malloc(numtextures * sizeof(*texturewidthmask), PU_STATIC, 0);
textureheight = Z_Malloc(numtextures * sizeof(*textureheight), PU_STATIC, 0);
totalwidth = 0;
// Really complex printing shit...
temp1 = W_GetNumForName(("S_START")); // P_???????
temp2 = W_GetNumForName(("S_END")) - 1;
temp3 = ((temp2 - temp1 + 63) / 64) + ((numtextures + 63) / 64);
// If stdout is a real console, use the classic vanilla "filling
// up the box" effect, which uses backspace to "step back" inside
// the box. If stdout is a file, don't draw the box.
if (I_ConsoleStdout()) {
printf("[");
for (i = 0; i < temp3 + 9; i++)
printf(" ");
printf("]");
for (i = 0; i < temp3 + 10; i++)
printf("\b");
}
for (i = 0; i < numtextures; i++, directory++) {
if (!(i & 63))
printf(".");
if (i == numtextures1) {
// Start looking in second texture file.
maptex = maptex2;
maxoff = maxoff2;
directory = maptex + 1;
}
offset = LONG(*directory);
if (offset > maxoff)
I_Error("R_InitTextures: bad texture directory");
mtexture = (maptexture_t *)((byte *)maptex + offset);
texture = textures[i] =
Z_Malloc(sizeof(texture_t) +
sizeof(texpatch_t) * (SHORT(mtexture->patchcount) - 1),
PU_STATIC, 0);
texture->width = SHORT(mtexture->width);
texture->height = SHORT(mtexture->height);
texture->patchcount = SHORT(mtexture->patchcount);
memcpy(texture->name, mtexture->name, sizeof(texture->name));
mpatch = &mtexture->patches[0];
patch = &texture->patches[0];
for (j = 0; j < texture->patchcount; j++, mpatch++, patch++) {
patch->originx = SHORT(mpatch->originx);
patch->originy = SHORT(mpatch->originy);
patch->patch = patchlookup[SHORT(mpatch->patch)];
if (patch->patch == -1) {
I_Error("R_InitTextures: Missing patch in texture %s", texture->name);
}
}
texturecolumnlump[i] =
Z_Malloc(texture->width * sizeof(**texturecolumnlump), PU_STATIC, 0);
texturecolumnofs[i] =
Z_Malloc(texture->width * sizeof(**texturecolumnofs), PU_STATIC, 0);
j = 1;
while (j * 2 <= texture->width)
j <<= 1;
texturewidthmask[i] = j - 1;
textureheight[i] = texture->height << FRACBITS;
totalwidth += texture->width;
}
Z_Free(patchlookup);
W_ReleaseLumpName(("TEXTURE1"));
if (maptex2)
W_ReleaseLumpName(("TEXTURE2"));
// Precalculate whatever possible.
for (i = 0; i < numtextures; i++)
R_GenerateLookup(i);
// Create translation table for global animation.
texturetranslation =
Z_Malloc((numtextures + 1) * sizeof(*texturetranslation), PU_STATIC, 0);
for (i = 0; i < numtextures; i++)
texturetranslation[i] = i;
GenerateTextureHashTable();
*/
}
/*
//
// R_InitFlats
+2 -1
View File
@@ -127,7 +127,8 @@ int tileID;
int tileLeftClip;
int tileRightClip;
int abs(int);
// __SUPER__
int abs(int x);
//
// R_AddPointToBox
+29 -9
View File
@@ -39,9 +39,11 @@
// #include "w_wad.h" // LATER
// #include "z_zone.h" // LATER
#include "ipu_interface.h"
#include "print.h"
planefunction_t floorfunc;
planefunction_t ceilingfunc;
@@ -92,6 +94,10 @@ fixed_t cacheddistance[SCREENHEIGHT];
fixed_t cachedxstep[SCREENHEIGHT];
fixed_t cachedystep[SCREENHEIGHT];
__SUPER__
int abs(int x); // JOSEF
//
// R_InitPlanes
// Only at game startup.
@@ -193,6 +199,7 @@ void R_ClearPlanes(void) {
//
// R_FindPlane
//
__SUPER__
visplane_t *R_FindPlane(fixed_t height, int picnum, int lightlevel) {
visplane_t *check;
@@ -228,10 +235,10 @@ visplane_t *R_FindPlane(fixed_t height, int picnum, int lightlevel) {
return check;
}
/*
//
// R_CheckPlane
//
__SUPER__
visplane_t *R_CheckPlane(visplane_t *pl, int start, int stop) {
int intrl;
int intrh;
@@ -281,6 +288,7 @@ visplane_t *R_CheckPlane(visplane_t *pl, int start, int stop) {
return pl;
}
/*
//
// R_MakeSpans
//
@@ -318,6 +326,7 @@ void R_DrawPlanes(void) {
int angle;
int lumpnum;
// if (tileID == 0) asm("trap 0");
if (ds_p - drawsegs > MAXDRAWSEGS)
printf("R_DrawPlanes: drawsegs overflow (%u)\n", ds_p - drawsegs);
// I_Error("R_DrawPlanes: drawsegs overflow (%i)", ds_p - drawsegs);
@@ -330,13 +339,15 @@ void R_DrawPlanes(void) {
printf("R_DrawPlanes: opening overflow (%u)\n", lastopening - openings);
// I_Error("R_DrawPlanes: opening overflow (%i)", lastopening - openings);
/*
// printf("num visplanes = %d\n", lastvisplane - visplanes);
for (pl = visplanes; pl < lastvisplane; pl++) {
if (pl->minx > pl->maxx)
continue;
// sky flat
if (pl->picnum == skyflatnum) {
/* LATER
dc_iscale = pspriteiscale >> detailshift;
// Sky is allways drawn full bright,
@@ -356,12 +367,14 @@ void R_DrawPlanes(void) {
colfunc();
}
}
*/
continue;
}
// LATER
// regular flat
lumpnum = firstflat + flattranslation[pl->picnum];
ds_source = W_CacheLumpNum(lumpnum, PU_STATIC);
// lumpnum = firstflat + flattranslation[pl->picnum];
// ds_source = W_CacheLumpNum(lumpnum, PU_STATIC);
planeheight = abs(pl->height - viewz);
light = (pl->lightlevel >> LIGHTSEGSHIFT) + extralight;
@@ -372,7 +385,7 @@ void R_DrawPlanes(void) {
if (light < 0)
light = 0;
planezlight = zlight[light];
// // planezlight = zlight[light]; // LATER
pl->top[pl->maxx + 1] = 0xff;
pl->top[pl->minx - 1] = 0xff;
@@ -380,11 +393,18 @@ void R_DrawPlanes(void) {
stop = pl->maxx + 1;
for (x = pl->minx; x <= stop; x++) {
R_MakeSpans(x, pl->top[x - 1], pl->bottom[x - 1], pl->top[x],
pl->bottom[x]);
// LATER
// R_MakeSpans(x, pl->top[x - 1], pl->bottom[x - 1], pl->top[x],
// pl->bottom[x]);
// JOSEF: TMP solid colour visualisation
for (int y = pl->top[x]; y <= pl->bottom[x]; y++) {
pixel_t* dest = (I_VideoBuffer + (y + viewwindowy) * IPUCOLSPERRENDERTILE) + (viewwindowx + x - tileLeftClip);
*dest = 189;
}
}
W_ReleaseLumpNum(lumpnum);
// W_ReleaseLumpNum(lumpnum); // LATER
}
*/
}
+27 -32
View File
@@ -96,8 +96,9 @@ unsigned walllightindex; // JOSEF
short *maskedtexturecol;
__SUPER__
int abs(int); // JOSEF
// __SUPER__
int abs(int x); // JOSEF
/*
//
@@ -213,34 +214,32 @@ void R_RenderSegLoop(void) {
if (yl < ceilingclip[rw_x] + 1)
yl = ceilingclip[rw_x] + 1;
// LATER
// if (markceiling) {
// top = ceilingclip[rw_x] + 1;
// bottom = yl - 1;
// if (bottom >= floorclip[rw_x])
// bottom = floorclip[rw_x] - 1;
// if (top <= bottom) {
// ceilingplane->top[rw_x] = top;
// ceilingplane->bottom[rw_x] = bottom;
// }
// }
if (markceiling) {
top = ceilingclip[rw_x] + 1;
bottom = yl - 1;
if (bottom >= floorclip[rw_x])
bottom = floorclip[rw_x] - 1;
if (top <= bottom) {
ceilingplane->top[rw_x] = top;
ceilingplane->bottom[rw_x] = bottom;
}
}
yh = bottomfrac >> HEIGHTBITS;
if (yh >= floorclip[rw_x])
yh = floorclip[rw_x] - 1;
// LATER
// if (markfloor) {
// top = yh + 1;
// bottom = floorclip[rw_x] - 1;
// if (top <= ceilingclip[rw_x])
// top = ceilingclip[rw_x] + 1;
// if (top <= bottom) {
// floorplane->top[rw_x] = top;
// floorplane->bottom[rw_x] = bottom;
// }
// }
if (markfloor) {
top = yh + 1;
bottom = floorclip[rw_x] - 1;
if (top <= ceilingclip[rw_x])
top = ceilingclip[rw_x] + 1;
if (top <= bottom) {
floorplane->top[rw_x] = top;
floorplane->bottom[rw_x] = bottom;
}
}
// texturecolumn and lighting are independent of wall tiers
if (segtextured) {
@@ -254,11 +253,7 @@ void R_RenderSegLoop(void) {
if (walllightindex >= MAXLIGHTSCALE) // JOSEF: walllightindex
walllightindex = MAXLIGHTSCALE - 1; // JOSEF: walllightindex
// if (tileID == 0 && curline->v1->x == -30932992 && curline->v1->y == -31457280 && curline->v2->x ==-30932992 && curline->v2->y == -14155776)
// dc_colormap = walllights[index]; // JOSEF: Texturetile handles this
dc_x = rw_x;
dc_iscale = 0xffffffffu / (unsigned)rw_scale;
} else {
@@ -620,11 +615,11 @@ void R_StoreWallRange(int start, int stop) {
}
// render it
// if (markceiling)
// ceilingplane = R_CheckPlane(ceilingplane, rw_x, rw_stopx - 1); // LATER
if (markceiling)
ceilingplane = R_CheckPlane(ceilingplane, rw_x, rw_stopx - 1); // LATER
// if (markfloor)
// floorplane = R_CheckPlane(floorplane, rw_x, rw_stopx - 1); // LATER
if (markfloor)
floorplane = R_CheckPlane(floorplane, rw_x, rw_stopx - 1); // LATER
R_RenderSegLoop();
+1 -1
View File
@@ -743,12 +743,12 @@ void R_RenderPlayerView(player_t *player) {
// The head node is the last node output.
R_RenderBSPNode(numnodes - 1);
IPU_R_RenderPlayerView();
// Check for new console commands.
NetUpdate();
R_DrawPlanes();
IPU_R_RenderPlayerView();
// Check for new console commands.
NetUpdate();