diff --git a/.github/workflows/build_netbsd.yml b/.github/workflows/build_netbsd.yml index d108f848b..28fb77810 100644 --- a/.github/workflows/build_netbsd.yml +++ b/.github/workflows/build_netbsd.yml @@ -19,7 +19,9 @@ jobs: steps: - uses: actions/checkout@v3 - name: Install prerequisites - run: apt install wget unzip + run: | + apt-get update + apt-get -y install zip wget - name: Retrieve OpenGL and X11 dev files (64 bit) run: | mkdir src/netbsd64 diff --git a/.github/workflows/build_ps1.yml b/.github/workflows/build_ps1.yml index 674f43eac..3ae3b670b 100644 --- a/.github/workflows/build_ps1.yml +++ b/.github/workflows/build_ps1.yml @@ -39,23 +39,23 @@ jobs: - uses: ./.github/actions/upload_build if: ${{ always() && steps.compile.outcome == 'success' }} with: - SOURCE_FILE: 'misc/ps1/build/template.elf' + SOURCE_FILE: 'misc/ps1/build/ClassiCube.elf' DEST_NAME: 'ClassiCube-PS1.elf' - uses: ./.github/actions/upload_build if: ${{ always() && steps.compile.outcome == 'success' }} with: - SOURCE_FILE: 'misc/ps1/build/template.exe' + SOURCE_FILE: 'misc/ps1/build/ClassiCube.exe' DEST_NAME: 'ClassiCube-PS1.exe' - uses: ./.github/actions/upload_build if: ${{ always() && steps.compile.outcome == 'success' }} with: - SOURCE_FILE: 'misc/ps1/build/template.bin' + SOURCE_FILE: 'misc/ps1/build/ClassiCube.bin' DEST_NAME: 'ClassiCube-PS1.bin' - uses: ./.github/actions/upload_build if: ${{ always() && steps.compile.outcome == 'success' }} with: - SOURCE_FILE: 'misc/ps1/build/template.cue' + SOURCE_FILE: 'misc/ps1/build/ClassiCube.cue' DEST_NAME: 'ClassiCube-PS1.cue' diff --git a/misc/build_scripts/build_server.py b/misc/build_scripts/build_server.py deleted file mode 100644 index d3ea564a3..000000000 --- a/misc/build_scripts/build_server.py +++ /dev/null @@ -1,64 +0,0 @@ -from http.server import HTTPServer, SimpleHTTPRequestHandler -import os -import subprocess - -build_files = { - '/ClassiCube.exe' : 'cc-w32-d3d.exe', '/ClassiCube.opengl.exe' : 'cc-w32-ogl.exe', - '/ClassiCube.64.exe' : 'cc-w64-d3d.exe', '/ClassiCube.64-opengl.exe' : 'cc-w64-ogl.exe', - '/ClassiCube.32' : 'cc-nix32', '/ClassiCube' : 'cc-nix64', - '/ClassiCube.osx' : 'cc-osx32', '/ClassiCube.64.osx' : 'cc-osx64', - '/ClassiCube.js' : 'cc.js', '/ClassiCube.apk' : 'cc.apk', - '/ClassiCube.rpi' : 'cc-rpi', - '/cc-nix32-gl2' : 'cc-nix32-gl2', '/cc-nix64-gl2' : 'cc-nix64-gl2', - '/cc-osx32-gl2' : 'cc-osx32-gl2', '/cc-osx64-gl2' : 'cc-osx64-gl2', -} - -release_files = { - '/win32' : 'win32/ClassiCube.exe', '/win64' : 'win64/ClassiCube.exe', - '/osx32' : 'osx32/ClassiCube.tar.gz', '/osx64' : 'osx64/ClassiCube.tar.gz', - '/mac32' : 'mac32/ClassiCube.tar.gz', '/mac64' : 'mac64/ClassiCube.tar.gz', - '/nix32' : 'nix32/ClassiCube.tar.gz', '/nix64' : 'nix64/ClassiCube.tar.gz', - '/rpi32' : 'rpi32/ClassiCube.tar.gz', -} - -def run_script(file): - args = ["sh", file] - su = subprocess.Popen(args) - return su.wait() - -class Handler(SimpleHTTPRequestHandler): - - def serve_script(self, file, msg): - ret = run_script(file) - self.send_response(200) - self.end_headers() - self.wfile.write(msg % ret) - - def do_GET(self): - if self.path in build_files: - self.serve_exe('client/src/' + build_files[self.path]) - elif self.path in release_files: - self.serve_exe('client/release/' + release_files[self.path]) - elif self.path == '/rebuild': - self.serve_script('build.sh', 'Rebuild client (%s)') - elif self.path == '/release': - self.serve_script('build_release.sh', 'Package release (%s)') - else: - self.send_error(404, "Unknown action") - return - - def serve_exe(self, path): - try: - f = open(path, 'rb') - fs = os.fstat(f.fileno()) - self.send_response(200) - self.send_header("Content-type", "application/octet-stream") - self.send_header("Content-Length", str(fs[6])) - self.end_headers() - self.copyfile(f, self.wfile) - f.close() - except IOError: - self.send_error(404, "File not found") - -httpd = HTTPServer(('', 80), Handler) -httpd.serve_forever() diff --git a/misc/build_scripts/makerelease.sh b/misc/build_scripts/makerelease.sh deleted file mode 100644 index d5ca841f9..000000000 --- a/misc/build_scripts/makerelease.sh +++ /dev/null @@ -1,60 +0,0 @@ -#!/bin/bash - -# paths, change these as needed -SOURCE_DIR=~/client/src -MISC_DIR=~/client/misc -BUILDS_DIR=~/client/release - -# ./ClassiCube -make_nix_tar() { - cp $SOURCE_DIR/$1 ClassiCube - chmod +x ClassiCube - tar -zcvf ClassiCube.tar.gz ClassiCube - rm ClassiCube -} - -# ./ClassiCube.app/Info.plist -# ./ClassiCube.app/Contents/MacOS/ClassiCube -# ./ClassiCube.app/Resources/ClassiCube.icns -make_mac_tar() { - mkdir ClassiCube.app - mkdir ClassiCube.app/Contents - mkdir ClassiCube.app/Contents/MacOS - mkdir ClassiCube.app/Contents/Resources - - cp $SOURCE_DIR/$1 ClassiCube.app/Contents/MacOS/ClassiCube - chmod +x ClassiCube.app/Contents/MacOS/ClassiCube - - cp $MISC_DIR/info.plist ClassiCube.app/Contents/Info.plist - cp $MISC_DIR/CCIcon.icns ClassiCube.app/Contents/Resources/ClassiCube.icns - tar -zcvf ClassiCube.tar.gz ClassiCube.app - rm -rf ClassiCube.app -} - - -mkdir -p $BUILDS_DIR -mkdir -p $BUILDS_DIR/win32 $BUILDS_DIR/win64 $BUILDS_DIR/osx32 $BUILDS_DIR/osx64 -mkdir -p $BUILDS_DIR/nix32 $BUILDS_DIR/nix64 $BUILDS_DIR/mac32 $BUILDS_DIR/mac64 -mkdir -p $BUILDS_DIR/rpi32 - -# edge doesn't respect download attribute, and having ClassiCube.64.exe breaks plugins -cp $SOURCE_DIR/cc-w32-d3d.exe $BUILDS_DIR/win32/ClassiCube.exe -cp $SOURCE_DIR/cc-w64-d3d.exe $BUILDS_DIR/win64/ClassiCube.exe - -# use tar to preserve chmod +x, so users don't have to manually do it -cd $BUILDS_DIR/osx32/ -make_nix_tar cc-osx32 -cd $BUILDS_DIR/osx64/ -make_nix_tar cc-osx64 -cd $BUILDS_DIR/nix32/ -make_nix_tar cc-nix32 -cd $BUILDS_DIR/nix64/ -make_nix_tar cc-nix64 -cd $BUILDS_DIR/rpi32/ -make_nix_tar cc-rpi - -# generate ClassiCube.app for mac users -cd $BUILDS_DIR/mac32/ -make_mac_tar cc-osx32 -cd $BUILDS_DIR/mac64/ -make_mac_tar cc-osx64 diff --git a/misc/build_scripts/notify.py b/misc/build_scripts/notify.py deleted file mode 100644 index e53f89b6b..000000000 --- a/misc/build_scripts/notify.py +++ /dev/null @@ -1,34 +0,0 @@ -import requests, re, datetime, json, time, os -# Any resemblence to any discord bots written by 123DMWM is purely coincidental. I swear. - -# The URL of the discord channel webhook to notify -# You can generate a webhook by right clicking channel -> Edit Channel -> Webhooks -WEBHOOK_URL = '' -# The ID of the user you want to ping on a build failure -# You can get this by right clicking user -> Copy ID -# You may have to go to settings -> Appearance -> Check Developer Mode to see this option -TARGET_USER = '' - -def notify_webhook(body): - try: - webhook_data = { - "username": "CC BuildBot", - "avatar_url": "https://static.classicube.net/img/cc-cube-small.png", - "content" : body - } - - r = requests.post(WEBHOOK_URL, json=webhook_data) - print("BuildNotify response: " + r.text) - except Exception as e: - print("BuildNotify failed: %s" % (e)) - -cc_errors = None -try: - with open(sys.argv[1], 'r') as file: - cc_errors = file.read() -except FileNotFoundError: - # nothing to as no compile errors - pass - -if cc_errors: - notify_webhook('**Houston, we have a problem** <@%s>\n\n%s' % (TARGET_USER, cc_errors)) \ No newline at end of file diff --git a/misc/build_scripts/readme.md b/misc/build_scripts/readme.md index 7bf5e7f97..00304bd3e 100644 --- a/misc/build_scripts/readme.md +++ b/misc/build_scripts/readme.md @@ -2,8 +2,5 @@ This folder contains build scripts for automatically compiling ClassiCube |File|Description| |--------|-------| -|buildbot.sh | Compiles the game to optimised executables (with icons) | |buildbot_plugin.sh | Compiles specified plugin for various platforms | -|buildtestplugin.sh | Example script for how to use buildbot_plugin.sh | -|makerelease.sh | Packages the executables to produce files for a release | -|notify.py | Notifies a user on Discord if buildbot fails | \ No newline at end of file +|buildtestplugin.sh | Example script for how to use buildbot_plugin.sh | \ No newline at end of file diff --git a/misc/build_scripts/upload_build.sh b/misc/build_scripts/upload_build.sh deleted file mode 100644 index ed07e8f6d..000000000 --- a/misc/build_scripts/upload_build.sh +++ /dev/null @@ -1,13 +0,0 @@ -# upload_build.sh [TARGET NAME] [SOURCE FILE] -# e.g. ~/upload_build.sh latest/ClassiCube.ipa cc.ipa -API_URL= -API_KEY= - -if [ -s $2 ]; then - curl $API_URL \ - --header "X-Build-Key:$API_KEY" \ - --header "X-Build-Name:$1" \ - --data-binary @$2 -else - echo "Missing or empty file: $2" -fi diff --git a/misc/ps1/CMakeLists.txt b/misc/ps1/CMakeLists.txt index 1f78b62a4..54550b575 100644 --- a/misc/ps1/CMakeLists.txt +++ b/misc/ps1/CMakeLists.txt @@ -11,11 +11,11 @@ project( add_definitions(-DPLAT_PS1) file(GLOB _sources ../../src/*.c) -psn00bsdk_add_executable(template GPREL ${_sources}) +psn00bsdk_add_executable(ClassiCube GPREL ${_sources}) psn00bsdk_add_cd_image( - iso # Target name - template # Output file name (= template.bin + template.cue) - iso.xml # Path to config file - DEPENDS template system.cnf + iso # Target name + ClassiCube # Output file name (= ClassiCube.bin + ClassiCube.cue) + iso.xml # Path to config file + DEPENDS ClassiCube system.cnf ) diff --git a/misc/ps1/system.cnf b/misc/ps1/system.cnf index e22172615..873e9128c 100644 --- a/misc/ps1/system.cnf +++ b/misc/ps1/system.cnf @@ -1,4 +1,4 @@ -BOOT=cdrom:\template.exe;1 +BOOT=cdrom:\ClassiCube.exe;1 TCB=4 EVENT=10 STACK=801FFFF0 diff --git a/misc/linux/CCIcon_X11.h b/misc/x11/CCIcon_X11.h similarity index 99% rename from misc/linux/CCIcon_X11.h rename to misc/x11/CCIcon_X11.h index 1f4996265..04a75c12c 100644 --- a/misc/linux/CCIcon_X11.h +++ b/misc/x11/CCIcon_X11.h @@ -1,4 +1,4 @@ -/* Generated using misc/linux_icon_gen.cs */ +/* Generated using misc/x11_icon_gen.cs */ static const unsigned long CCIcon_Data[] = { 64,64, diff --git a/misc/x11/linux/flatpak/net.classicube.flatpak.client.SDL3.json b/misc/x11/linux/flatpak/net.classicube.flatpak.client.SDL3.json new file mode 100644 index 000000000..5c75fad61 --- /dev/null +++ b/misc/x11/linux/flatpak/net.classicube.flatpak.client.SDL3.json @@ -0,0 +1,78 @@ +{ + "id": "net.classicube.flatpak.client", + "runtime": "org.freedesktop.Platform", + "runtime-version": "23.08", + "sdk": "org.freedesktop.Sdk", + "command": "ClassiCubeLauncher", + "finish-args": [ + "--socket=wayland", + "--socket=fallback-x11", + "--device=dri", + "--share=network", + "--share=ipc", + "--socket=pulseaudio" + ], + "modules": [ + { + "name": "SDL3", + "buildsystem": "cmake-ninja", + "builddir": true, + "sources": [ + { + "type": "git", + "url": "https://github.com/libsdl-org/SDL.git", + "branch": "main" + } + ], + "cleanup": [ + "/bin/sdl3-config", + "/include", + "/lib/libSDL3.la", + "/lib/libSDL3main.a", + "/lib/libSDL3main.la", + "/lib/libSDL3_test.a", + "/lib/libSDL3_test.la", + "/lib/cmake", + "/share/aclocal", + "/lib/pkgconfig" + ], + "modules": [ + { + "name": "libdecor", + "buildsystem": "meson", + "config-opts": [ + "-Ddemo=false" + ], + "sources": [ + { + "type": "git", + "url": "https://gitlab.freedesktop.org/libdecor/libdecor.git" + } + ], + "cleanup": [ + "/include", + "/lib/pkgconfig" + ] + } + ] + }, + { + "name": "ClassiCube", + "buildsystem": "simple", + "build-commands": [ + "gcc -fno-math-errno src/*.c -o src/ClassiCube -rdynamic -lpthread -lGL -DCC_WIN_BACKEND=CC_WIN_BACKEND_SDL3 -DCC_GFX_BACKEND=CC_GFX_BACKEND_GL2 -DCC_BUILD_FLATPAK -L /app/lib -lSDL3", + "install -Dm755 src/ClassiCube -t ${FLATPAK_DEST}/bin", + "install -Dm755 misc/linux/flatpak/ClassiCubeLauncher -t ${FLATPAK_DEST}/bin", + "install -Dm644 misc/linux/flatpak/net.classicube.flatpak.client.svg ${FLATPAK_DEST}/share/icons/hicolor/scalable/apps/net.classicube.flatpak.client.svg", + "install -Dm644 misc/linux/flatpak/net.classicube.flatpak.client.desktop ${FLATPAK_DEST}/share/applications/net.classicube.flatpak.client.desktop", + "install -Dm644 misc/linux/flatpak/net.classicube.flatpak.client.metainfo.xml ${FLATPAK_DEST}/share/metainfo/net.classicube.flatpak.client.metainfo.xml" + ], + "sources": [ + { + "type": "git", + "url": "https://github.com/ClassiCube/ClassiCube.git" + } + ] + } + ] +} \ No newline at end of file diff --git a/misc/x11/linux/flatpak/net.classicube.flatpak.client.X11.json b/misc/x11/linux/flatpak/net.classicube.flatpak.client.X11.json new file mode 100644 index 000000000..e064afac8 --- /dev/null +++ b/misc/x11/linux/flatpak/net.classicube.flatpak.client.X11.json @@ -0,0 +1,34 @@ +{ + "id": "net.classicube.flatpak.client", + "runtime": "org.freedesktop.Platform", + "runtime-version": "23.08", + "sdk": "org.freedesktop.Sdk", + "command": "ClassiCubeLauncher", + "finish-args": [ + "--socket=x11", + "--device=dri", + "--share=network", + "--share=ipc", + "--socket=pulseaudio" + ], + "modules": [ + { + "name": "ClassiCube", + "buildsystem": "simple", + "build-commands": [ + "gcc -fno-math-errno src/*.c -o src/ClassiCube -O1 -DCC_BUILD_FLATPAK -DCC_GFX_BACKEND=CC_GFX_BACKEND_GL2 -rdynamic -lm -lpthread -lX11 -lXi -lGL -ldl", + "install -Dm755 src/ClassiCube -t ${FLATPAK_DEST}/bin", + "install -Dm755 misc/linux/flatpak/ClassiCubeLauncher -t ${FLATPAK_DEST}/bin", + "install -Dm644 misc/linux/flatpak/net.classicube.flatpak.client.svg ${FLATPAK_DEST}/share/icons/hicolor/scalable/apps/net.classicube.flatpak.client.svg", + "install -Dm644 misc/linux/flatpak/net.classicube.flatpak.client.desktop ${FLATPAK_DEST}/share/applications/net.classicube.flatpak.client.desktop", + "install -Dm644 misc/linux/flatpak/net.classicube.flatpak.client.metainfo.xml ${FLATPAK_DEST}/share/metainfo/net.classicube.flatpak.client.metainfo.xml" + ], + "sources": [ + { + "type": "git", + "url": "https://github.com/ClassiCube/ClassiCube.git" + } + ] + } + ] +} \ No newline at end of file diff --git a/misc/x11/linux/flatpak/net.classicube.flatpak.client.desktop b/misc/x11/linux/flatpak/net.classicube.flatpak.client.desktop new file mode 100644 index 000000000..11f416da3 --- /dev/null +++ b/misc/x11/linux/flatpak/net.classicube.flatpak.client.desktop @@ -0,0 +1,10 @@ +[Desktop Entry] +Name=ClassiCube +Exec=ClassiCubeLauncher +Comment=Sandbox building-block game +Type=Application +Icon=net.classicube.flatpak.client +Categories=Game;ActionGame; +Terminal=false +MimeType=x-scheme-handler/mc; +StartupWMClass=net.classicube.flatpak.client \ No newline at end of file diff --git a/misc/x11/linux/flatpak/net.classicube.flatpak.client.metainfo.xml b/misc/x11/linux/flatpak/net.classicube.flatpak.client.metainfo.xml new file mode 100644 index 000000000..7810cb367 --- /dev/null +++ b/misc/x11/linux/flatpak/net.classicube.flatpak.client.metainfo.xml @@ -0,0 +1,133 @@ + + + net.classicube.flatpak.client + ClassiCube + Sandbox building-block game + + The ClassiCube Project + + CC0-1.0 + BSD-3-Clause + +

