Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SHC/Dreamcast support #1276

Merged
merged 7 commits into from
Jun 10, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 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 @@ -140,6 +143,7 @@ ENV PATH="$PATH:/etc/poetry/bin"
ARG ENABLE_GBA_SUPPORT
ARG ENABLE_MACOSX_SUPPORT
ARG ENABLE_N3DS_SUPPORT
ARG ENABLE_DREAMCAST_SUPPORT
Exant64 marked this conversation as resolved.
Show resolved Hide resolved
ARG ENABLE_N64_SUPPORT
ARG ENABLE_NDS_ARM9_SUPPORT
ARG ENABLE_PS1_SUPPORT
Expand All @@ -151,6 +155,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
29 changes: 29 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 @@ -106,6 +108,10 @@ class ArmccCompiler(Compiler):
flags: ClassVar[Flags] = COMMON_ARMCC_FLAGS
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):
Expand Down Expand Up @@ -502,6 +508,27 @@ def available_platforms() -> List[Platform]:
cc=SATURN_CC,
)

DREAMCAST_CC = (
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can this be tidied up?

could/should any of those compiler flags be not hard-coded?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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}"
)

"echo ${OUTPUT} && "
"echo pwd is $(pwd) && "
'cat "$INPUT" | unix2dos > dos_src.c && '
'cp -r ${COMPILER_DIR}/bin/*.* /tmp/ && '
'export SHC_LIB=Z:\\\\tmp && '
'export SHC_TMP=Z:\\\\tmp && '
'echo "$SHC_LIB" && '
'(${WINE} /tmp/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 -loop -string=const -round=nearest -inline -aggressive=2 -object=dos_src.obj) && '
# '(WIBO_DEBUG="" ${WIBO} ${COMPILER_DIR}/bin/asmsh.exe dos_src.src -cpu=sh4 -endian=little -sjis -object=dos_src.obj) && '
"(${WIBO} ${COMPILER_DIR}/bin/elfcnv.exe dos_src.obj dos_src.o) && "
'cp dos_src.o "$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 +1523,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
10 changes: 10 additions & 0 deletions backend/coreapp/flags.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,16 @@ 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"]
),
Checkbox(id="shc_debug", flag="-debug"),
]

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.
10 changes: 10 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,14 @@
"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_debug": "Debug",

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