Skip to content

Commit

Permalink
Low detail mode
Browse files Browse the repository at this point in the history
  • Loading branch information
viciious committed Oct 19, 2024
1 parent 8a66bf2 commit 8982b7a
Show file tree
Hide file tree
Showing 11 changed files with 190 additions and 114 deletions.
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ OBJS = \
d_mapinfo.o \
sh2_fixed.o \
sh2_draw.o \
sh2_drawlow.o \
sh2_mixer.o \
r_cache.o \
m_fire.o \
Expand All @@ -117,7 +118,7 @@ m68k.bin:

$(TARGET).32x: $(TARGET).elf
$(OBJC) -O binary $< temp2.bin
$(DD) if=temp2.bin of=temp.bin bs=198K conv=sync
$(DD) if=temp2.bin of=temp.bin bs=200K conv=sync
rm -f temp3.bin
cat temp.bin $(WAD) >>temp3.bin
$(DD) if=temp3.bin of=$@ bs=512K conv=sync
Expand Down
7 changes: 4 additions & 3 deletions marsdraw.c
Original file line number Diff line number Diff line change
Expand Up @@ -523,7 +523,7 @@ void I_DrawSpanPotatoLow(int ds_y, int ds_x1, int ds_x2, int light, fixed_t ds_x
{
pixel_t* dest, pix;
unsigned count;
short* dc_colormap;
int8_t *dc_colormap;

#ifdef RANGECHECK
if (ds_x2 < ds_x1 || ds_x1<0 || ds_x2 >= viewportWidth || ds_y>viewportHeight)
Expand All @@ -536,8 +536,9 @@ void I_DrawSpanPotatoLow(int ds_y, int ds_x1, int ds_x2, int light, fixed_t ds_x
count = ds_x2 - ds_x1 + 1;

dest = viewportbuffer + ds_y * 320 / 2 + ds_x1;
dc_colormap = (int16_t *)dc_colormaps + light;
pix = dc_colormap[(int8_t)ds_source[513]];
dc_colormap = (int8_t *)dc_colormaps + light;
pix = (uint8_t)dc_colormap[(int8_t)ds_source[513]];
pix = ((uint8_t)pix << 8) | pix;

do {
*dest++ = pix;
Expand Down
10 changes: 6 additions & 4 deletions marsnew.c
Original file line number Diff line number Diff line change
Expand Up @@ -713,13 +713,14 @@ pixel_t* I_OverwriteBuffer(void)
int I_ViewportYPos(void)
{
const int fbh = I_FrameBufferHeight();
int width = viewportWidth * (lowres ? 2 : 1);

if (splitscreen)
return (fbh - viewportHeight) / 2;

if (viewportWidth < 160)
if (width < 160)
return (fbh - jo_stbar_height - viewportHeight) / 2;
if (viewportWidth == 320)
if (width == 320)
return (fbh - jo_stbar_height - viewportHeight);
return (fbh - jo_stbar_height - viewportHeight) / 2;
}
Expand All @@ -728,14 +729,15 @@ pixel_t *I_ViewportBuffer (void)
{
int x = 0;
pixel_t *vb = (pixel_t * )framebuffer;

int width = viewportWidth * (lowres ? 2 : 1);

if (splitscreen)
{
x = vd->displayplayer ? 160 : 0;
}
else
{
x = (320 - viewportWidth) / 2;
x = (320 - width) / 2;
}

vb += I_ViewportYPos() * 320 / 2 + x / 2;
Expand Down
4 changes: 4 additions & 0 deletions marssave.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ typedef struct __attribute((packed))
int8_t yabcdpad;
int8_t sfxdriver;
char spcmDir[9];
int8_t lowres;
} saveopts_t;

static char saveslotguard[SRAM_SLOTSIZE - sizeof(savegame_t)] __attribute__((unused));
Expand Down Expand Up @@ -192,6 +193,7 @@ static void SaveOptions(void)
so.yabcdpad = yabcdpad;
so.magic1 = SRAM_MAGIC1;
so.magic2 = SRAM_MAGIC2;
so.lowres = lowres;
D_snprintf(so.spcmDir, sizeof(so.spcmDir), "%s", spcmDir);

Mars_WriteSRAM((void*)&so, optslotoffset, sizeof(saveopts_t));
Expand Down Expand Up @@ -247,6 +249,7 @@ static void ReadOptions(void)
anamorphicview = so.anamorphic;
sfxdriver = so.sfxdriver;
yabcdpad = so.yabcdpad;
lowres = so.lowres;

so.spcmDir[sizeof(so.spcmDir)-1] = '\0';
D_snprintf(spcmDir, sizeof(spcmDir), "%s", so.spcmDir);
Expand Down Expand Up @@ -274,6 +277,7 @@ void ReadEEProm(void)
anamorphicview = 0;
sfxdriver = 0;
detailmode = detmode_normal;
lowres = false;

ReadOptions();
}
Expand Down
30 changes: 29 additions & 1 deletion o_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ typedef enum
mi_resolution,
mi_anamorphic,
mi_detailmode,
mi_lowres,

mi_controltype,
mi_yabcdpad,
Expand Down Expand Up @@ -247,6 +248,10 @@ void O_Init (void)
menuitem[mi_detailmode].x = ITEMX;
menuitem[mi_detailmode].y = STARTY + ITEMSPACE * 3;

D_memcpy(menuitem[mi_lowres].name, "Low detail", 11);
menuitem[mi_lowres].x = ITEMX;
menuitem[mi_lowres].y = STARTY + ITEMSPACE * 4;

D_memcpy(menuitem[mi_controltype].name, "Gamepad", 8);
menuitem[mi_controltype].x = ITEMX;
menuitem[mi_controltype].y = STARTY;
Expand Down Expand Up @@ -293,7 +298,7 @@ void O_Init (void)

D_memcpy(menuscreen[ms_video].name, "Video", 6);
menuscreen[ms_video].firstitem = mi_resolution;
menuscreen[ms_video].numitems = mi_detailmode - mi_resolution + 1;
menuscreen[ms_video].numitems = mi_lowres - mi_resolution + 1;

D_memcpy(menuscreen[ms_controls].name, "Controls", 9);
menuscreen[ms_controls].firstitem = mi_controltype;
Expand Down Expand Up @@ -724,6 +729,13 @@ void O_Control (player_t *player)
if (detailmode != detmode_potato)
detailmode = detmode_potato;
break;
case mi_lowres:
if (!lowres)
{
lowres = true;
R_SetViewportSize(viewportNum);
}
break;
}
}

Expand All @@ -738,6 +750,13 @@ void O_Control (player_t *player)
if (detailmode != detmode_normal)
detailmode = detmode_normal;
break;
case mi_lowres:
if (lowres)
{
lowres = false;
R_SetViewportSize(viewportNum);
}
break;
}
}

