Skip to content

Commit

Permalink
wolf3d port
Browse files Browse the repository at this point in the history
  • Loading branch information
ilyakurdyukov authored Sep 1, 2024
1 parent dcbf7a3 commit 0adc96a
Show file tree
Hide file tree
Showing 13 changed files with 2,726 additions and 35 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ There are other ports that reuse code written for FPDoom:

[fpbuild](fpbuild): Duke 3D, Shadow Warrior, Blood
[infones](infones): NES emulator
[wolf3d](wolf3d): Wolfenstein 3D

### Installation on SD card

Expand Down Expand Up @@ -85,10 +86,11 @@ All feature phone LCDs I've seen are vertical, if you have a phone with a horizo
| 32 | Olmio E35 | SC6531E | ILI9481 320x480 | 0 |
| 33 | Texet TM-D324 | SC6531E | NT35310 320x480 | 0 |
| 34 | Texet TM-302 | SC6531DA | ST7789 240x320 | 0 |
| 35 | Strike A13 | SC6531DA | GC9106 128x160 | left soft |

* Vertex M115, Nokia TA-1174, BQ 3586, Energizer E12,
Sunwind C2401, DEXP SD2810, YX Q5 Kids Camera, Nomi i184, Sigma IO67,
F+ F197, Texet TM-302:
F+ F197, Texet TM-302, Strike A13:
need keymap file
* Nobby 170B: use `--spi 1 --mac 0xa8` without `--rotate`
* Smart Watch DZ09: use `--spi 0 --lcd 0x80009307`, no controls - you can only watch replays, no boot key - use boot cable
Expand Down
8 changes: 8 additions & 0 deletions fpdoom/include/ctype.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,14 @@ static inline int isspace(int c) {
return c == ' ' || (unsigned)c - 9 < 5;
}

static inline int isupper(int c) {
return (unsigned)c - 'A' < 26;
}

static inline int islower(int c) {
return (unsigned)c - 'a' < 26;
}

static inline int ispunct(int c) {
return (unsigned)c - 0x21 < 0x5e && !isalnum(c);
}
Expand Down
2 changes: 0 additions & 2 deletions infones/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,13 @@ LDSCRIPT = $(FPDOOM)/sc6531e_fdl.ld

ifdef TOOLCHAIN
CC = "$(TOOLCHAIN)"-gcc
CXX = "$(TOOLCHAIN)"-g++
OBJCOPY = "$(TOOLCHAIN)"-objcopy
endif

COMPILER = $(findstring clang,$(notdir $(CC)))
ifeq ($(COMPILER), clang)
# Clang
CFLAGS = -Oz
CXX = "$(CC)++"
else
# GCC
CFLAGS = -Os
Expand Down
79 changes: 47 additions & 32 deletions release.make
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ ifneq ($(words $(ZIPDIR)), 1)
$(error ZIPDIR must not contain spaces in the name)
endif

BIN_NAMES = usb/fptest sdcard/fpbin/fpmain \
$(patsubst %,usb/%,fpdoom fpduke3d fpsw fpblood infones) \
$(patsubst %,sdcard/fpbin/%,fpdoom fpduke3d fpsw fpblood infones) \
$(patsubst %,sdcard/sdboot%,1 2 3)

BINS = $(patsubst %,$(BINDIR)/%.bin,$(BIN_NAMES))
FPBIN = $(BINDIR)/sdcard/fpbin
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)

.PHONY: all clean
all: $(BINS)
Expand All @@ -37,60 +37,75 @@ fpbuild/jfbuild:
infones/InfoNES:
$(call getsrc,infones)

wolf3d/Wolf4SDL:
$(call getsrc,wolf3d)

define makebin
cd $(1) && $(MAKE) clean $(2)
cd $(1) && $(MAKE) all $(2)
mkdir -p $(BINDIR)/$(4)
mv $(1)/$(3).bin $(BINDIR)/$(4)/
mkdir -p $(dir $@)
mv $(1)/$(notdir $@) $@
cd $(1) && $(MAKE) clean $(2)
endef

# USB mode

$(BINDIR)/usb/fptest.bin:
$(call makebin,fptest,LIBC_SDIO=0,fptest,usb)
$(call makebin,fptest,LIBC_SDIO=0)

$(BINDIR)/usb/fpdoom.bin: doom_src
$(call makebin,fpdoom,LIBC_SDIO=0,fpdoom,usb)
$(call makebin,fpdoom,LIBC_SDIO=0)

