From 2f206fd084e636ffd0cd5d43f95e903de87af70e Mon Sep 17 00:00:00 2001 From: Mark Street <22226349+mkst@users.noreply.github.com> Date: Thu, 15 Feb 2024 14:17:26 +0000 Subject: [PATCH] Add PSP platform (#958) * Add PSP platform * black * Add credits for font used in PSP logo * Switch wine for wibo + bump version * use wine again for pspsnc.exe * bump asm-differ --- .github/workflows/ci.yml | 2 +- backend/Dockerfile | 18 +++++----- backend/compilers/compilers.linux.yaml | 6 ++++ backend/coreapp/compilers.py | 32 ++++++++++++++++++ backend/coreapp/decompiler_wrapper.py | 2 +- backend/coreapp/platforms.py | 33 ++++++++++++++++++- backend/poetry.lock | 2 +- frontend/src/app/(navfooter)/credits/page.tsx | 1 + .../PlatformSelect/PlatformIcon.tsx | 2 ++ .../src/components/PlatformSelect/psp.svg | 4 +++ .../src/lib/i18n/locales/en/compilers.json | 5 +++ 11 files changed, 95 insertions(+), 12 deletions(-) create mode 100644 frontend/src/components/PlatformSelect/psp.svg diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4f4e0ee15..3ab645dc8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -87,7 +87,7 @@ jobs: poetry run python3 libraries/download.py - name: Install wibo run: |- - wget https://github.com/decompals/wibo/releases/download/0.6.10/wibo && chmod +x wibo && sudo cp wibo /usr/bin/ + wget https://github.com/decompals/wibo/releases/download/0.6.12/wibo && chmod +x wibo && sudo cp wibo /usr/bin/ - name: Run backend tests run: |- diff --git a/backend/Dockerfile b/backend/Dockerfile index b94071a5e..f934ef11f 100644 --- a/backend/Dockerfile +++ b/backend/Dockerfile @@ -59,11 +59,11 @@ RUN apt-get -y update && apt-get install -y \ && rm -rf /var/lib/apt/lists/* RUN curl -sSL https://install.python-poetry.org/ | \ - POETRY_VERSION=1.6.1 POETRY_HOME=/etc/poetry python3.10 - + POETRY_VERSION=1.6.1 POETRY_HOME=/etc/poetry python3.10 - COPY --from=nsjail /nsjail/nsjail /bin/nsjail -COPY --from=ghcr.io/decompals/wibo:0.6.10 /usr/local/sbin/wibo /usr/bin/ +COPY --from=ghcr.io/decompals/wibo:0.6.12 /usr/local/sbin/wibo /usr/bin/ RUN add-apt-repository -y ppa:dosemu2/ppa && \ apt-get update && \ @@ -75,11 +75,11 @@ ARG ENABLE_MSDOS_SUPPORT ARG ENABLE_PS2_SUPPORT ARG ENABLE_WIN9X_SUPPORT RUN if [ "${ENABLE_MSDOS_SUPPORT}" = "YES" ] || \ - [ "${ENABLE_PS2_SUPPORT}" = "YES" ] || \ - [ "${ENABLE_WIN9X_SUPPORT}" = "YES" ]; then \ + [ "${ENABLE_PS2_SUPPORT}" = "YES" ] || \ + [ "${ENABLE_WIN9X_SUPPORT}" = "YES" ]; then \ dpkg --add-architecture i386 && apt-get update && \ apt-get install -y -o APT::Immediate-Configure=false \ - wine; \ + wine; \ fi # msdos specific @@ -107,9 +107,9 @@ USER user # initialize wine files to /home/user/.wine RUN if [ "${ENABLE_MSDOS_SUPPORT}" = "YES" ] || \ - [ "${ENABLE_NDS_ARM9_SUPPORT}" = "YES" ] || \ - [ "${ENABLE_PS2_SUPPORT}" = "YES" ] || \ - [ "${ENABLE_WIN9X_SUPPORT}" = "YES" ]; then \ + [ "${ENABLE_NDS_ARM9_SUPPORT}" = "YES" ] || \ + [ "${ENABLE_PS2_SUPPORT}" = "YES" ] || \ + [ "${ENABLE_WIN9X_SUPPORT}" = "YES" ]; then \ wineboot --init; \ fi @@ -123,6 +123,7 @@ ARG ENABLE_N3DS_SUPPORT ARG ENABLE_N64_SUPPORT ARG ENABLE_NDS_ARM9_SUPPORT ARG ENABLE_PS1_SUPPORT +ARG ENABLE_PSP_SUPPORT ARG ENABLE_SATURN_SUPPORT ARG ENABLE_SWITCH_SUPPORT @@ -135,6 +136,7 @@ ENV ENABLE_N64_SUPPORT=${ENABLE_N64_SUPPORT} ENV ENABLE_NDS_ARM9_SUPPORT=${ENABLE_NDS_ARM9_SUPPORT} ENV ENABLE_PS1_SUPPORT=${ENABLE_PS1_SUPPORT} ENV ENABLE_PS2_SUPPORT=${ENABLE_PS2_SUPPORT} +ENV ENABLE_PSP_SUPPORT=${ENABLE_PSP_SUPPORT} ENV ENABLE_SATURN_SUPPORT=${ENABLE_SATURN_SUPPORT} ENV ENABLE_SWITCH_SUPPORT=${ENABLE_SWITCH_SUPPORT} ENV ENABLE_WIN9X_SUPPORT=${ENABLE_WIN9X_SUPPORT} diff --git a/backend/compilers/compilers.linux.yaml b/backend/compilers/compilers.linux.yaml index 6f37d7fed..d75da606a 100644 --- a/backend/compilers/compilers.linux.yaml +++ b/backend/compilers/compilers.linux.yaml @@ -125,6 +125,12 @@ ps2: - mwcps2-3.0b22-020716 - mwcps2-3.0b22-020926 +psp: + - pspsnc_1.2.7503.0 + - mwccpsp_3.0.1_121 + - mwccpsp_3.0.1_147 + - mwccpsp_3.0.1_151 + saturn: - cygnus-2.7-96Q3 diff --git a/backend/coreapp/compilers.py b/backend/coreapp/compilers.py index 3a1f52740..c613c5fa3 100644 --- a/backend/coreapp/compilers.py +++ b/backend/coreapp/compilers.py @@ -30,6 +30,7 @@ NDS_ARM9, PS1, PS2, + PSP, SATURN, SWITCH, WIN9X, @@ -565,6 +566,32 @@ def available_platforms() -> List[Platform]: cc='${WINE} "${COMPILER_DIR}/mwccps2.exe" -c $COMPILER_FLAGS -nostdinc -stderr "$INPUT" -o "$OUTPUT"', ) +# PSP +PSPSNC_1_2_7503_0 = GCCCompiler( + id="pspsnc_1.2.7503.0", + platform=PSP, + cc='${WINE} ${COMPILER_DIR}/pspsnc.exe -c -td=. ${COMPILER_FLAGS} -o "${OUTPUT}" "${INPUT}"', +) + +MWCCPSP_CC = ( + '${WIBO} ${COMPILER_DIR}/mwccpsp.exe -c ${COMPILER_FLAGS} -o "${OUTPUT}" "${INPUT}"' +) + +MWCCPSP_3_0_1_121 = MWCCCompiler( + id="mwccpsp_3.0.1_121", + platform=PSP, + cc=MWCCPSP_CC, +) +MWCCPSP_3_0_1_147 = MWCCCompiler( + id="mwccpsp_3.0.1_147", + platform=PSP, + cc=MWCCPSP_CC, +) +MWCCPSP_3_0_1_151 = MWCCCompiler( + id="mwccpsp_3.0.1_151", + platform=PSP, + cc=MWCCPSP_CC, +) # N64 IDO53 = IDOCompiler( @@ -1216,6 +1243,11 @@ def available_platforms() -> List[Platform]: GCC281_MIPSEL, GCC29166_MIPSEL, GCC2952_MIPSEL, + # PSP + PSPSNC_1_2_7503_0, + MWCCPSP_3_0_1_121, + MWCCPSP_3_0_1_147, + MWCCPSP_3_0_1_151, # Saturn CYGNUS_2_7_96Q3, # PS2 diff --git a/backend/coreapp/decompiler_wrapper.py b/backend/coreapp/decompiler_wrapper.py index 74f53c818..fdb91528a 100644 --- a/backend/coreapp/decompiler_wrapper.py +++ b/backend/coreapp/decompiler_wrapper.py @@ -24,7 +24,7 @@ def decompile( return f"decompiled({asm})" ret = default_source_code - if platform.arch in ["mips", "mipsee", "mipsel", "ppc"]: + if platform.arch in ["mips", "mipsee", "mipsel", "mipsel:4000", "ppc"]: if len(asm.splitlines()) > MAX_M2C_ASM_LINES: return "/* Too many lines to decompile; please run m2c manually */" try: diff --git a/backend/coreapp/platforms.py b/backend/coreapp/platforms.py index 1470b3823..185b7cd86 100644 --- a/backend/coreapp/platforms.py +++ b/backend/coreapp/platforms.py @@ -256,7 +256,7 @@ def from_id(platform_id: str) -> Platform: name="PlayStation", description="MIPS (little-endian)", arch="mipsel", - assemble_cmd='mips-linux-gnu-as -march=r3000 -mabi=32 -o "$OUTPUT" "$INPUT"', + assemble_cmd='mips-linux-gnu-as -EL -march=r3000 -mabi=32 -o "$OUTPUT" "$INPUT"', objdump_cmd="mips-linux-gnu-objdump", nm_cmd="mips-linux-gnu-nm", diff_flags=COMMON_DIFF_FLAGS + COMMON_MIPS_DIFF_FLAGS, @@ -285,6 +285,36 @@ def from_id(platform_id: str) -> Platform: """, ) +PSP = Platform( + id="psp", + name="PlayStation Portable", + description="MIPS (little-endian)", + arch="mipsel:4000", + assemble_cmd='mips-linux-gnu-as -EL -march=r4000 -mabi=32 -o "$OUTPUT" "$INPUT"', + objdump_cmd="mips-linux-gnu-objdump", + nm_cmd="mips-linux-gnu-nm", + diff_flags=COMMON_DIFF_FLAGS + COMMON_MIPS_DIFF_FLAGS, + asm_prelude=""" +.macro .late_rodata + .section .rodata +.endm + +.macro glabel label + .global \label + .type \label, @function + \label: +.endm + +.macro jlabel label + \label: +.endm + +.set noat +.set noreorder + +""", +) + SATURN = Platform( id="saturn", name="Saturn", @@ -713,6 +743,7 @@ def from_id(platform_id: str) -> Platform: "n3ds": N3DS, "ps1": PS1, "ps2": PS2, + "psp": PSP, "saturn": SATURN, "macosx": MACOSX, "msdos": MSDOS, diff --git a/backend/poetry.lock b/backend/poetry.lock index 34fe78c5f..324c2925f 100644 --- a/backend/poetry.lock +++ b/backend/poetry.lock @@ -51,7 +51,7 @@ watchdog = "^2.2.0" type = "git" url = "https://github.com/simonlindholm/asm-differ.git" reference = "HEAD" -resolved_reference = "77465bce442fed294b383a7a0e28ea7776ba9715" +resolved_reference = "1786d0afc69d38586cba850834a7b5c649f2c0a4" [[package]] name = "attrs" diff --git a/frontend/src/app/(navfooter)/credits/page.tsx b/frontend/src/app/(navfooter)/credits/page.tsx index 9401f2012..da1b3507b 100644 --- a/frontend/src/app/(navfooter)/credits/page.tsx +++ b/frontend/src/app/(navfooter)/credits/page.tsx @@ -28,6 +28,7 @@ const ICON_SOURCES = { "Saturn by JustDanPatrick": "https://upload.wikimedia.org/wikipedia/commons/archive/7/78/20220518145749%21Sega_Saturn_Black_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", } type Contributor = { diff --git a/frontend/src/components/PlatformSelect/PlatformIcon.tsx b/frontend/src/components/PlatformSelect/PlatformIcon.tsx index d7f23204b..4e328447e 100644 --- a/frontend/src/components/PlatformSelect/PlatformIcon.tsx +++ b/frontend/src/components/PlatformSelect/PlatformIcon.tsx @@ -8,6 +8,7 @@ import LogoN64 from "./n64.svg" import LogoNDS from "./nds.svg" import LogoPS1 from "./ps1.svg" import LogoPS2 from "./ps2.svg" +import LogoPSP from "./psp.svg" import LogoSaturn from "./saturn.svg" import LogoSwitch from "./switch.svg" import UnknownIcon from "./unknown.svg" @@ -25,6 +26,7 @@ const ICONS = { "nds_arm9": LogoNDS, "ps1": LogoPS1, "ps2": LogoPS2, + "psp": LogoPSP, "n3ds": LogoN3DS, "switch": LogoSwitch, "saturn": LogoSaturn, diff --git a/frontend/src/components/PlatformSelect/psp.svg b/frontend/src/components/PlatformSelect/psp.svg new file mode 100644 index 000000000..22fd0a4c1 --- /dev/null +++ b/frontend/src/components/PlatformSelect/psp.svg @@ -0,0 +1,4 @@ + + + + diff --git a/frontend/src/lib/i18n/locales/en/compilers.json b/frontend/src/lib/i18n/locales/en/compilers.json index db53150ec..2cb6b5184 100644 --- a/frontend/src/lib/i18n/locales/en/compilers.json +++ b/frontend/src/lib/i18n/locales/en/compilers.json @@ -149,6 +149,11 @@ "psyq4.4-ccpsx": "CCPSX (PSYQ4.4: gcc 2.8.1 + aspsx 2.79)", + "mwccpsp_3.0.1_121": "MWCC 1.0 (3.0.1 121)", + "mwccpsp_3.0.1_147": "MWCC 1.1 (3.0.1 147)", + "mwccpsp_3.0.1_151": "MWCC 1.1 SP1 (3.0.1 151)", + "pspsnc_1.2.7503.0": "SN 1.2.7503.0", + "wcc10.5": "Watcom Optimizing C i386 Compiler 10.5", "wpp10.5": "Watcom Optimizing C++ i386 Compiler 10.5", "wcc10.5a": "Watcom Optimizing C i386 Compiler 10.5a",