ClassiCube brings you back to the days of 2009 where one block game ruled them all, it includes such features as:

+ +
+ + + Classic mode features faithful classic gameplay + https://github.com/ClassiCube/ClassiCube/assets/6509348/eedee53f-f53e-456f-b51c-92c62079eee0 + + + Enhanced mode allows hacks like flying and noclipping, it also allows servers to provide many custom features + https://github.com/ClassiCube/ClassiCube/assets/6509348/b2fe0e2b-5d76-41ab-909f-048d0ad15f37 + + + + + https://github.com/ClassiCube/ClassiCube/releases/tag/1.3.6 + + + https://github.com/ClassiCube/ClassiCube/releases/tag/1.3.5 + + + https://github.com/ClassiCube/ClassiCube/releases/tag/1.3.4 + + + https://github.com/ClassiCube/ClassiCube/releases/tag/1.3.3 + + + https://github.com/ClassiCube/ClassiCube/releases/tag/1.3.2 + + + https://github.com/ClassiCube/ClassiCube/releases/tag/1.3.1 + + + https://github.com/ClassiCube/ClassiCube/releases/tag/1.3.0 + + + https://github.com/ClassiCube/ClassiCube/releases/tag/1.2.9 + + + https://github.com/ClassiCube/ClassiCube/releases/tag/1.2.8 + + + https://github.com/ClassiCube/ClassiCube/releases/tag/1.2.7 + + + https://github.com/ClassiCube/ClassiCube/releases/tag/1.2.6 + + + https://github.com/ClassiCube/ClassiCube/releases/tag/1.2.5 + + + https://github.com/ClassiCube/ClassiCube/releases/tag/1.2.4 + + + https://github.com/ClassiCube/ClassiCube/releases/tag/1.2.3 + + + https://github.com/ClassiCube/ClassiCube/releases/tag/1.2.2 + + + https://github.com/ClassiCube/ClassiCube/releases/tag/1.2.1 + + + https://github.com/ClassiCube/ClassiCube/releases/tag/1.2.0 + + + https://github.com/ClassiCube/ClassiCube/releases/tag/1.1.9 + + + https://github.com/ClassiCube/ClassiCube/releases/tag/1.1.8 + + + https://github.com/ClassiCube/ClassiCube/releases/tag/1.1.7 + + + https://github.com/ClassiCube/ClassiCube/releases/tag/1.1.6 + + + https://github.com/ClassiCube/ClassiCube/releases/tag/1.1.5 + + + https://github.com/ClassiCube/ClassiCube/releases/tag/1.1.4 + + + https://github.com/ClassiCube/ClassiCube/releases/tag/1.1.3 + + + https://github.com/ClassiCube/ClassiCube/releases/tag/1.1.2 + + + https://github.com/ClassiCube/ClassiCube/releases/tag/1.1.1 + + + https://www.classicube.net/ + https://github.com/ClassiCube/ClassiCube/issues + https://www.patreon.com/ClassiCube + https://github.com/ClassiCube/ClassiCube + + Game + AdventureGame + ActionGame + + + pointing + keyboard + + + moderate + intense + + net.classicube.flatpak.client.desktop + + ClassiCube + +
diff --git a/misc/x11/linux/flatpak/net.classicube.flatpak.client.svg b/misc/x11/linux/flatpak/net.classicube.flatpak.client.svg new file mode 100644 index 000000000..44324156b --- /dev/null +++ b/misc/x11/linux/flatpak/net.classicube.flatpak.client.svg @@ -0,0 +1,44 @@ + + + + + + + + + image/svg+xml + + + + + + + + + + + diff --git a/misc/x11/linux/install-desktop-entry.sh b/misc/x11/linux/install-desktop-entry.sh new file mode 100644 index 000000000..a3c3ab7c5 --- /dev/null +++ b/misc/x11/linux/install-desktop-entry.sh @@ -0,0 +1,34 @@ +DESKTOP_FILE=ClassiCube.desktop +GAME_DIR=`pwd` + +# remove existing ClassiCube desktop entry file +rm $DESKTOP_FILE + +# download ClassiCube icon from github if necessary +if [ -f "CCicon.png" ] +then + echo "CCicon.png exists already. Skipping download." +else + echo "CCicon.png doesn't exist. Attempting to download it.." + wget "https://raw.githubusercontent.com/ClassiCube/classicube/master/misc/CCicon.png" +fi + +# create ClassiCube desktop entry +echo 'Creating ClassiCube.desktop..' +cat >> $DESKTOP_FILE << EOF +[Desktop Entry] +Type=Application +Comment=Minecraft Classic inspired sandbox game +Name=ClassiCube +Exec=$GAME_DIR/ClassiCube +Icon=$GAME_DIR/CCicon.png +Path=$GAME_DIR +Terminal=false +Categories=Game +EOF +chmod +x $DESKTOP_FILE + +echo 'Installing ClassiCube.desktop..' +# install ClassiCube desktop entry into the system +sudo desktop-file-install --dir=/usr/share/applications ClassiCube.desktop +sudo update-desktop-database /usr/share/applications diff --git a/misc/linux/min-X.h b/misc/x11/min-X.h similarity index 100% rename from misc/linux/min-X.h rename to misc/x11/min-X.h diff --git a/misc/linux/min-XF86keysym.h b/misc/x11/min-XF86keysym.h similarity index 100% rename from misc/linux/min-XF86keysym.h rename to misc/x11/min-XF86keysym.h diff --git a/misc/linux/min-glx.h b/misc/x11/min-glx.h similarity index 100% rename from misc/linux/min-glx.h rename to misc/x11/min-glx.h diff --git a/misc/linux/min-keysymdef.h b/misc/x11/min-keysymdef.h similarity index 100% rename from misc/linux/min-keysymdef.h rename to misc/x11/min-keysymdef.h diff --git a/misc/linux/min-xinput2.h b/misc/x11/min-xinput2.h similarity index 100% rename from misc/linux/min-xinput2.h rename to misc/x11/min-xinput2.h diff --git a/misc/linux/min-xkblib.h b/misc/x11/min-xkblib.h similarity index 100% rename from misc/linux/min-xkblib.h rename to misc/x11/min-xkblib.h diff --git a/misc/linux/min-xlib.h b/misc/x11/min-xlib.h similarity index 100% rename from misc/linux/min-xlib.h rename to misc/x11/min-xlib.h diff --git a/misc/linux/min-xutil.h b/misc/x11/min-xutil.h similarity index 100% rename from misc/linux/min-xutil.h rename to misc/x11/min-xutil.h diff --git a/misc/linux/linux_icon_gen.cs b/misc/x11/x11_icon_gen.cs similarity index 100% rename from misc/linux/linux_icon_gen.cs rename to misc/x11/x11_icon_gen.cs diff --git a/src/Graphics_PS1.c b/src/Graphics_PS1.c index d24f80678..1025ffcef 100644 --- a/src/Graphics_PS1.c +++ b/src/Graphics_PS1.c @@ -363,8 +363,41 @@ void Gfx_DeleteIb(GfxResourceID* ib) { } /*########################################################################################################################* *-------------------------------------------------------Vertex buffers----------------------------------------------------* *#########################################################################################################################*/ +// Preprocess vertex buffers into optimised layout for PS1 +struct PS1VertexTextured { float x, y, z; PackedCol Col; int u, v; }; +static VertexFormat buf_fmt; +static int buf_count; + static void* gfx_vertices; +static int ToUVFixed(float value) { + return ((int)(value * 1024.0f) & 0x3FF); // U/V wrapping not supported +} + +static void PreprocessTexturedVertices(void) { + struct PS1VertexTextured* dst = gfx_vertices; + struct VertexTextured* src = gfx_vertices; + + // PS1 need to use raw U/V coordinates + // i.e. U = (src->U * tex->width) % tex->width + // To avoid expensive floating point conversions, + // convert the U coordinates to fixed point + // (using 10 bits for the fractional coordinate) + // Converting from fixed point using 1024 as base + // to tex->width/height as base is relatively simple: + // value / 1024 = X / tex_size + // X = value * tex_size / 1024 + for (int i = 0; i < buf_count; i++, src++, dst++) + { + dst->u = ToUVFixed(src->U * 0.99f); + dst->v = ToUVFixed(src->V ); + } +} + +static void PreprocessColouredVertices(void) { +} + + static GfxResourceID Gfx_AllocStaticVb(VertexFormat fmt, int count) { return Mem_TryAlloc(count, strideSizes[fmt]); } @@ -378,11 +411,19 @@ void Gfx_DeleteVb(GfxResourceID* vb) { } void* Gfx_LockVb(GfxResourceID vb, VertexFormat fmt, int count) { + buf_fmt = fmt; + buf_count = count; return vb; } void Gfx_UnlockVb(GfxResourceID vb) { - gfx_vertices = vb; + gfx_vertices = vb; + + if (buf_fmt == VERTEX_FORMAT_TEXTURED) { + PreprocessTexturedVertices(); + } else { + PreprocessColouredVertices(); + } } @@ -393,16 +434,15 @@ static GfxResourceID Gfx_AllocDynamicVb(VertexFormat fmt, int maxVertices) { void Gfx_BindDynamicVb(GfxResourceID vb) { Gfx_BindVb(vb); } void* Gfx_LockDynamicVb(GfxResourceID vb, VertexFormat fmt, int count) { - return vb; + return Gfx_LockVb(vb, fmt, count); } -void Gfx_UnlockDynamicVb(GfxResourceID vb) { - gfx_vertices = vb; -} +void Gfx_UnlockDynamicVb(GfxResourceID vb) { Gfx_UnlockVb(vb); } void Gfx_DeleteDynamicVb(GfxResourceID* vb) { Gfx_DeleteVb(vb); } + /*########################################################################################################################* *---------------------------------------------------------Matrices--------------------------------------------------------* *#########################################################################################################################*/ @@ -417,11 +457,11 @@ static void LoadTransformMatrix(struct Matrix* src) { mtx.t[1] = ToFixed(src->row4.y); mtx.t[2] = ToFixed(src->row4.z); - Platform_Log3("X: %f3, Y: %f3, Z: %f3", &src->row1.x, &src->row1.y, &src->row1.z); - Platform_Log3("X: %f3, Y: %f3, Z: %f3", &src->row2.x, &src->row2.y, &src->row2.z); - Platform_Log3("X: %f3, Y: %f3, Z: %f3", &src->row3.x, &src->row3.y, &src->row3.z); - Platform_Log3("X: %f3, Y: %f3, Z: %f3", &src->row4.x, &src->row4.y, &src->row4.z); - Platform_LogConst("===="); + //Platform_Log3("X: %f3, Y: %f3, Z: %f3", &src->row1.x, &src->row1.y, &src->row1.z); + //Platform_Log3("X: %f3, Y: %f3, Z: %f3", &src->row2.x, &src->row2.y, &src->row2.z); + //Platform_Log3("X: %f3, Y: %f3, Z: %f3", &src->row3.x, &src->row3.y, &src->row3.z); + //Platform_Log3("X: %f3, Y: %f3, Z: %f3", &src->row4.x, &src->row4.y, &src->row4.z); + //Platform_LogConst("===="); mtx.m[0][0] = ToFixed(src->row1.x); mtx.m[0][1] = ToFixed(src->row1.y); @@ -548,7 +588,7 @@ static void DrawTexturedQuads2D(int verticesCount, int startVertex) { for (int i = 0; i < verticesCount; i += 4) { - struct VertexTextured* v = (struct VertexTextured*)gfx_vertices + startVertex + i; + struct PS1VertexTextured* v = (struct PS1VertexTextured*)gfx_vertices + startVertex + i; POLY_FT4* poly = new_primitive(sizeof(POLY_FT4)); setPolyFT4(poly); @@ -561,14 +601,14 @@ static void DrawTexturedQuads2D(int verticesCount, int startVertex) { poly->x2 = v[2].x; poly->y2 = v[2].y; poly->x3 = v[3].x; poly->y3 = v[3].y; - poly->u0 = ((int)(v[1].U * 0.99f * curTex->width) & curTex->width_mask) + uOffset; - poly->v0 = ((int)(v[1].V * curTex->height) & curTex->height_mask) + vOffset; - poly->u1 = ((int)(v[0].U * 0.99f * curTex->width) & curTex->width_mask) + uOffset; - poly->v1 = ((int)(v[0].V * curTex->height) & curTex->height_mask) + vOffset; - poly->u2 = ((int)(v[2].U * 0.99f * curTex->width) & curTex->width_mask) + uOffset; - poly->v2 = ((int)(v[2].V * curTex->height) & curTex->height_mask) + vOffset; - poly->u3 = ((int)(v[3].U * 0.99f * curTex->width) & curTex->width_mask) + uOffset; - poly->v3 = ((int)(v[3].V * curTex->height) & curTex->height_mask) + vOffset; + poly->u0 = ((v[1].u * curTex->width) >> 10) + uOffset; + poly->v0 = ((v[1].v * curTex->height) >> 10) + vOffset; + poly->u1 = ((v[0].u * curTex->width) >> 10) + uOffset; + poly->v1 = ((v[0].v * curTex->height) >> 10) + vOffset; + poly->u2 = ((v[2].u * curTex->width) >> 10) + uOffset; + poly->v2 = ((v[2].v * curTex->height) >> 10) + vOffset; + poly->u3 = ((v[3].u * curTex->width) >> 10) + uOffset; + poly->v3 = ((v[3].v * curTex->height) >> 10) + vOffset; // https://problemkaputt.de/psxspx-gpu-rendering-attributes.htm // "For untextured graphics, 8bit RGB values of FFh are brightest. However, for texture blending, 8bit values of 80h are brightest" @@ -625,7 +665,7 @@ static void DrawTexturedQuads3D(int verticesCount, int startVertex) { for (int i = 0; i < verticesCount; i += 4) { - struct VertexTextured* v = (struct VertexTextured*)gfx_vertices + startVertex + i; + struct PS1VertexTextured* v = (struct PS1VertexTextured*)gfx_vertices + startVertex + i; POLY_FT4* poly = new_primitive(sizeof(POLY_FT4)); setPolyFT4(poly); @@ -651,14 +691,14 @@ static void DrawTexturedQuads3D(int verticesCount, int startVertex) { if (signA > signB) continue; } - poly->u0 = ((int)(v[1].U * curTex->width) & curTex->width_mask) + uOffset; - poly->v0 = ((int)(v[1].V * curTex->height) & curTex->height_mask) + vOffset; - poly->u1 = ((int)(v[0].U * curTex->width) & curTex->width_mask) + uOffset; - poly->v1 = ((int)(v[0].V * curTex->height) & curTex->height_mask) + vOffset; - poly->u2 = ((int)(v[2].U * curTex->width) & curTex->width_mask) + uOffset; - poly->v2 = ((int)(v[2].V * curTex->height) & curTex->height_mask) + vOffset; - poly->u3 = ((int)(v[3].U * curTex->width) & curTex->width_mask) + uOffset; - poly->v3 = ((int)(v[3].V * curTex->height) & curTex->height_mask) + vOffset; + poly->u0 = ((v[1].u * curTex->width) >> 10) + uOffset; + poly->v0 = ((v[1].v * curTex->height) >> 10) + vOffset; + poly->u1 = ((v[0].u * curTex->width) >> 10) + uOffset; + poly->v1 = ((v[0].v * curTex->height) >> 10) + vOffset; + poly->u2 = ((v[2].u * curTex->width) >> 10) + uOffset; + poly->v2 = ((v[2].v * curTex->height) >> 10) + vOffset; + poly->u3 = ((v[3].u * curTex->width) >> 10) + uOffset; + poly->v3 = ((v[3].v * curTex->height) >> 10) + vOffset; //int P = curTex->height, page = poly->tpage & 0xFF, ll = curTex->yOffset; //Platform_Log4("XYZ: %f3 x %i, %i, %i", &v[0].V, &P, &page, &ll); diff --git a/src/Graphics_Saturn.c b/src/Graphics_Saturn.c index 6893b375d..6705a581e 100644 --- a/src/Graphics_Saturn.c +++ b/src/Graphics_Saturn.c @@ -237,7 +237,7 @@ void Gfx_DeleteIb(GfxResourceID* ib) { } /*########################################################################################################################* *-------------------------------------------------------Vertex buffers----------------------------------------------------* *#########################################################################################################################*/ -// Preprocess vertex buffers into optimised layout for DS +// Preprocess vertex buffers into optimised layout for Saturn static VertexFormat buf_fmt; static int buf_count; diff --git a/src/Window_X11.c b/src/Window_X11.c index 8872271ec..4c7528d9e 100644 --- a/src/Window_X11.c +++ b/src/Window_X11.c @@ -16,12 +16,12 @@ #include #endif */ -#include "../misc/linux/min-xlib.h" -#include "../misc/linux/min-keysymdef.h" -#include "../misc/linux/min-xutil.h" -#include "../misc/linux/min-xkblib.h" -#include "../misc/linux/min-xinput2.h" -#include "../misc/linux/min-XF86keysym.h" +#include "../misc/x11/min-xlib.h" +#include "../misc/x11/min-keysymdef.h" +#include "../misc/x11/min-xutil.h" +#include "../misc/x11/min-xkblib.h" +#include "../misc/x11/min-xinput2.h" +#include "../misc/x11/min-XF86keysym.h" #include #ifdef X_HAVE_UTF8_STRING @@ -318,8 +318,8 @@ void Window_Init(void) { void Window_Free(void) { } #ifdef CC_BUILD_ICON -/* See misc/linux/linux_icon_gen.cs for how to generate this file */ -#include "../misc/linux/CCIcon_X11.h" +/* See misc/x11/x11_icon_gen.cs for how to generate this file */ +#include "../misc/x11/CCIcon_X11.h" static void ApplyIcon(void) { Atom net_wm_icon = XInternAtom(win_display, "_NET_WM_ICON", false);