Skip to content

Commit

Permalink
SHC/Dreamcast support (#1276)
Browse files Browse the repository at this point in the history
* SHC support

* fixed platform icon order

* remove unnecessary ARG in dockerfile

* tidied up dreamcast CC, moved some flags to settings

* enable dreamcast support in CI

* fixed formatting

* cleaned up cc even more as per mkst's advice
  • Loading branch information
Exant64 authored Jun 10, 2024
1 parent 11b09b9 commit bd7dac6
Show file tree
Hide file tree
Showing 11 changed files with 77 additions and 0 deletions.
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ jobs:
--build-arg ENABLE_GC_WII_SUPPORT=YES \
--build-arg ENABLE_PS2_SUPPORT=YES \
--build-arg ENABLE_SATURN_SUPPORT=YES \
--build-arg ENABLE_DREAMCAST_SUPPORT=YES \
--build-arg ENABLE_WIN32_SUPPORT=YES
- name: Run tests
run: |-
Expand Down
4 changes: 4 additions & 0 deletions backend/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,10 @@ RUN add-apt-repository -y ppa:dosemu2/ppa && \
ARG ENABLE_MSDOS_SUPPORT
ARG ENABLE_PS2_SUPPORT
ARG ENABLE_WIN32_SUPPORT
ARG ENABLE_DREAMCAST_SUPPORT
RUN if [ "${ENABLE_MSDOS_SUPPORT}" = "YES" ] || \
[ "${ENABLE_PS2_SUPPORT}" = "YES" ] || \
[ "${ENABLE_DREAMCAST_SUPPORT}" = "YES" ] || \
[ "${ENABLE_WIN32_SUPPORT}" = "YES" ]; then \
dpkg --add-architecture i386 && apt-get update && \
apt-get install -y -o APT::Immediate-Configure=false \
Expand Down Expand Up @@ -130,6 +132,7 @@ USER user
RUN if [ "${ENABLE_MSDOS_SUPPORT}" = "YES" ] || \
[ "${ENABLE_NDS_ARM9_SUPPORT}" = "YES" ] || \
[ "${ENABLE_PS2_SUPPORT}" = "YES" ] || \
[ "${ENABLE_DREAMCAST_SUPPORT}" = "YES" ] || \
[ "${ENABLE_WIN32_SUPPORT}" = "YES" ]; then \
wineboot --init; \
fi
Expand All @@ -151,6 +154,7 @@ ENV ENABLE_GC_WII_SUPPORT=${ENABLE_GC_WII_SUPPORT}
ENV ENABLE_MACOSX_SUPPORT=${ENABLE_MACOSX_SUPPORT}
ENV ENABLE_MSDOS_SUPPORT=${ENABLE_MSDOS_SUPPORT}
ENV ENABLE_N3DS_SUPPORT=${ENABLE_N3DS_SUPPORT}
ENV ENABLE_DREAMCAST_SUPPORT=${ENABLE_DREAMCAST_SUPPORT}
ENV ENABLE_N64_SUPPORT=${ENABLE_N64_SUPPORT}
ENV ENABLE_NDS_ARM9_SUPPORT=${ENABLE_NDS_ARM9_SUPPORT}
ENV ENABLE_PS1_SUPPORT=${ENABLE_PS1_SUPPORT}
Expand Down
3 changes: 3 additions & 0 deletions backend/compilers/compilers.linux.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,9 @@ psp:
saturn:
- cygnus-2.7-96Q3

dreamcast:
- shc-v5.1r11

macosx:
- gcc-5026
- gcc-5363
Expand Down
19 changes: 19 additions & 0 deletions backend/coreapp/compilers.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from coreapp.flags import (
COMMON_ARMCC_FLAGS,
COMMON_CLANG_FLAGS,
COMMON_SHC_FLAGS,
COMMON_GCC_FLAGS,
COMMON_GCC_PS1_FLAGS,
COMMON_GCC_PS2_FLAGS,
Expand Down Expand Up @@ -36,6 +37,7 @@
PS2,
PSP,
SATURN,
DREAMCAST,
SWITCH,
WIN32,
Platform,
Expand Down Expand Up @@ -107,6 +109,12 @@ class ArmccCompiler(Compiler):
library_include_flag: str = "-J"


@dataclass(frozen=True)
class SHCCompiler(Compiler):
flags: ClassVar[Flags] = COMMON_SHC_FLAGS
library_include_flag: str = ""


@dataclass(frozen=True)
class GCCCompiler(Compiler):
is_gcc: ClassVar[bool] = True
Expand Down Expand Up @@ -502,6 +510,15 @@ def available_platforms() -> List[Platform]:
cc=SATURN_CC,
)

DREAMCAST_CC = (
'cat "$INPUT" | unix2dos > dos_src.c && '
"cp -r ${COMPILER_DIR}/bin/* . && "
"(SHC_LIB=. SHC_TMP=. ${WINE} ${COMPILER_DIR}/bin/shc.exe dos_src.c ${COMPILER_FLAGS} -comment=nonest -cpu=sh4 -division=cpu -fpu=single -endian=little -extra=a=1800 -pic=0 -macsave=0 -sjis -string=const -aggressive=2 -object=dos_src.obj) && "
"${WIBO} ${COMPILER_DIR}/bin/elfcnv.exe dos_src.obj ${OUTPUT}"
)

SHC_V51R11 = SHCCompiler(id="shc-v5.1r11", platform=DREAMCAST, cc=DREAMCAST_CC)

# PS2
EE_GCC29_990721 = GCCPS2Compiler(
id="ee-gcc2.9-990721",
Expand Down Expand Up @@ -1496,6 +1513,8 @@ def available_platforms() -> List[Platform]:
MWCCPSP_3_0_1_219,
# Saturn
CYGNUS_2_7_96Q3,
# Dreamcast
SHC_V51R11,
# PS2
EE_GCC29_990721,
EE_GCC29_991111,
Expand Down
9 changes: 9 additions & 0 deletions backend/coreapp/flags.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,15 @@ def to_json(self) -> Dict[str, Union[str, List[str]]]:
Checkbox(id="clang_no_exceptions", flag="-fno-exceptions"),
]

COMMON_SHC_FLAGS: Flags = [
FlagSet(id="shc_opt_level", flags=["-optimize=0", "-optimize=1"]),
FlagSet(id="shc_opt_type", flags=["-speed", "-size"]),
FlagSet(id="shc_round", flags=["-round=zero", "-round=nearest"]),
Checkbox(id="shc_debug", flag="-debug"),
Checkbox(id="shc_loop", flag="-loop"),
Checkbox(id="shc_inline", flag="-inline"),
]

COMMON_GCC_FLAGS: Flags = [
FlagSet(id="gcc_opt_level", flags=["-O0", "-O1", "-O2", "-O3"]),
FlagSet(
Expand Down
13 changes: 13 additions & 0 deletions backend/coreapp/platforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,18 @@ def from_id(platform_id: str) -> Platform:
diff_flags=COMMON_DIFF_FLAGS,
)

DREAMCAST = Platform(
id="dreamcast",
name="Dreamcast",
description="SH4 (little-endian)",
arch="sh4",
assemble_cmd='sh-elf-as --isa=sh4 --little --relax -o "$OUTPUT" "$PRELUDE" "$INPUT"',
objdump_cmd="sh-elf-objdump",
nm_cmd="sh-elf-nm",
diff_flags=COMMON_DIFF_FLAGS,
has_decompiler=False,
)

PS2 = Platform(
id="ps2",
name="PlayStation 2",
Expand Down Expand Up @@ -241,6 +253,7 @@ def from_id(platform_id: str) -> Platform:
"ps2": PS2,
"psp": PSP,
"saturn": SATURN,
"dreamcast": DREAMCAST,
"macosx": MACOSX,
"msdos": MSDOS,
"win32": WIN32,
Expand Down
1 change: 1 addition & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ services:
ENABLE_MSDOS_SUPPORT: "NO"
ENABLE_PS2_SUPPORT: "NO"
ENABLE_WIN32_SUPPORT: "NO"
ENABLE_DREAMCAST_SUPPORT: "NO"
# dont install clang by default
ENABLE_SWITCH_SUPPORT: "NO"
# dont install dosemu by default
Expand Down
1 change: 1 addition & 0 deletions frontend/src/app/(navfooter)/credits/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ const ICON_SOURCES = {
"Happy Mac by NiloGlock": "https://commons.wikimedia.org/wiki/File:Happy_Mac.svg",
"Tiger-like-x by Althepal": "https://commons.wikimedia.org/wiki/File:Tiger-like-x.svg",
"Saturn by JustDanPatrick": "https://upload.wikimedia.org/wikipedia/commons/archive/7/78/20220518145749%21Sega_Saturn_Black_Logo.svg",
"Dreamcast by Sega": "https://en.wikipedia.org/wiki/File:Dreamcast_logo.svg",
"MS-DOS by Microsoft": "https://commons.wikimedia.org/wiki/File:Msdos-icon.svg",
"Windows 9x by Microsoft": "https://commons.wikimedia.org/wiki/File:Windows_Logo_(1992-2001).svg",
"PerSPire Font by Sean Liew": "https://www.fontspace.com/sean-liew",
Expand Down
2 changes: 2 additions & 0 deletions frontend/src/components/PlatformSelect/PlatformIcon.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import LogoDreamcast from "./dreamcast.svg"
import LogoGBA from "./gba.svg"
import LogoGCWii from "./gc_wii.svg"
import LogoIRIX from "./irix.svg"
Expand Down Expand Up @@ -30,6 +31,7 @@ const ICONS = {
"n3ds": LogoN3DS,
"switch": LogoSwitch,
"saturn": LogoSaturn,
"dreamcast": LogoDreamcast,
}

export const PLATFORMS = Object.keys(ICONS)
Expand Down
9 changes: 9 additions & 0 deletions frontend/src/components/PlatformSelect/dreamcast.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 15 additions & 0 deletions frontend/src/lib/i18n/locales/en/compilers.json
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,8 @@
"gcc2.91.66-mipsel": "gcc 2.91.66 + maspsx",
"gcc2.95.2-mipsel": "gcc 2.95.2 + maspsx",

"shc-v5.1r11": "SHC v5.1 (Release 11)",

"psyq3.3": "PSYQ3.3 (gcc 2.6.0 + aspsx 2.21)",
"psyq3.5": "PSYQ3.5 (gcc 2.6.0 + aspsx 2.34)",
"psyq3.6": "PSYQ3.6 (gcc 2.7.2 + aspsx 2.34)",
Expand Down Expand Up @@ -365,6 +367,19 @@
"msvc_fastcall": "__fastcall calling convention",
"msvc_stdcall": "__stdcall calling convention",

"shc_opt_level": "Optimization level",
"shc_opt_level.-optimize=0": "Optimization: off",
"shc_opt_level.-optimize=1": "Optimization: on",
"shc_opt_type": "Optimization type",
"shc_opt_type.speed": "Optimization for speed",
"shc_opt_type.size": "Optimization for size",
"shc_round": "Floating-point rounding options",
"shc_round.-round=zero": "Round to zero",
"shc_round.-round=nearest": "Round to nearest",
"shc_debug": "Debug",
"shc_loop": "Loop unrolling",
"shc_inline": "Inline static functions",

"psyq_opt_level": "Optimization level",
"psyq_opt_level.-O0": "No optimization",
"psyq_opt_level.-O1": "Some optimization",
Expand Down

0 comments on commit bd7dac6

Please sign in to comment.