Expand Down Expand Up @@ -908,6 +927,15 @@ void O_Drawer (void)
print(menuitem[mi_detailmode].x + 160, menuitem[mi_detailmode].y, "off");
break;
}

switch (lowres) {
case true:
print(menuitem[mi_lowres].x + 160, menuitem[mi_lowres].y, "on");
break;
default:
print(menuitem[mi_lowres].x + 160, menuitem[mi_lowres].y, "off");
break;
}
}

if (screenpos == ms_help)
Expand Down
4 changes: 3 additions & 1 deletion p_tick.c
Original file line number Diff line number Diff line change
Expand Up @@ -540,9 +540,11 @@ void P_Drawer (void)
clearscreen = 2;

if (clearscreen > 0) {
int width = viewportWidth * (lowres ? 2 : 1);

I_ResetLineTable();

if (viewportWidth == 320)
if (width == 320)
I_ClearFrameBuffer();
else
DrawTiledBackground();
Expand Down
1 change: 1 addition & 0 deletions r_local.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ extern fixed_t stretch;
extern fixed_t stretchX;
extern VINT weaponYpos;
extern fixed_t weaponXScale;
extern boolean lowres;

#define PROJECTION centerXFrac

Expand Down
24 changes: 19 additions & 5 deletions r_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ fixed_t stretch;
fixed_t stretchX;
VINT weaponYpos;
fixed_t weaponXScale;
boolean lowres = false;

VINT detailmode;

Expand Down Expand Up @@ -260,6 +261,8 @@ void R_SetViewportSize(int num)

width = viewports[num][splitscreen][0];
height = viewports[num][splitscreen][1];
if (lowres)
width /= 2;

viewportNum = num;
viewportWidth = width;
Expand All @@ -281,7 +284,7 @@ void R_SetViewportSize(int num)
//stretch = (fixed_t)((160.0f / width) * ((float)height / 180.0f) * 2.2f * FRACUNIT);
stretch = ((FRACUNIT * 16 * height) / 180 * 22) / width;
}
weaponXScale = FRACUNIT;
weaponXScale = FRACUNIT / (lowres ? 2 : 1);
stretchX = stretch * centerX;

weaponYpos = 180;
Expand Down Expand Up @@ -319,11 +322,22 @@ void R_SetDrawFuncs(void)
if (detailmode < detmode_potato || detailmode >= MAXDETAILMODES)
detailmode = detmode_normal;

drawcol = I_DrawColumn;
drawcolnpo2 = I_DrawColumnNPo2;
drawfuzzcol = I_DrawFuzzColumn;
drawspan = detailmode == detmode_potato ? I_DrawSpanPotato : I_DrawSpan;
if (lowres)
{
drawcol = I_DrawColumnLow;
drawcolnpo2 = I_DrawColumnNPo2Low;
drawfuzzcol = I_DrawFuzzColumnLow;
drawspan = detailmode == detmode_potato ? I_DrawSpanPotatoLow : I_DrawSpanLow;
}
else
{
drawcol = I_DrawColumn;
drawcolnpo2 = I_DrawColumnNPo2;
drawfuzzcol = I_DrawFuzzColumn;
drawspan = detailmode == detmode_potato ? I_DrawSpanPotato : I_DrawSpan;
}

Mars_ClearCache();
#ifdef MARS
Mars_CommSlaveClearCache();
#endif
Expand Down
2 changes: 1 addition & 1 deletion r_phase3.c
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ static void R_PrepPSprite(pspdef_t *psp)
return;

xscale = weaponXScale;
center = centerXFrac - 160 * weaponXScale;
center = centerXFrac - (lowres ? 320 - viewportWidth : 160) * weaponXScale;

tx = psp->sx + center;
topoffset = (((fixed_t)BIGSHORT(patch->topoffset) - weaponYpos) << FRACBITS) - psp->sy;
Expand Down
Loading

0 comments on commit 8982b7a

Please sign in to comment.