Skip to content

Commit

Permalink
wolf3d: fix crash on FizzleFade at 160x128
Browse files Browse the repository at this point in the history
  • Loading branch information
ilyakurdyukov authored Sep 2, 2024
1 parent 0adc96a commit 9d82f8a
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 12 deletions.
1 change: 1 addition & 0 deletions fpmenu/config.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ $doom = fpbin/fpdoom.bin $@
|Duke 3D| fpbin/fpduke3d.bin $@ --dir games/duke3d duke3d # -cachesize 1648
|Shadow Warrior| fpbin/fpsw.bin $@ --dir games/sw sw # -cachesize 1552
|Blood| fpbin/fpblood.bin $@ --dir games/blood blood # -cachesize 1648
|Wolfenstein 3D| fpbin/wolf3d.bin $@ --dir games/wolf3d wolf3d

#1234567890123456# 128px = 16 chars
#12345678901234567890# 160px = 20 chars
Expand Down
7 changes: 6 additions & 1 deletion release.make
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ APPS = fpdoom fpduke3d fpsw fpblood infones wolf3d wolf3d_sw
BINS = \
$(patsubst %,$(BINDIR)/usb/%.bin,fptest $(APPS)) \
$(patsubst %,$(FPBIN)/%.bin,fpmain $(APPS)) \
$(patsubst %,$(BINDIR)/sdboot%.bin,1 2 3)
$(patsubst %,$(BINDIR)/sdboot%.bin,1 2 3) \
$(FPBIN)/config.txt

.PHONY: all clean
all: $(BINS)
Expand Down Expand Up @@ -88,6 +89,10 @@ $(BINDIR)/sdboot3.bin:
$(FPBIN)/fpmain.bin:
$(call makebin,fpmenu,LIBC_SDIO=3 NAME=fpmain)

$(FPBIN)/config.txt:
mkdir -p $(dir $@)
cp fpmenu/$(notdir $@) $@

$(FPBIN)/fpdoom.bin: doom_src
$(call makebin,fpdoom,LIBC_SDIO=3)

Expand Down
4 changes: 2 additions & 2 deletions wolf3d/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ GAMEVER = CARMACIZED SPEAR SPEARDEMO
endif
endif
ifneq ($(GAMEVER),)
GAMEFLAGS = -DVERSIONALREADYCHOSEN $(GAMEVER:%=-D%)
GAME_CFLAGS += -DVERSIONALREADYCHOSEN $(GAMEVER:%=-D%)
endif

GAME_SRCS = \
Expand Down Expand Up @@ -117,7 +117,7 @@ endif

CFLAGS += -std=c99 -pedantic

GAME_CFLAGS = -DEMBEDDED=2 -DNO_SOUND=1 -DNO_MOUSE=1 -DNO_JOYSTICK=1
GAME_CFLAGS += -DEMBEDDED=2 -DNO_SOUND=1 -DNO_MOUSE=1 -DNO_JOYSTICK=1
GAME_CFLAGS += -DVIEWMAP -DREVEALMAP
#GAME_CFLAGS += -DTRACE_UPDATE=1
ifeq ($(LIBC_SDIO), 0)
Expand Down
42 changes: 33 additions & 9 deletions wolf3d/wolf3d.patch
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,7 @@ index 88a5590..7baab83 100644

for (text = textinput; *text; text++)
diff --git a/id_vh.c b/id_vh.c
index 2f85e15..12d9097 100644
index 2f85e15..e942caf 100644
--- a/id_vh.c
+++ b/id_vh.c
@@ -73,11 +73,15 @@ void VW_MeasurePropString (const char *string, word *width, word *height)
Expand All @@ -476,7 +476,22 @@ index 2f85e15..12d9097 100644
}

void VWB_DrawTile8 (int x, int y, int tile)
@@ -236,10 +240,13 @@ boolean FizzleFade (SDL_Surface *source, int x1, int y1,
@@ -215,6 +219,14 @@ boolean FizzleFade (SDL_Surface *source, int x1, int y1,
{
unsigned x, y, p, frame, pixperframe;
int32_t rndval;
+#ifdef EMBEDDED
+ unsigned stride = screenWidth;
+ if (screenHeight == 256) {
+ width = (width + (x1 & 1) + 1) >> 1;
+ height = (height + (y1 & 1) + 1) >> 1;
+ x1 >>= 1; y1 >>= 1; stride >>= 1;
+ }
+#endif

rndval = 1;
pixperframe = width * height / frames;
@@ -236,10 +248,13 @@ boolean FizzleFade (SDL_Surface *source, int x1, int y1,
return true;
}

Expand All @@ -491,29 +506,38 @@ index 2f85e15..12d9097 100644

for (p = 0; p < pixperframe; p++)
{
@@ -261,6 +268,13 @@ boolean FizzleFade (SDL_Surface *source, int x1, int y1,
@@ -261,6 +276,22 @@ boolean FizzleFade (SDL_Surface *source, int x1, int y1,
//
// copy one pixel
//
+#ifdef EMBEDDED
+ {
+ unsigned pos = (y1 + y) * screenWidth + x1 + x;
+ uint16_t *d = framebuf, *pal = d - 0x100;
+ uint16_t *d = framebuf;
+ unsigned pos = (y1 + y) * screenWidth + (x1 + x);
+ if (stride == 160) {
+ unsigned a, b = 0x00400802;
+ uint32_t *pal = (uint32_t*)d - 0x100;
+ uint8_t *s = srcptr + pos * 2;
+ a = pal[s[0]] + pal[s[1]]; s += screenWidth;
+ a += pal[s[0]] + pal[s[1]];
+ a += (b & a >> 2) + b; a &= 0xf81f07e0;
+ d[(pos + x1 + x) >> 1] = a | a >> 16;
+ } else {
+ uint16_t *pal = d - 0x100;
+ d[pos] = pal[srcptr[pos]];
+ }
+#else
if(screenBits == 8)
{
*(destptr + (y1 + y) * screen->pitch + x1 + x)
@@ -273,6 +287,7 @@ boolean FizzleFade (SDL_Surface *source, int x1, int y1,
@@ -273,6 +304,7 @@ boolean FizzleFade (SDL_Surface *source, int x1, int y1,
memcpy(destptr + (y1 + y) * screen->pitch + (x1 + x) * screen->format->BytesPerPixel,
&fullcol, screen->format->BytesPerPixel);
}
+#endif
}

if (rndval == 1)
@@ -282,7 +297,7 @@ boolean FizzleFade (SDL_Surface *source, int x1, int y1,
@@ -282,7 +314,7 @@ boolean FizzleFade (SDL_Surface *source, int x1, int y1,
//
VL_UnlockSurface (screenBuffer);
VL_UnlockSurface (screen);
Expand All @@ -522,7 +546,7 @@ index 2f85e15..12d9097 100644

return false;
}
@@ -290,9 +305,13 @@ boolean FizzleFade (SDL_Surface *source, int x1, int y1,
@@ -290,9 +322,13 @@ boolean FizzleFade (SDL_Surface *source, int x1, int y1,

VL_UnlockSurface(screen);

Expand Down

0 comments on commit 9d82f8a

Please sign in to comment.