$(BINDIR)/usb/fpduke3d.bin: fpbuild/jfbuild
$(call makebin,fpbuild,LIBC_SDIO=0 GAME=duke3d,fpduke3d,usb)
$(call makebin,fpbuild,LIBC_SDIO=0 GAME=duke3d)

$(BINDIR)/usb/fpsw.bin: fpbuild/jfbuild
$(call makebin,fpbuild,LIBC_SDIO=0 GAME=sw,fpsw,usb)
$(call makebin,fpbuild,LIBC_SDIO=0 GAME=sw)

$(BINDIR)/usb/fpblood.bin: fpbuild/jfbuild
$(call makebin,fpbuild,LIBC_SDIO=0 GAME=blood,fpblood,usb)
$(call makebin,fpbuild,LIBC_SDIO=0 GAME=blood)

$(BINDIR)/usb/infones.bin: infones/InfoNES
$(call makebin,infones,LIBC_SDIO=0,infones,usb)
$(call makebin,infones,LIBC_SDIO=0)

$(BINDIR)/usb/wolf3d.bin: wolf3d/Wolf4SDL
$(call makebin,wolf3d,LIBC_SDIO=0)

$(BINDIR)/usb/wolf3d_sw.bin: wolf3d/Wolf4SDL
$(call makebin,wolf3d,LIBC_SDIO=0 NAME=wolf3d_sw)

# SD card mode

$(BINDIR)/sdcard/sdboot1.bin:
$(call makebin,sdboot,CHIP=1,sdboot1,sdcard)
$(BINDIR)/sdboot1.bin:
$(call makebin,sdboot,CHIP=1)

$(BINDIR)/sdboot2.bin:
$(call makebin,sdboot,CHIP=2)

$(BINDIR)/sdboot3.bin:
$(call makebin,sdboot,CHIP=3)

$(BINDIR)/sdcard/sdboot2.bin:
$(call makebin,sdboot,CHIP=2,sdboot2,sdcard)
$(FPBIN)/fpmain.bin:
$(call makebin,fpmenu,LIBC_SDIO=3 NAME=fpmain)

$(BINDIR)/sdcard/sdboot3.bin:
$(call makebin,sdboot,CHIP=3,sdboot3,sdcard)
$(FPBIN)/fpdoom.bin: doom_src
$(call makebin,fpdoom,LIBC_SDIO=3)

$(BINDIR)/sdcard/fpbin/fpmain.bin:
$(call makebin,fpmenu,LIBC_SDIO=3 NAME=fpmain,fpmain,sdcard/fpbin)
$(FPBIN)/fpduke3d.bin: fpbuild/jfbuild
$(call makebin,fpbuild,LIBC_SDIO=3 GAME=duke3d)

$(BINDIR)/sdcard/fpbin/fpdoom.bin: doom_src
$(call makebin,fpdoom,LIBC_SDIO=3,fpdoom,sdcard/fpbin)
$(FPBIN)/fpsw.bin: fpbuild/jfbuild
$(call makebin,fpbuild,LIBC_SDIO=3 GAME=sw)

$(BINDIR)/sdcard/fpbin/fpduke3d.bin: fpbuild/jfbuild
$(call makebin,fpbuild,LIBC_SDIO=3 GAME=duke3d,fpduke3d,sdcard/fpbin)
$(FPBIN)/fpblood.bin: fpbuild/jfbuild
$(call makebin,fpbuild,LIBC_SDIO=3 GAME=blood)

$(BINDIR)/sdcard/fpbin/fpsw.bin: fpbuild/jfbuild
$(call makebin,fpbuild,LIBC_SDIO=3 GAME=sw,fpsw,sdcard/fpbin)
$(FPBIN)/infones.bin: infones/InfoNES
$(call makebin,infones,LIBC_SDIO=3)

$(BINDIR)/sdcard/fpbin/fpblood.bin: fpbuild/jfbuild
$(call makebin,fpbuild,LIBC_SDIO=3 GAME=blood,fpblood,sdcard/fpbin)
$(FPBIN)/wolf3d.bin: wolf3d/Wolf4SDL
$(call makebin,wolf3d,LIBC_SDIO=3)

$(BINDIR)/sdcard/fpbin/infones.bin: infones/InfoNES
$(call makebin,infones,LIBC_SDIO=3,infones,sdcard/fpbin)
$(FPBIN)/wolf3d_sw.bin: wolf3d/Wolf4SDL
$(call makebin,wolf3d,LIBC_SDIO=3 NAME=wolf3d_sw)

