Skip to content

Commit

Permalink
Remove endian swap macros
Browse files Browse the repository at this point in the history
  • Loading branch information
JonnyPtn committed Oct 19, 2024
1 parent 981af9f commit 2feb0e4
Show file tree
Hide file tree
Showing 13 changed files with 141 additions and 249 deletions.
40 changes: 0 additions & 40 deletions linuxdoom-1.10/m_swap.c

This file was deleted.

34 changes: 0 additions & 34 deletions linuxdoom-1.10/m_swap.h

This file was deleted.

40 changes: 17 additions & 23 deletions linuxdoom-1.10/r_data.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,8 @@
//
//-----------------------------------------------------------------------------



#include "m_swap.h"

#include "p_local.h"



#ifdef LINUX
#include <alloca.h>
#endif
Expand Down Expand Up @@ -214,7 +208,7 @@ void R_GenerateComposite(int texnum) {
for (const auto &patch : texture.patches) {
realpatch = static_cast<patch_t *>(W_CacheLumpNum(patch.patch));
x1 = patch.originx;
x2 = x1 + SHORT(realpatch->width);
x2 = x1 + realpatch->width;

if (x1 < 0)
x = 0;
Expand All @@ -230,7 +224,7 @@ void R_GenerateComposite(int texnum) {
continue;

patchcol =
(column_t *)((std::byte *)realpatch + LONG(realpatch->columnofs[x - x1]));
(column_t *)((std::byte *)realpatch + realpatch->columnofs[x - x1]);
R_DrawColumnInCache(patchcol, block + colofs[x], patch.originy,
texture.height);
}
Expand Down Expand Up @@ -266,7 +260,7 @@ void R_GenerateLookup(int texnum) {
for (const auto &patch : texture.patches) {
realpatch = static_cast<patch_t *>(W_CacheLumpNum(patch.patch));
x1 = patch.originx;
x2 = x1 + SHORT(realpatch->width);
x2 = x1 + realpatch->width;

if (x1 < 0)
x = 0;
Expand All @@ -278,7 +272,7 @@ void R_GenerateLookup(int texnum) {
for (; x < x2; x++) {
patchcount[x] = static_cast<std::byte>(static_cast<int>(patchcount[x]) + 1);
collump[x] = patch.patch;
colofs[x] = LONG(realpatch->columnofs[x - x1]) + 3;
colofs[x] = realpatch->columnofs[x - x1] + 3;
}
}

Expand Down Expand Up @@ -359,7 +353,7 @@ void R_InitTextures(void) {

// Load the patch names from pnames.lmp.
names = static_cast<char *>(W_CacheLumpName("PNAMES"));
nummappatches = LONG(*((int *)names));
nummappatches = *((int *)names);
name_p = names + 4;
std::vector<int> patchlookup(nummappatches);

Expand All @@ -377,13 +371,13 @@ void R_InitTextures(void) {
// The data is contained in one or two lumps,
// TEXTURE1 for shareware, plus TEXTURE2 for commercial.
maptex = maptex1 = static_cast<int *>(W_CacheLumpName("TEXTURE1"));
numtextures1 = LONG(*maptex);
numtextures1 = *maptex;
maxoff = W_LumpLength(W_GetNumForName({"TEXTURE1"}));
directory = maptex + 1;

if (W_CheckNumForName("TEXTURE2") != -1) {
maptex2 = static_cast<int *>(W_CacheLumpName("TEXTURE2"));
numtextures2 = LONG(*maptex2);
numtextures2 = *maptex2;
maxoff2 = W_LumpLength(W_GetNumForName("TEXTURE2"));
} else {
maptex2 = NULL;
Expand Down Expand Up @@ -423,7 +417,7 @@ void R_InitTextures(void) {
directory = maptex + 1;
}

offset = LONG(*directory);
offset = *directory;

if (offset > maxoff)
I_Error("R_InitTextures: bad texture directory");
Expand All @@ -432,18 +426,18 @@ void R_InitTextures(void) {

auto &texture = textures[i];

texture.width = SHORT(mtexture->width);
texture.height = SHORT(mtexture->height);
texture.patches.resize(SHORT(mtexture->patchcount));
texture.width = mtexture->width;
texture.height = mtexture->height;
texture.patches.resize(mtexture->patchcount);

texture.name = mtexture->name;
mpatch = &mtexture->patches[0];
patch = &texture.patches[0];

for (j = 0; j < texture.patches.size(); j++, mpatch++, patch++) {
patch->originx = SHORT(mpatch->originx);
patch->originy = SHORT(mpatch->originy);
patch->patch = patchlookup[SHORT(mpatch->patch)];
patch->originx = mpatch->originx;
patch->originy = mpatch->originy;
patch->patch = patchlookup[mpatch->patch];
if (patch->patch == -1) {
I_Error("R_InitTextures: Missing patch in texture %s",
texture.name.c_str());
Expand Down Expand Up @@ -517,9 +511,9 @@ void R_InitSpriteLumps(void) {

patch =
static_cast<patch_t *>(W_CacheLumpNum(firstspritelump + i));
spritewidth[i] = SHORT(patch->width) << FRACBITS;
spriteoffset[i] = SHORT(patch->leftoffset) << FRACBITS;
spritetopoffset[i] = SHORT(patch->topoffset) << FRACBITS;
spritewidth[i] = patch->width << FRACBITS;
spriteoffset[i] = patch->leftoffset << FRACBITS;
spritetopoffset[i] = patch->topoffset << FRACBITS;
}
}

Expand Down
9 changes: 2 additions & 7 deletions linuxdoom-1.10/r_things.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,6 @@
#include <stdio.h>
#include <stdlib.h>

#include "m_swap.h"




#include "g_game.h"
#include "r_defs.h"
#include "r_state.h"
Expand Down Expand Up @@ -327,11 +322,11 @@ void R_DrawVisSprite(vissprite_t *vis, int x1, int x2) {
for (dc_x = vis->x1; dc_x <= vis->x2; dc_x++, frac += vis->xiscale) {
texturecolumn = frac >> FRACBITS;
#ifdef RANGECHECK
if (texturecolumn < 0 || texturecolumn >= SHORT(patch->width))
if (texturecolumn < 0 || texturecolumn >= patch->width)
I_Error("R_DrawSpriteRange: bad texturecolumn");
#endif
column =
(column_t *)((std::byte *)patch + LONG(patch->columnofs[texturecolumn]));
(column_t *)((std::byte *)patch + patch->columnofs[texturecolumn]);
R_DrawMaskedColumn(column);
}

Expand Down
4 changes: 2 additions & 2 deletions src/am_map.ixx
Original file line number Diff line number Diff line change
Expand Up @@ -1135,8 +1135,8 @@ void AM_drawMarks(void) {

for (i = 0; i < AM_NUMMARKPOINTS; i++) {
if (markpoints[i].x != -1) {
// w = SHORT(marknums[i]->width);
// h = SHORT(marknums[i]->height);
// w = marknums[i]->width;
// h = marknums[i]->height;
w = 5; // because something's wrong with the wad, i guess
h = 6; // because something's wrong with the wad, i guess
fx = CXMTOF(markpoints[i].x);
Expand Down
16 changes: 4 additions & 12 deletions src/finale.ixx
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,6 @@
module;
#include <ctype.h>

// Functions.
#include "m_swap.h"




// Data.

#include "g_game.h"
#include "r_state.h"

Expand Down Expand Up @@ -298,7 +290,7 @@ void F_TextWrite(void) {
continue;
}

w = SHORT(hu_font[c]->width);
w = hu_font[c]->width;
if (cx + w > SCREENWIDTH)
break;
V_DrawPatch(cx, cy, 0, hu_font[c]);
Expand Down Expand Up @@ -535,7 +527,7 @@ void F_CastPrint(const char *text) {
continue;
}

w = SHORT(hu_font[c]->width);
w = hu_font[c]->width;
width += w;
}

Expand All @@ -552,7 +544,7 @@ void F_CastPrint(const char *text) {
continue;
}

w = SHORT(hu_font[c]->width);
w = hu_font[c]->width;
V_DrawPatch(cx, 180, 0, hu_font[c]);
cx += w;
}
Expand Down Expand Up @@ -598,7 +590,7 @@ void F_DrawPatchCol(int x, patch_t *patch, int col) {
std::byte *desttop;
int count;

column = (column_t *)((std::byte *)patch + LONG(patch->columnofs[col]));
column = (column_t *)((std::byte *)patch + patch->columnofs[col]);
desttop = screens[0].data() + x;

// step through the posts in a column
Expand Down
13 changes: 6 additions & 7 deletions src/hud.ixx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
//-----------------------------------------------------------------------------
module;
#include <ctype.h>
#include "m_swap.h"
#include "d_player.h"
#include "g_game.h"
#include "r_defs.h"
Expand Down Expand Up @@ -76,11 +75,11 @@ export constexpr auto HU_FONTSIZE = (HU_FONTEND - HU_FONTSTART + 1);
#define HU_TITLET (mapnamest[gamemap - 1])
#define HU_TITLEHEIGHT 1
#define HU_TITLEX 0
#define HU_TITLEY (167 - SHORT(hu_font[0]->height))
#define HU_TITLEY (167 - hu_font[0]->height)

#define HU_INPUTTOGGLE 't'
#define HU_INPUTX HU_MSGX
#define HU_INPUTY (HU_MSGY + HU_MSGHEIGHT * (SHORT(hu_font[0]->height) + 1))
#define HU_INPUTY (HU_MSGY + HU_MSGHEIGHT * (hu_font[0]->height + 1))
#define HU_INPUTWIDTH 64
#define HU_INPUTHEIGHT 1

Expand Down Expand Up @@ -363,7 +362,7 @@ void HUlib_drawTextLine( hu_textline_t *l, bool drawcursor ) {
c = toupper( l->l[i] );
if ( c != ' ' && c >= l->sc && c <= '_' )
{
w = SHORT( l->f[c - l->sc]->width );
w = l->f[c - l->sc]->width ;
if ( x + w > SCREENWIDTH )
break;
V_DrawPatchDirect( x, l->y, FG, l->f[c - l->sc] );
Expand All @@ -378,7 +377,7 @@ void HUlib_drawTextLine( hu_textline_t *l, bool drawcursor ) {
}

// draw the cursor if requested
if ( drawcursor && x + SHORT( l->f['_' - l->sc]->width ) <= SCREENWIDTH )
if ( drawcursor && x + l->f['_' - l->sc]->width <= SCREENWIDTH )
{
V_DrawPatchDirect( x, l->y, FG, l->f['_' - l->sc] );
}
Expand All @@ -396,7 +395,7 @@ void HUlib_eraseTextLine( hu_textline_t *l ) {

if ( !automapactive && viewwindowx && l->needsupdate )
{
lh = SHORT( l->f[0]->height ) + 1;
lh = l->f[0]->height + 1;
for ( y = l->y, yoffset = y * SCREENWIDTH; y < l->y + lh;
y++, yoffset += SCREENWIDTH )
{
Expand Down Expand Up @@ -424,7 +423,7 @@ void HUlib_initSText( hu_stext_t *s, int x, int y, int h, patch_t **font,
s->laston = true;
s->cl = 0;
for ( i = 0; i < h; i++ )
HUlib_initTextLine( &s->l[i], x, y - i * (SHORT( font[0]->height ) + 1), font,
HUlib_initTextLine( &s->l[i], x, y - i * ( font[0]->height + 1), font,
startchar );
}

Expand Down
Loading

0 comments on commit 2feb0e4

Please sign in to comment.