diff --git a/mars.h b/mars.h index d64aa5f8d..8c7c3b77d 100644 --- a/mars.h +++ b/mars.h @@ -63,7 +63,7 @@ void Mars_Sec_R_WallPrep(void) ATTR_DATA_CACHE_ALIGN; void Mars_Sec_R_SegCommands(void) ATTR_DATA_CACHE_ALIGN; void Mars_Sec_R_DrawPlanes(void) ATTR_DATA_CACHE_ALIGN; void Mars_Sec_R_PreDrawPlanes(void) ATTR_DATA_CACHE_ALIGN; -void Mars_Sec_R_DrawSprites(int sprscreenhalf, int *sortedsprites) ATTR_DATA_CACHE_ALIGN; +void Mars_Sec_R_DrawSprites(int sprscreenhalf) ATTR_DATA_CACHE_ALIGN; void Mars_Sec_R_DrawPSprites(int sprscreenhalf) ATTR_DATA_CACHE_ALIGN; void Mars_Sec_P_CheckSights(void) ATTR_DATA_CACHE_ALIGN; void Mars_Sec_wipe_doMelt(void); @@ -125,11 +125,10 @@ static inline void Mars_R_EndDrawPlanes(void) } // r_phase8 -static inline void Mars_R_BeginDrawSprites(int sprscreenhalf, int *sortedsprites) +static inline void Mars_R_BeginDrawSprites(int sprscreenhalf) { Mars_R_SecWait(); MARS_SYS_COMM6 = sprscreenhalf; - *(volatile uintptr_t *)&MARS_SYS_COMM8 = (uintptr_t)sortedsprites; MARS_SYS_COMM4 = MARS_SECCMD_R_DRAW_SPRITES; } diff --git a/marshw.c b/marshw.c index 689d31b26..e385add54 100644 --- a/marshw.c +++ b/marshw.c @@ -115,23 +115,28 @@ char Mars_UploadPalette(const uint8_t* palette) { int i; unsigned short* cram = (unsigned short *)&MARS_CRAM; - int16_t br = mars_brightness; + int br = mars_brightness; if ((MARS_SYS_INTMSK & MARS_SH2_ACCESS_VDP) == 0) return 0; for (i = 0; i < 256; i++) { - int16_t r = br + *palette++; - int16_t g = br + *palette++; - int16_t b = br + *palette++; + int r = br + *palette++; + int g = br + *palette++; + int b = br + *palette++; if (r < 0) r = 0; else if (r > 255) r = 255; if (g < 0) g = 0; else if (g > 255) g = 255; if (b < 0) b = 0; else if (b > 255) b = 255; - unsigned short b1 = ((b >> 3) & 0x1f) << 10; - unsigned short g1 = ((g >> 3) & 0x1f) << 5; - unsigned short r1 = ((r >> 3) & 0x1f) << 0; + unsigned b1 = b; + unsigned g1 = g; + unsigned r1 = r; + + b1 = ((b1 >> 3) & 0x1f) << 10; + g1 = ((g1 >> 3) & 0x1f) << 5; + r1 = ((r1 >> 3) & 0x1f) << 0; + cram[i] = r1 | g1 | b1; } diff --git a/marsnew.c b/marsnew.c index 8c930a1af..cca75f9b7 100644 --- a/marsnew.c +++ b/marsnew.c @@ -331,7 +331,7 @@ void Mars_Secondary(void) Mars_Sec_R_DrawPlanes(); break; case MARS_SECCMD_R_DRAW_SPRITES: - Mars_Sec_R_DrawSprites(MARS_SYS_COMM6, (int*)(*(volatile uintptr_t *)&MARS_SYS_COMM8)); + Mars_Sec_R_DrawSprites(MARS_SYS_COMM6); break; case MARS_SECCMD_M_ANIMATE_FIRE: Mars_Sec_M_AnimateFire(); @@ -516,7 +516,7 @@ void* I_RemapLumpPtr(void *ptr) ==================== */ -static char zone[0x32000] __attribute__((aligned(16))); +static char zone[0x33000] __attribute__((aligned(16))); byte *I_ZoneBase (int *size) { *size = sizeof(zone); diff --git a/marssound.c b/marssound.c index 1cad89d65..ae574ddbc 100644 --- a/marssound.c +++ b/marssound.c @@ -90,7 +90,7 @@ int S_PaintChannel4IMA(void* mixer, int16_t* buffer, int32_t cnt, int32_t scale) int S_PaintChannel4IMA2x(void* mixer, int16_t* buffer, int32_t cnt, int32_t scale) ATTR_DATA_CACHE_ALIGN; void S_PaintChannel8(void* mixer, int16_t* buffer, int32_t cnt, int32_t scale) ATTR_DATA_CACHE_ALIGN; static int S_PaintChannel(sfxchannel_t *ch, int16_t* buffer, int painted) ATTR_DATA_CACHE_ALIGN; -static void S_StartSoundEx(mobj_t *mobj, int sound_id, getsoundpos_t getpos) ATTR_DATA_CACHE_ALIGN; +static void S_StartSoundEx(mobj_t *mobj, int sound_id, getsoundpos_t getpos); static void S_SpatializeAt(fixed_t*origin, mobj_t* listener, int* pvol, int* psep) ATTR_DATA_CACHE_ALIGN; static void S_Spatialize(mobj_t* mobj, int* pvol, int* psep, getsoundpos_t getpos) ATTR_DATA_CACHE_ALIGN; static void S_SpatializeAll(void) ATTR_DATA_CACHE_ALIGN; diff --git a/p_ceilng.c b/p_ceilng.c index f676bc4c5..a2b96a8a1 100644 --- a/p_ceilng.c +++ b/p_ceilng.c @@ -9,7 +9,7 @@ /*================================================================== */ /*================================================================== */ -ceiling_t *activeceilings[MAXCEILINGS]; +ceiling_t **activeceilings/*[MAXCEILINGS]*/ = NULL; /*================================================================== */ /* */ diff --git a/p_map.c b/p_map.c index 81ba89160..36966379e 100644 --- a/p_map.c +++ b/p_map.c @@ -21,7 +21,7 @@ typedef struct static fixed_t P_InterceptVector(divline_t* v2, divline_t* v1) ATTR_DATA_CACHE_ALIGN; boolean PIT_UseLines(line_t* li, plineuse_t *lu) ATTR_DATA_CACHE_ALIGN; -void P_UseLines(player_t* player) ATTR_DATA_CACHE_ALIGN __attribute__((noinline)); +void P_UseLines(player_t* player) __attribute__((noinline)); boolean PIT_RadiusAttack(mobj_t* thing, pradiusattack_t *ra) ATTR_DATA_CACHE_ALIGN; void P_RadiusAttack(mobj_t* spot, mobj_t* source, int damage) ATTR_DATA_CACHE_ALIGN; fixed_t P_AimLineAttack(lineattack_t *la, mobj_t* t1, angle_t angle, fixed_t distance) ATTR_DATA_CACHE_ALIGN; diff --git a/p_plats.c b/p_plats.c index bbc483407..f9ec84a7e 100644 --- a/p_plats.c +++ b/p_plats.c @@ -8,7 +8,7 @@ #include "doomdef.h" #include "p_local.h" -plat_t *activeplats[MAXPLATS]; +plat_t **activeplats/*[MAXPLATS]*/ = NULL; /*================================================================== */ /* */ diff --git a/p_setup.c b/p_setup.c index 9a3409ea7..19d0a68b1 100644 --- a/p_setup.c +++ b/p_setup.c @@ -752,8 +752,15 @@ extern byte *debugscreen; void P_Init (void) { - P_InitSwitchList (); + anims = Z_Malloc(sizeof(*anims) * MAXANIMS, PU_STATIC, 0); + switchlist = Z_Malloc(sizeof(*switchlist)* MAXSWITCHES * 2, PU_STATIC, 0); + buttonlist = Z_Malloc(sizeof(*buttonlist) * MAXBUTTONS, PU_STATIC, 0); + linespeciallist = Z_Malloc(sizeof(*linespeciallist) * MAXLINEANIMS, PU_STATIC, 0); + + activeplats = Z_Malloc(sizeof(*activeplats) * MAXPLATS, PU_STATIC, 0); + activeceilings = Z_Malloc(sizeof(*activeceilings) * MAXCEILINGS, PU_STATIC, 0); + P_InitSwitchList (); P_InitPicAnims (); #ifndef MARS pausepic = W_CacheLumpName ("PAUSED",PU_STATIC); diff --git a/p_spec.c b/p_spec.c index b990b8fcc..b23aeb569 100644 --- a/p_spec.c +++ b/p_spec.c @@ -47,7 +47,7 @@ static const animdef_t animdefs[] = {-1} }; -anim_t anims[MAXANIMS], *lastanim; +anim_t *anims/*[MAXANIMS]*/, * lastanim; void P_InitPicAnims (void) @@ -955,7 +955,7 @@ int EV_DoDonut(line_t *line) */ int numlinespecials = 0; -line_t *linespeciallist[MAXLINEANIMS]; +line_t **linespeciallist = NULL; void P_SpawnSpecials (void) { diff --git a/p_spec.h b/p_spec.h index 0acecbe33..ef7afb22c 100644 --- a/p_spec.h +++ b/p_spec.h @@ -32,7 +32,7 @@ typedef struct #define MAXANIMS 32 -extern anim_t anims[MAXANIMS], *lastanim; +extern anim_t *anims/*[MAXANIMS]*/, * lastanim; /* */ @@ -40,7 +40,7 @@ extern anim_t anims[MAXANIMS], *lastanim; /* */ #define MAXLINEANIMS 64 extern int numlinespecials; -extern line_t *linespeciallist[MAXLINEANIMS]; +extern line_t **linespeciallist/*[MAXLINEANIMS]*/; /* Define values for map objects */ @@ -176,8 +176,8 @@ typedef struct #define MAXBUTTONS 16 /* 4 players, 4 buttons each at once, max. */ #define BUTTONTIME 15 /* 1 second */ -extern VINT switchlist[MAXSWITCHES * 2]; -extern button_t buttonlist[MAXBUTTONS]; +extern VINT *switchlist/*[MAXSWITCHES * 2]*/; +extern button_t* buttonlist/*[MAXBUTTONS]*/; void P_ChangeSwitchTexture(line_t *line,int useAgain); void P_InitSwitchList(void); @@ -226,7 +226,7 @@ typedef struct #define PLATSPEED (FRACUNIT*THINKERS_TICS) #define MAXPLATS 30 -extern plat_t *activeplats[MAXPLATS]; +extern plat_t **activeplats/*[MAXPLATS]*/; void T_PlatRaise(plat_t *plat); int EV_DoPlat(line_t *line,plattype_e type,int amount); @@ -310,7 +310,7 @@ typedef struct #define CEILSPEED FRACUNIT*THINKERS_TICS #define MAXCEILINGS 30 -extern ceiling_t *activeceilings[MAXCEILINGS]; +extern ceiling_t **activeceilings/*[MAXCEILINGS]*/; int EV_DoCeiling (line_t *line, ceiling_e type); void T_MoveCeiling (ceiling_t *ceiling); diff --git a/p_switch.c b/p_switch.c index 54d097a11..34b3b7771 100644 --- a/p_switch.c +++ b/p_switch.c @@ -16,9 +16,9 @@ static const switchlist_t alphSwitchList[] = {"SW1WOOD", "SW2WOOD"}, }; -VINT switchlist[MAXSWITCHES * 2]; +VINT *switchlist/*[MAXSWITCHES * 2]*/ = NULL; int numswitches; -button_t buttonlist[MAXBUTTONS]; +button_t *buttonlist/*[MAXBUTTONS]*/ = NULL; /* =============== diff --git a/r_data.c b/r_data.c index 7d9fb6d71..57277d7c7 100644 --- a/r_data.c +++ b/r_data.c @@ -392,6 +392,7 @@ void R_InitMathTables(void) viewangletox = (VINT *)I_AllocWorkBuffer(sizeof(*viewangletox) * (FINEANGLES / 2)); distscale = (fixed_t *)I_AllocWorkBuffer(sizeof(*distscale) * SCREENWIDTH); yslope = (fixed_t *)I_AllocWorkBuffer(sizeof(*yslope) * SCREENHEIGHT); + xtoviewangle = (uint16_t *)I_AllocWorkBuffer(sizeof(*xtoviewangle) * (SCREENWIDTH+1)); tempviewangletox = (VINT *)I_WorkBuffer(); // Use tangent table to generate viewangletox: @@ -470,6 +471,12 @@ void R_InitMathTables(void) { fuzzoffset[i] = fuzzoffset[i] < 0 ? -fuzzunit : fuzzunit; } + + // enable caching for LUTs + viewangletox = (void *)(((intptr_t)viewangletox) & ~0x20000000); + distscale = (void *)(((intptr_t)distscale) & ~0x20000000); + yslope = (void *)(((intptr_t)yslope) & ~0x20000000); + xtoviewangle = (void *)(((intptr_t)xtoviewangle) & ~0x20000000); } diff --git a/r_local.h b/r_local.h index 0c02c5846..1c25ea1a0 100644 --- a/r_local.h +++ b/r_local.h @@ -335,7 +335,7 @@ extern VINT *viewangletox/*[FINEANGLES/2]*/; /* The xtoviewangleangle[] table maps a screen pixel to the lowest viewangle */ /* that maps back to x ranges from clipangle to -clipangle */ -extern uint16_t xtoviewangle[SCREENWIDTH+1]; +extern uint16_t *xtoviewangle/*[SCREENWIDTH+1]*/; #ifdef MARS extern const fixed_t finetangent_[FINEANGLES/4]; @@ -458,7 +458,7 @@ typedef struct int b_bottomheight; int b_texturemid; - /* !!! THE FOLLOWING SECTION MUST BE LARGE ENOUGH */ + /* !!! THE SECTION ABOVE MUST BE LARGE ENOUGH */ /* !!! TO ACCOMODATE VISSPRITE_T STRUCTURE, GETS */ /* !!! OVERWRITTEN AFTER PHASE 7 - END */ @@ -497,7 +497,7 @@ typedef struct mapvertex_t v2; }; - byte *sil; + uint16_t *clipbounds; } viswall_t; typedef struct @@ -526,7 +526,7 @@ typedef struct vissprite_s #define MAXVISSPRITES MAXWALLCMDS -#define MAXOPENINGS SCREENWIDTH*14 +#define MAXOPENINGS SCREENWIDTH*16 #define MAXVISSSEC 128 @@ -600,9 +600,9 @@ __attribute__((aligned(16))) /* */ /* openings / misc refresh memory */ /* */ - unsigned short * volatile openings/*[MAXOPENINGS]*/; - unsigned short * volatile lastopening; unsigned short * volatile segclip, * volatile lastsegclip; + + int * volatile gsortedsprites; } viewdef_t; extern viewdef_t vd; diff --git a/r_main.c b/r_main.c index 2d2afd26a..e50174a13 100644 --- a/r_main.c +++ b/r_main.c @@ -77,7 +77,7 @@ fixed_t *distscale/*[SCREENWIDTH]*/; VINT *viewangletox/*[FINEANGLES/2]*/; -uint16_t xtoviewangle[SCREENWIDTH+1]; +uint16_t *xtoviewangle/*[SCREENWIDTH+1]*/; /* */ /* performance counters */ @@ -660,8 +660,8 @@ static void R_Setup (int displayplayer, visplane_t *visplanes_, vd.viswallextras = viswallex_ + 1; - vd.openings = tempbuf; - tempbuf += MAXOPENINGS; + // re-use the openings array in VRAM + vd.gsortedsprites = (void *)(((intptr_t)vd.visplanes[1].open + 3) & ~3); vd.vissprites = (void *)vd.viswalls; @@ -681,8 +681,6 @@ static void R_Setup (int displayplayer, visplane_t *visplanes_, vd.vissprite_p = vd.vissprites; vd.lastsprite_p = vd.vissprite_p; - vd.lastopening = vd.openings; - vd.vissectors = vissectors_; vd.lastvissector = vd.vissectors; /* no subsectors visible yet */ @@ -918,12 +916,9 @@ void R_RenderPlayerView(int displayplayer) t_segs = I_GetFRTCounter() - t_segs; Mars_ClearCacheLine(&vd.lastsegclip); - Mars_ClearCacheLine(&vd.lastopening); if (vd.lastsegclip - vd.segclip > MAXOPENINGS) I_Error("lastsegclip > MAXOPENINGS: %d", vd.lastsegclip - vd.segclip); - if (vd.lastopening - vd.openings > MAXOPENINGS) - I_Error("lastopening > MAXOPENINGS: %d", vd.lastopening - vd.openings); if (vd.lastvissector - vd.vissectors > MAXVISSSEC) I_Error("lastvissector > MAXVISSSEC: %d", vd.lastvissector - vd.vissectors); diff --git a/r_phase2.c b/r_phase2.c index 9d55a83a8..161f02392 100644 --- a/r_phase2.c +++ b/r_phase2.c @@ -143,16 +143,16 @@ void R_WallLatePrep(viswall_t* wc, vertex_t *verts) } #endif - int rw_x = wc->start; - int rw_stopx = wc->stop + 1; - int width = (rw_stopx - rw_x + 1) / 2; + wc->clipbounds = NULL; - wc->sil = (byte*)vd.lastopening - rw_x; - - if (wc->actionbits & AC_TOPSIL) - vd.lastopening += width; - if (wc->actionbits & AC_BOTTOMSIL) - vd.lastopening += width; + const int start = wc->start; + const int stop = wc->stop; + const int width = stop - start + 1; + if (wc->actionbits & (AC_NEWFLOOR | AC_NEWCEILING | AC_TOPSIL | AC_BOTTOMSIL)) + { + wc->clipbounds = vd.lastsegclip - start; + vd.lastsegclip += width; + } } // @@ -168,35 +168,16 @@ static void R_SegLoop(viswall_t* segl, unsigned short* clipbounds, int x, start = segl->start; const int stop = segl->stop; - const int width = stop - start + 1; const fixed_t ceilingheight = segl->ceilingheight; const int floorandlight = (segl->seglightlevel << 16) | segl->floorpicnum; const int ceilandlight = (segl->seglightlevel << 16) | segl->ceilingpicnum; - byte *topsil, *bottomsil; - - if (actionbits & AC_TOPSIL) - { - topsil = segl->sil; - bottomsil = (actionbits & AC_BOTTOMSIL) ? segl->sil + width : NULL; - } - else - { - topsil = NULL; - bottomsil = (actionbits & AC_BOTTOMSIL) ? segl->sil : NULL; - } - unsigned short *flooropen = (actionbits & AC_ADDFLOOR) ? vd.visplanes[0].open : NULL; unsigned short *ceilopen = (actionbits & AC_ADDCEILING) ? vd.visplanes[0].open : NULL; - unsigned short *newclipbounds = NULL; - if (actionbits & (AC_NEWFLOOR | AC_NEWCEILING)) - { - newclipbounds = vd.lastsegclip - start; - vd.lastsegclip += width; - } + unsigned short *newclipbounds = segl->clipbounds; const int cyvh = (centerY << 16) | viewportHeight; @@ -237,26 +218,20 @@ static void R_SegLoop(viswall_t* segl, unsigned short* clipbounds, else if (high < ceilingclipx) high = ceilingclipx; - // bottom sprite clip sil - if (bottomsil) - bottomsil[x] = low+1; - - // top sprite clip sil - if (topsil) - topsil[x] = high+1; + if (newclipbounds) + { + newclipbounds[x] = (high << 8) | low; + } int newclip = actionbits & (AC_NEWFLOOR|AC_NEWCEILING); - if (newclipbounds) + if (newclip) { if (!(newclip & AC_NEWFLOOR)) low = floorclipx; if (!(newclip & AC_NEWCEILING)) high = ceilingclipx; - newclip = (high << 8) | low; - // rewrite clipbounds - clipbounds[x] = newclip; - newclipbounds[x] = newclip; + clipbounds[x] = (high << 8) | low; } // diff --git a/r_phase6.c b/r_phase6.c index f21612b73..13e4a549e 100644 --- a/r_phase6.c +++ b/r_phase6.c @@ -272,7 +272,6 @@ void R_SegCommands(void) int extralight; uint32_t clipbounds_[SCREENWIDTH / 2 + 1]; uint16_t *clipbounds = (uint16_t *)clipbounds_; - uint16_t *newclipbounds = vd.segclip; // initialize the clipbounds array R_InitClipBounds(clipbounds_); @@ -442,12 +441,24 @@ void R_SegCommands(void) if(actionbits & (AC_NEWFLOOR|AC_NEWCEILING)) { unsigned w = segl->stop - segl->start + 1; - unsigned short *src = newclipbounds - 1, *dst = clipbounds + segl->start; + unsigned short *src = segl->clipbounds + segl->start, *dst = clipbounds + segl->start; - newclipbounds += w; - do { - *dst++ = *++src; - } while (--w > 0); + if ((actionbits & (AC_NEWFLOOR|AC_NEWCEILING)) == (AC_NEWFLOOR|AC_NEWCEILING)) { + --src; + do { + *dst++ = *++src; + } while (--w > 0); + } + else { + int8_t *psrc = (int8_t *)src; + int8_t *pdst = (int8_t *)dst; + if (actionbits & AC_NEWFLOOR) { + psrc++, pdst++; + } + do { + *pdst = *psrc, psrc += 2, pdst += 2; + } while (--w > 0); + } } } } diff --git a/r_phase8.c b/r_phase8.c index d9768a676..e3b19c40a 100644 --- a/r_phase8.c +++ b/r_phase8.c @@ -15,7 +15,7 @@ static int fuzzpos[2]; static boolean R_SegBehindPoint(viswall_t *viswall, int dx, int dy) ATTR_DATA_CACHE_ALIGN; void R_DrawVisSprite(vissprite_t* vis, unsigned short* spropening, int *fuzzpos, int sprscreenhalf) ATTR_DATA_CACHE_ALIGN; void R_ClipVisSprite(vissprite_t *vis, unsigned short *spropening, int sprscreenhalf, int16_t *walls) ATTR_DATA_CACHE_ALIGN; -static void R_DrawSortedSprites(int *fuzzpos, int* sortedsprites, int sprscreenhalf) ATTR_DATA_CACHE_ALIGN; +static void R_DrawSortedSprites(int* sortedsprites, int *fuzzpos, int sprscreenhalf) ATTR_DATA_CACHE_ALIGN; static void R_DrawPSprites(int *fuzzpos, int sprscreenhalf) ATTR_DATA_CACHE_ALIGN; void R_Sprites(void) ATTR_DATA_CACHE_ALIGN __attribute__((noinline)); @@ -72,8 +72,8 @@ void R_DrawVisSprite(vissprite_t *vis, unsigned short *spropening, int *fuzzpos, for(; x < stopx; x++, xfrac += fracstep) { column_t *column = (column_t *)((byte *)patch + BIGSHORT(patch->columnofs[xfrac>>FRACBITS])); - int topclip = (spropening[x] >> 8) - 1; - int bottomclip = (spropening[x] & 0xff) - 1 - 1; + int topclip = (spropening[x] >> 8); + int bottomclip = (spropening[x] & 0xff) - 1; // column loop // a post record has four bytes: topdelta length pixelofs*2 @@ -150,14 +150,12 @@ void R_ClipVisSprite(vissprite_t *vis, unsigned short *spropening, int sprscreen int r1; // FP+7 int r2; // r18 unsigned silhouette; // FP+4 - byte *topsil; // FP+6 - byte *bottomsil; // r21 - unsigned opening; // r16 - unsigned short top; // r19 - unsigned short bottom; // r20 - unsigned short openmark; + uint16_t *sil; // FP+6 + uint16_t *opening; + int top; // r19 + int bottom; // r20 + unsigned short openmark = OPENMARK; viswall_t *ds; // r17 - unsigned short vhplus1 = viewportHeight + 1; x1 = vis->x1; x2 = vis->x2; @@ -181,12 +179,10 @@ void R_ClipVisSprite(vissprite_t *vis, unsigned short *spropening, int sprscreen #endif for(x = x1; x <= x2; x++) - spropening[x] = vhplus1 | (1<<8); - + spropening[x] = viewportHeight; + do { - int width; - ds = vd.viswalls + *walls++; silhouette = (ds->actionbits & (AC_TOPSIL | AC_BOTTOMSIL | AC_SOLIDSIL)); @@ -203,60 +199,66 @@ void R_ClipVisSprite(vissprite_t *vis, unsigned short *spropening, int sprscreen r1 = ds->start < x1 ? x1 : ds->start; r2 = ds->stop > x2 ? x2 : ds->stop; - width = ds->stop - ds->start + 1; - - silhouette /= AC_TOPSIL; - if(silhouette == 4) - { -#ifdef MARS - // force GCC into keeping constants in registers as it - // is stupid enough to reload them on each loop iteration - __asm volatile("mov %1,%0\n\t" : "=&r" (openmark) : "r"(OPENMARK)); -#endif - for (x = r1; x <= r2; x++) - spropening[x] = openmark; + if (r1 > r2) continue; - } - topsil = ds->sil; - bottomsil = ds->sil + (silhouette & 1 ? width : 0); + sil = ds->clipbounds + r1; + opening = spropening + r1; + x = r2 - r1 + 1; + silhouette /= AC_TOPSIL; if(silhouette == 1) { - for(x = r1; x <= r2; x++) + int8_t *popn = (int8_t *)opening; + int8_t *psil = (int8_t *)sil; + do { - opening = spropening[x]; - if((opening>>8) == 1) - spropening[x] = (topsil[x] << 8) | (opening & 0xff); - } + if(*popn == 0) + *popn = *psil; + popn += 2, psil += 2; + } while (--x); } else if(silhouette == 2) { - for(x = r1; x <= r2; x++) + int8_t *popn = (int8_t *)opening; + int8_t *psil = (int8_t *)sil; + int vph = (int8_t)viewportHeight; + popn++, psil++; + do { - opening = spropening[x]; - if((opening & 0xff) == vhplus1) - spropening[x] = (((volatile uint16_t)opening >> 8) << 8) | bottomsil[x]; - } + if(*popn == vph) + *popn = *psil; + popn += 2, psil += 2; + } while (--x); } - else + else if (silhouette == 3) { - for(x = r1; x <= r2; x++) + do { - top = spropening[x]; + uint16_t clip = *sil; + top = *opening; bottom = top & 0xff; - top >>= 8; - if(bottom == vhplus1) - bottom = bottomsil[x]; - if(top == 1) - top = topsil[x]; - spropening[x] = (top << 8) | bottom; - } + top = top & openmark; + if(bottom == viewportHeight) + bottom = clip & 0xff; + if(top == 0) + top = clip & openmark; + *opening = top | bottom; + opening++, sil++; + } while (--x); + } + else + { + opening += x; + do { + --opening; + *opening = openmark; + } while (--x); } } while (*walls != -1); } -static void R_DrawSortedSprites(int *fuzzpos, int* sortedsprites, int sprscreenhalf) +static void R_DrawSortedSprites(int* sortedsprites, int *fuzzpos, int sprscreenhalf) { int i; int x1, x2; @@ -317,7 +319,7 @@ static void R_DrawPSprites(int *fuzzpos, int sprscreenhalf) unsigned i; unsigned short spropening[SCREENWIDTH]; viswall_t *spr; - unsigned vhplus1 = viewportHeight + 1; + unsigned vph = viewportHeight; // draw psprites for (spr = vd.lastsprite_p; spr < vd.vissprite_p; spr++) @@ -332,7 +334,7 @@ static void R_DrawPSprites(int *fuzzpos, int sprscreenhalf) // clear out the clipping array across the range of the psprite while (i < stopx) { - spropening[i] = vhplus1 | (1<<8); + spropening[i] = vph; ++i; } @@ -341,16 +343,17 @@ static void R_DrawPSprites(int *fuzzpos, int sprscreenhalf) } #ifdef MARS -void Mars_Sec_R_DrawSprites(int sprscreenhalf, int *sortedsprites) +void Mars_Sec_R_DrawSprites(int sprscreenhalf) { Mars_ClearCacheLine(&vd.vissprites); Mars_ClearCacheLine(&vd.lastsprite_p); Mars_ClearCacheLine(&vd.vissprite_p); + Mars_ClearCacheLine(&vd.gsortedsprites); // mobj sprites - //Mars_ClearCacheLines(sortedsprites, ((lastsprite_p - vissprites + 1) * sizeof(*sortedsprites) + 31) / 16); + //Mars_ClearCacheLines(vd.gsortedsprites, ((lastsprite_p - vissprites + 1) * sizeof(*vd.gsortedsprites) + 31) / 16); - R_DrawSortedSprites(&fuzzpos[1], sortedsprites, -sprscreenhalf); + R_DrawSortedSprites(vd.gsortedsprites, &fuzzpos[1], -sprscreenhalf); R_DrawPSprites(&fuzzpos[1], -sprscreenhalf); } @@ -367,7 +370,6 @@ void R_Sprites(void) unsigned midcount; viswall_t *spr; int *sortedsprites = (void *)vd.vissectors; - int *gsortedsprites; viswall_t *wc; vertex_t *verts; @@ -447,20 +449,18 @@ void R_Sprites(void) } #ifdef MARS - // re-use the openings array in VRAM - gsortedsprites = (int*)(((intptr_t)vd.segclip + 3) & ~3); + Mars_R_SecWait(); for (i = 0; i < sortedcount+1; i++) - gsortedsprites[i] = sortedsprites[i]; + vd.gsortedsprites[i] = sortedsprites[i]; #endif #ifdef MARS - Mars_R_BeginDrawSprites(half, gsortedsprites); - //Mars_ClearCacheLines(openings, ((lastopening - openings) * sizeof(*openings) + 31) / 16); + Mars_R_BeginDrawSprites(half); #endif - R_DrawSortedSprites(&fuzzpos[0], sortedsprites, half); + R_DrawSortedSprites(sortedsprites, &fuzzpos[0], half); - R_DrawPSprites(0, half); + R_DrawPSprites(&fuzzpos[0], half); #ifdef MARS Mars_R_EndDrawSprites(); diff --git a/st_main.c b/st_main.c index ec769970a..502154a10 100644 --- a/st_main.c +++ b/st_main.c @@ -3,7 +3,7 @@ #include "doomdef.h" #include "st_main.h" -stbar_t stbar[MAXPLAYERS]; +stbar_t *stbar; int stbar_tics; static short stbarframe; @@ -46,6 +46,8 @@ void ST_Init (void) { int i, l; + stbar = Z_Malloc(sizeof(*stbar)*MAXPLAYERS, PU_STATIC, NULL); + l = W_CheckNumForName("STBAR"); if (l != -1) { diff --git a/st_main.h b/st_main.h index b6b8ff888..1ae8bd137 100644 --- a/st_main.h +++ b/st_main.h @@ -155,7 +155,7 @@ typedef struct char forcedraw; } stbar_t; -extern stbar_t stbar[MAXPLAYERS]; +extern stbar_t *stbar; extern int stbar_tics; extern void valtostr(char *string,int val); void ST_DrawValue(int x,int y,int value);