214 changes: 214 additions & 0 deletions wolf3d/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,214 @@
# 0 - detect, 1 - SC6531E, 2 - SC6531DA, 3 - SC6530
CHIP = 0
TWO_STAGE = 1
LIBC_SDIO = 0
USE_ASM = 0
NO_FLOAT = 1
PACK_RELOC = ../pack_reloc/pack_reloc
SRCS = asmcode usbio common libc syscomm
ifeq ($(CHIP), 0)
SRCS += chip1_syscode chip2_syscode
else
SRCS += syscode
endif
ifneq ($(LIBC_SDIO), 0)
SRCS += sdio microfat
endif

NAME = wolf3d
GAMESRC = Wolf4SDL
OBJDIR = obj$(CHIP)
FPDOOM = ../fpdoom
HOSTCC = cc
NM = nm

ifeq ($(GAMEVER),)
GAMEVER = CARMACIZED GOODTIMES # v1.4
ifneq ($(filter %_apo,$(NAME)),)
GAMEVER = CARMACIZED # v1.4 apogee
else ifneq ($(filter %_sw,$(NAME)),)
GAMEVER = CARMACIZED UPLOAD # sw v1.4
else ifneq ($(filter %_sod,$(NAME)),)
GAMEVER = CARMACIZED GOODTIMES SPEAR
else ifneq ($(filter %_sdm,$(NAME)),)
GAMEVER = CARMACIZED SPEAR SPEARDEMO
endif
endif
ifneq ($(GAMEVER),)
GAMEFLAGS = -DVERSIONALREADYCHOSEN $(GAMEVER:%=-D%)
endif

GAME_SRCS = \
id_ca id_in id_pm id_sd id_us id_vh id_vl \
signon wl_act1 wl_act2 wl_agent wl_atmos \
wl_cloudsky wl_debug wl_draw wl_game wl_inter \
wl_main wl_menu wl_parallax wl_plane wl_play \
wl_scale wl_shade wl_state wl_text wl_utils

SRCS += extra scr_update wlsys_fp

GAME_OBJS = $(GAME_SRCS:%=$(OBJDIR)/game/%.o)

ifeq ($(TWO_STAGE), 0)
SRCS := start entry $(SRCS)
OBJS = $(SRCS:%=$(OBJDIR)/sys/%.o) $(GAME_OBJS)
else
SRCS1 = start1 entry $(SRCS)
SRCS2 = start2 entry2 $(SRCS)
OBJS1 = $(SRCS1:%=$(OBJDIR)/sys/%.o)
OBJS2 = $(SRCS2:%=$(OBJDIR)/sys/%.o) $(GAME_OBJS)
endif

LDSCRIPT = $(FPDOOM)/sc6531e_fdl.ld

ifdef TOOLCHAIN
CC = "$(TOOLCHAIN)"-gcc
OBJCOPY = "$(TOOLCHAIN)"-objcopy
endif

COMPILER = $(findstring clang,$(notdir $(CC)))
ifeq ($(COMPILER), clang)
# Clang
CFLAGS = -Oz
else
# GCC
CFLAGS = -Os
endif

CFLAGS += -Wall -Wextra -fsigned-char
CFLAGS += -fno-PIE -ffreestanding -march=armv5te -mthumb $(EXTRA_CFLAGS) -fno-strict-aliasing
CFLAGS += -fomit-frame-pointer
CFLAGS += -ffunction-sections -fdata-sections
LFLAGS = -pie -nostartfiles -nodefaultlibs -nostdlib -Wl,-T,$(LDSCRIPT) -Wl,--gc-sections -Wl,-z,notext
ifeq ($(CHIP), 2)
LFLAGS += -Wl,--defsym,IMAGE_START=0x34000000
else
LFLAGS += -Wl,--defsym,IMAGE_START=0x14000000
endif
# -Wl,--no-dynamic-linker
LFLAGS += $(LD_EXTRA)
CFLAGS += -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=0
CFLAGS += -isystem $(FPDOOM)/include
ifneq ($(CHIP), 0)
CFLAGS += -DCHIP=$(CHIP)
endif
CFLAGS += -DTWO_STAGE=$(TWO_STAGE)
ifneq ($(LIBC_SDIO), 0)
CFLAGS += -DLIBC_SDIO=$(LIBC_SDIO) -DFAT_WRITE=1
#CFLAGS += -DFAT_DEBUG=1
endif

ifeq ($(COMPILER), clang)
# Clang's bug workaround
CFLAGS += -mcpu=+nodsp
endif

LTO = 1
ifneq ($(LTO), 0)
# Clang's LTO doesn't work with the GCC toolchain
ifeq ($(findstring -gcc-toolchain,$(notdir $(CC))),)
CFLAGS += -flto
endif
endif

ifdef SYSROOT
CFLAGS += --sysroot="$(SYSROOT)"
endif

CFLAGS += -std=c99 -pedantic

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)
GAME_CFLAGS += -DLINUX_FN_FIX=1
endif
ifneq ($(USE_ASM), 0)
GAME_CFLAGS += -DUSE_ASM
endif
ifneq ($(NO_FLOAT), 0)
GAME_CFLAGS += -DNO_FLOAT=1 -I$(OBJDIR)
endif
GAME_CFLAGS += -I$(GAMESRC) -I.
GAME_CFLAGS += -Wno-unused -Wno-unused-parameter
GAME_CFLAGS += -Wno-strict-prototypes

.PHONY: all clean map

all: $(NAME).bin map
map: $(OBJDIR)/$(NAME)_map.txt

clean:
$(RM) -r $(OBJDIR) $(NAME).bin

$(OBJDIR):
mkdir -p $@/sys $@/game

%.asm: %.c
$(CC) $(CFLAGS) $< -S -o $@

ifneq ($(NO_FLOAT), 0)
$(OBJDIR)/game/wl_draw.o: $(OBJDIR)/wolf3d_tables.h

$(OBJDIR)/calctables: calctables.c | $(OBJDIR)
$(HOSTCC) -O2 $< -o $@ -lm

$(OBJDIR)/wolf3d_tables.h: $(OBJDIR)/calctables
$(OBJDIR)/calctables $@
endif

-include $(OBJS:.o=.d)

compile_fn = $(CC) $(CFLAGS) $(1) -MMD -MP -MF $(@:.o=.d) $< -c -o $@

$(OBJDIR)/game/%.o: $(GAMESRC)/%.c | $(OBJDIR)
$(call compile_fn,$(GAME_CFLAGS))

$(OBJDIR)/sys/%.o: %.c | $(OBJDIR)
$(call compile_fn,$(GAME_CFLAGS) -I$(ENGINEROOT)/src -I$(FPDOOM))

$(OBJDIR)/sys/%.o: $(FPDOOM)/%.c | $(OBJDIR)
$(call compile_fn,)

$(OBJDIR)/sys/chip1_%.o: $(FPDOOM)/%.c | $(OBJDIR)
$(call compile_fn,-DCHIP=1 -DCHIP_AUTO)

$(OBJDIR)/sys/chip2_%.o: $(FPDOOM)/%.c | $(OBJDIR)
$(call compile_fn,-DCHIP=2 -DCHIP_AUTO)

$(OBJDIR)/sys/%.o: $(FPDOOM)/%.s | $(OBJDIR)
$(CC) $< -c -o $@

$(OBJDIR)/sys/%.o: %.s | $(OBJDIR)
$(CC) $< -c -o $@

%.rel: %.elf
$(PACK_RELOC) $< $@

ifeq ($(TWO_STAGE), 0)
$(OBJDIR)/$(NAME).elf: $(OBJS)
$(CC) $(LFLAGS) $(OBJS) -o $@

$(OBJDIR)/$(NAME)_map.txt: $(OBJDIR)/$(NAME).elf
$(NM) -n $< > $@

$(NAME).bin: $(OBJDIR)/$(NAME).elf $(OBJDIR)/$(NAME).rel
$(OBJCOPY) -O binary -j .text $< $@
cat $(OBJDIR)/$(NAME).rel >> $@
else
$(OBJDIR)/$(NAME)_part1.elf: $(OBJS1)
$(CC) $(LFLAGS) $(OBJS1) -o $@

$(OBJDIR)/$(NAME)_part2.elf: $(OBJS2)
$(CC) $(LFLAGS) $(OBJS2) -o $@

$(OBJDIR)/$(NAME)_map.txt: $(OBJDIR)/$(NAME)_part2.elf
$(NM) -n $< > $@

%.bin: %.elf
$(OBJCOPY) -O binary -j .text $< $@

$(NAME).bin: $(patsubst %,$(OBJDIR)/$(NAME)_part%,2.bin 1.bin 1.rel 2.rel)
cat $^ > $@
endif

Loading

0 comments on commit 0adc96a

Please sign in to comment.