Repository: paolomainardi/additronk8s-retrogames-kubernetes-controller Branch: main Commit: 2709dd2aff4c Files: 32 Total size: 82.7 KB Directory structure: gitextract_hq6e478a/ ├── .github/ │ └── workflows/ │ ├── build-controller.yaml │ └── build-engine.yml ├── .gitignore ├── LICENSE ├── Makefile ├── README.md ├── game-engine/ │ ├── .dockerignore │ ├── Dockerfile │ ├── conf/ │ │ ├── client.conf │ │ ├── default.pa │ │ ├── dosbox/ │ │ │ ├── dosbox.cli.conf.template │ │ │ └── dosbox.conf.template │ │ ├── novnc/ │ │ │ ├── background_patch.diff │ │ │ └── vnc_lite.html │ │ ├── supervisord.conf │ │ └── webaudio.js │ ├── entrypoint.sh │ └── run.sh ├── k8s/ │ ├── manifests/ │ │ ├── crd-game-controller.yml │ │ ├── game-controller-cluster-role-binding.yml │ │ ├── game-controller-cluster-role.yml │ │ ├── game-controller-sa.yml │ │ ├── game-controller.yaml │ │ └── namespace.yml │ └── src/ │ └── game-controller/ │ ├── Dockerfile │ ├── index.js │ ├── lib/ │ │ ├── api-machinery.js │ │ ├── crd-informer.js │ │ ├── game-engine.js │ │ └── util.js │ └── package.json └── skaffold.yml ================================================ FILE CONTENTS ================================================ ================================================ FILE: .github/workflows/build-controller.yaml ================================================ name: build-controller on: pull_request: branches: main push: branches: main tags: - v* jobs: buildx: runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@v2 - name: Prepare id: prepare run: | DOCKER_IMAGE=ghcr.io/paolomainardi/additronk8s-game-controller DOCKER_PLATFORMS=linux/amd64,linux/arm/v7,linux/arm64 DOCKERFILE_PATH=./k8s/src/game-controller VERSION=latest if [[ $GITHUB_REF == refs/tags/* ]]; then VERSION=${GITHUB_REF#refs/tags/v} fi if [ "${{ github.event_name }}" = "schedule" ]; then VERSION=nightly fi TAGS="--tag ${DOCKER_IMAGE}:${VERSION}" if [[ $VERSION =~ ^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; then TAGS="$TAGS --tag ${DOCKER_IMAGE}:latest" fi echo ::set-output name=docker_image::${DOCKER_IMAGE} echo ::set-output name=version::${VERSION} echo ::set-output name=buildx_args::--platform ${DOCKER_PLATFORMS} \ --build-arg VERSION=${VERSION} \ --build-arg BUILD_DATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ') \ --build-arg VCS_REF=${GITHUB_SHA::8} \ ${TAGS} --file ${DOCKERFILE_PATH}/Dockerfile ${DOCKERFILE_PATH} - name: Set up QEMU uses: docker/setup-qemu-action@v1 - name: Set up Docker Buildx uses: docker/setup-buildx-action@v1 - name: Docker Buildx (build) run: | docker buildx build --output "type=image,push=false" ${{ steps.prepare.outputs.buildx_args }} - name: Log into GitHub Container Registry run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login https://ghcr.io -u ${{ github.actor }} --password-stdin - name: Docker Buildx (push) if: success() && github.event_name != 'pull_request' run: | docker buildx build --output "type=image,push=true" ${{ steps.prepare.outputs.buildx_args }} - name: Inspect image if: always() && github.event_name != 'pull_request' run: | docker buildx imagetools inspect ${{ steps.prepare.outputs.docker_image }}:${{ steps.prepare.outputs.version }} ================================================ FILE: .github/workflows/build-engine.yml ================================================ name: build-engine on: pull_request: branches: main push: branches: main tags: - v* jobs: buildx: runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@v2 - name: Prepare id: prepare run: | DOCKER_IMAGE=ghcr.io/paolomainardi/additronk8s-game-engine DOCKER_PLATFORMS=linux/amd64,linux/arm/v7,linux/arm64 DOCKERFILE_PATH=./game-engine VERSION=latest if [[ $GITHUB_REF == refs/tags/* ]]; then VERSION=${GITHUB_REF#refs/tags/v} fi if [ "${{ github.event_name }}" = "schedule" ]; then VERSION=nightly fi TAGS="--tag ${DOCKER_IMAGE}:${VERSION}" if [[ $VERSION =~ ^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; then TAGS="$TAGS --tag ${DOCKER_IMAGE}:latest" fi echo ::set-output name=docker_image::${DOCKER_IMAGE} echo ::set-output name=version::${VERSION} echo ::set-output name=buildx_args::--platform ${DOCKER_PLATFORMS} \ --build-arg VERSION=${VERSION} \ --build-arg BUILD_DATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ') \ --build-arg VCS_REF=${GITHUB_SHA::8} \ ${TAGS} --file ${DOCKERFILE_PATH}/Dockerfile ${DOCKERFILE_PATH} - name: Set up QEMU uses: docker/setup-qemu-action@v1 - name: Set up Docker Buildx uses: docker/setup-buildx-action@v1 - name: Docker Buildx (build) run: | docker buildx build --output "type=image,push=false" ${{ steps.prepare.outputs.buildx_args }} - name: Log into GitHub Container Registry run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login https://ghcr.io -u ${{ github.actor }} --password-stdin - name: Docker Buildx (push) if: success() && github.event_name != 'pull_request' run: | docker buildx build --output "type=image,push=true" ${{ steps.prepare.outputs.buildx_args }} - name: Inspect image if: always() && github.event_name != 'pull_request' run: | docker buildx imagetools inspect ${{ steps.prepare.outputs.docker_image }}:${{ steps.prepare.outputs.version }} ================================================ FILE: .gitignore ================================================ games node_modules ================================================ FILE: LICENSE ================================================ Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS APPENDIX: How to apply the Apache License to your work. To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. Copyright [yyyy] [name of copyright owner] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ================================================ FILE: Makefile ================================================ all: run SHELL := /bin/bash ifndef GAME_DIR GAME_DIR=MONKEY_FLOPPY endif ifndef GAME_EXE GAME_EXE=MONEY.EXE endif build-game-engine: docker build -t ghcr.io/paolomainardi/additronk8s-game-engine:latest game-engine kind-load-game-engine: build-game-engine kind load docker-image ghcr.io/paolomainardi/additronk8s-game-engine:latest --name retrogames-k8s-dev run-game-engine: build ./game-engine/run.sh run: create-kind-cluster kind-load-game-engine skaffold run -n games --tail dev: kind-load-game-engine skaffold dev -n games --tail create-kind-cluster: kind delete cluster --name retrogames-k8s-dev || true kind create cluster --name retrogames-k8s-dev ================================================ FILE: README.md ================================================ # AdditronK8S [](https://github.com/paolomainardi/additronk8s-retrogames-kubernetes-controller/actions/workflows/build-controller.yaml) [](https://github.com/paolomainardi/additronk8s-retrogames-kubernetes-controller/actions/workflows/build-engine.yml) ## Description AdditronK8S is a retro game machine build as a Kubernetes custom controller and implemented in Javascript. > The name `Additron` is a tribute to the great inventor and scientist [Josef Kates](https://en.wikipedia.org/wiki/Josef_Kates) who invented the [**first digital playing machine**](https://en.wikipedia.org/wiki/Bertie_the_Brain) to showcase his Additron tube invention. I did this as a PoC [for a company talk](https://www2.slideshare.net/sparkfabrik/retro-gaming-machine-made-with-javascript-and-kubernetes) [(Video)](https://youtu.be/XlhSCWzgQ4k), to demonstrate how **powerful** can be the **Kubernetes APIs** when used also to build custom applications. I chose to use **Javascript** as it is an **officially supported client** and also because I didn't find any project a bit more complex than a simple hello world, to implement a custom controller. > Personal note: When developing for Kubernetes, you have to deal with tons of REST APIs and complex relationship between them, this is where the GO ecosystem shines, you have framework and abstractions used to build Kubernetes itself and you are sure to use top-notch quality code; so if you plan to implement something serious with Kubernetes, my advice is to use GO as a first class citizen language of your system. One of the goal of this project was to use just **Kubernetes API without any external dependency** (neither the storage), infact is noteworthy that `Configmaps` are (ab)used as a persistent storage layer, using a simple technique of split/merge parts of files to save the games. How it works (hand written schematic):  See it in action: [](https://asciinema.org/a/yuUCC0i5BizfRPYoSBcGAP4Sc) Here you can find the slides of my talk: https://www2.slideshare.net/sparkfabrik/retro-gaming-machine-made-with-javascript-and-kubernetes ## Technology This project consists of 3 main components: 1. A Docker image to run games based on Dosbox + [noVNC + Pulseaudio/gStreamer](https://github.com/novnc/noVNC/issues/302) 2. A Javascript Kubernetes custom controller who implements the CRD and the needed logic to run the games. 3. A K3d Kubernetes cluster and Skaffold to manage it. > WARNING: The code is not even close to be production ready, it is just a quick PoC to build a custom controller in Javascript. ## Quick start You just need a working k8s cluster, with a working external connection. To install it from the root, run the following commands: ```shell kubectl apply -f k8s/manifests/namespace.yml kubectl -n games apply -f k8s/manifests/crd-game-controller.yml kubectl -n games apply -f k8s/manifests/game-controller-sa.yml kubectl -n games apply -f k8s/manifests/game-controller-cluster-role.yml kubectl -n games apply -f k8s/manifests/game-controller-cluster-role-binding.yml kubectl -n games apply -f k8s/manifests/game-controller.yaml ``` Now you can run a demo game to test if everything is working as expected: ```shell kubectl -n games apply -f k8s/games/quake.yml ``` > You can also tail the logs of the game-controller to ensure that it was successful > in processing the location of your game zip file. > ```shell > kubectl -n games logs deployment/game-controller -f > ``` Once you have the game up and running, you can access via the web browser by proxying the game service, like this: ``` kubectl -n games port-forward svc/quake 8080:8080 8081:8081 ``` Finally you can access the game console on: `https://localhost:8080` At this stage you will be presented with the dosbox command line and the command to run to execute the game. > *IMPORTANT*: To start the audio websocket, before to start the game and inside the > dosbox cli, you have to press `ALT + s` this will start once the needed websocket, > to transport the audio from the pulseaudio server to your browser. ## Games Files can be downloaded from any public http endpoint or from any public GCP cloud storage bucket. The expect manifest to run a game is this: ```yaml apiVersion: retro.sparkfabrik.com/v1 kind: Game metadata: name: game-name spec: name: "Game name human friendly" zipUrl: "gs://my-gs-bucket/game.zip" dir: "GAME" exe: "GAME.EXE" ``` Where `dir` represent the directory of the unzipped game and `exe` the binary to run. To be clear, this is a structure we expect: ``` unzip game.zip > GAME - GAME.EXE - SOUND.MOD - VIDEO.MOD ``` ### Development The development environment is based on `k3d` and `skaffold`, by running `make dev` you will have end up with: 1. A k3d kubernetes cluster 2. Docker images loaded into the k3d cluster 3. Game controller up and running with live-reload in case of code changes ## References * [Retro DOS Games on Kubernetes:](https://www.virtuallyghetto.com/2021/02/retro-dos-games-on-kubernetes.html) many thanks to [William Lam](https://twitter.com/lamw) for this great write-up. ================================================ FILE: game-engine/.dockerignore ================================================ games ================================================ FILE: game-engine/Dockerfile ================================================ FROM debian:10.7 ENV LANG=en_US.UTF-8 LANGUAGE=en_US.UTF-8 LC_ALL=C.UTF-8 DISPLAY=:0.0 # Install dependencies. RUN apt-get update \ && DEBIAN_FRONTEND=noninteractive apt-get install --yes --no-install-recommends \ bzip2 \ gstreamer1.0-plugins-good \ gstreamer1.0-pulseaudio \ gstreamer1.0-tools \ libglu1-mesa \ libgtk2.0-0 \ libncursesw5 \ libopenal1 \ libsdl-image1.2 \ libsdl-ttf2.0-0 \ libsdl1.2debian \ libsndfile1 \ novnc \ pulseaudio \ supervisor \ ucspi-tcp \ wget \ x11vnc \ xvfb \ dosbox \ procps \ gettext-base \ unzip \ patch \ && rm -rf /var/lib/apt/lists/* # Configure pulseaudio. COPY conf/default.pa conf/client.conf /etc/pulse/ # Force vnc_lite.html to be used for novnc, to avoid having the directory listing page. # Additionally, turn off the control bar. Finally, add a hook to start audio. COPY conf/webaudio.js /usr/share/novnc/core/ COPY conf/novnc/vnc_lite.html /usr/share/novnc/vnc_lite.html RUN ln -s /usr/share/novnc/vnc_lite.html /usr/share/novnc/index.html # Add a patch to make the background customizable. COPY conf/novnc/background_patch.diff /usr/share/novnc RUN cd /usr/share/novnc && \ patch -p1 < background_patch.diff # Configure supervisord. COPY conf/supervisord.conf /etc/supervisor/supervisord.conf # Run everything as standard user/group retrogames. RUN groupadd retrogames \ && useradd --create-home --gid retrogames retrogames WORKDIR /home/retrogames # Copy dosbox custom confs. COPY conf/dosbox /dosbox/ COPY entrypoint.sh /entrypoint.sh RUN chmod +x /entrypoint.sh # Copy games. RUN mkdir /games && chown -R retrogames:retrogames /games USER retrogames #COPY --chown=retrogames:retrogames games /games HEALTHCHECK CMD ps aux | grep dosbox | grep -v grep || exit 1 ENTRYPOINT [ "supervisord", "-c", "/etc/supervisor/supervisord.conf" ] ================================================ FILE: game-engine/conf/client.conf ================================================ default-server=unix:/tmp/pulseaudio.socket ================================================ FILE: game-engine/conf/default.pa ================================================ #!/usr/bin/pulseaudio -nF load-module module-native-protocol-unix socket=/tmp/pulseaudio.socket auth-anonymous=1 load-module module-always-sink ================================================ FILE: game-engine/conf/dosbox/dosbox.cli.conf.template ================================================ set border 0 exec dosbox -conf ~/.dosbox/dosbox.conf -fullscreen root@9fb8fc07e1da:~# cat .dosbox/dosbox.conf # This is the configurationfile for DOSBox 0.74. (Please use the latest version of DOSBox) # Lines starting with a # are commentlines and are ignored by DOSBox. # They are used to (briefly) document the effect of each option. [sdl] # fullscreen: Start dosbox directly in fullscreen. (Press ALT-Enter to go back) # fulldouble: Use double buffering in fullscreen. It can reduce screen flickering, but it can also result in a slow DOSBox. # fullresolution: What resolution to use for fullscreen: original or fixed size (e.g. 1024x768). # Using your monitor's native resolution with aspect=true might give the best results. # If you end up with small window on a large screen, try an output different from surface. # windowresolution: Scale the window to this size IF the output device supports hardware scaling. # (output=surface does not!) # output: What video system to use for output. # Possible values: surface, overlay, opengl, openglnb. # autolock: Mouse will automatically lock, if you click on the screen. (Press CTRL-F10 to unlock) # sensitivity: Mouse sensitivity. # waitonerror: Wait before closing the console if dosbox has an error. # priority: Priority levels for dosbox. Second entry behind the comma is for when dosbox is not focused/minimized. # pause is only valid for the second entry. # Possible values: lowest, lower, normal, higher, highest, pause. # mapperfile: File used to load/save the key/event mappings from. Resetmapper only works with the defaul value. # usescancodes: Avoid usage of symkeys, might not work on all operating systems. fullscreen=true fulldouble=false fullresolution=0x0 windowresolution=0x0 output=opengl autolock=true sensitivity=100 waitonerror=true priority=higher,normal mapperfile=mapper-0.74.map usescancodes=false [dosbox] # language: Select another language file. # machine: The type of machine tries to emulate. # Possible values: hercules, cga, tandy, pcjr, ega, vgaonly, svga_s3, svga_et3000, svga_et4000, svga_paradise, vesa_nolfb, vesa_oldvbe. # captures: Directory where things like wave, midi, screenshot get captured. # memsize: Amount of memory DOSBox has in megabytes. # This value is best left at its default to avoid problems with some games, # though few games might require a higher value. # There is generally no speed advantage when raising this value. language= machine=svga_s3 captures=capture memsize=16 [render] # frameskip: How many frames DOSBox skips before drawing one. # aspect: Do aspect correction, if your output method doesn't support scaling this can slow things down!. # scaler: Scaler used to enlarge/enhance low resolution modes. # If 'forced' is appended, then the scaler will be used even if the result might not be desired. # Possible values: none, normal2x, normal3x, advmame2x, advmame3x, advinterp2x, advinterp3x, hq2x, hq3x, 2xsai, super2xsai, supereagle, tv2x, tv3x, rgb2x, rgb3x, scan2x, scan3x. frameskip=0 aspect=false scaler=none [cpu] # core: CPU Core used in emulation. auto will switch to dynamic if available and appropriate. # Possible values: auto, dynamic, normal, simple. # cputype: CPU Type used in emulation. auto is the fastest choice. # Possible values: auto, 386, 386_slow, 486_slow, pentium_slow, 386_prefetch. # cycles: Amount of instructions DOSBox tries to emulate each millisecond. # Setting this value too high results in sound dropouts and lags. # Cycles can be set in 3 ways: # 'auto' tries to guess what a game needs. # It usually works, but can fail for certain games. # 'fixed #number' will set a fixed amount of cycles. This is what you usually need if 'auto' fails. # (Example: fixed 4000). # 'max' will allocate as much cycles as your computer is able to handle. # # Possible values: auto, fixed, max. # cycleup: Amount of cycles to decrease/increase with keycombo.(CTRL-F11/CTRL-F12) # cycledown: Setting it lower than 100 will be a percentage. core=auto cputype=auto cycles=auto cycleup=10 cycledown=20 [mixer] # nosound: Enable silent mode, sound is still emulated though. # rate: Mixer sample rate, setting any device's rate higher than this will probably lower their sound quality. # Possible values: 44100, 48000, 32000, 22050, 16000, 11025, 8000, 49716. # blocksize: Mixer block size, larger blocks might help sound stuttering but sound will also be more lagged. # Possible values: 1024, 2048, 4096, 8192, 512, 256. # prebuffer: How many milliseconds of data to keep on top of the blocksize. nosound=false rate=44100 blocksize=1024 prebuffer=20 [midi] # mpu401: Type of MPU-401 to emulate. # Possible values: intelligent, uart, none. # mididevice: Device that will receive the MIDI data from MPU-401. # Possible values: default, win32, alsa, oss, coreaudio, coremidi, none. # midiconfig: Special configuration options for the device driver. This is usually the id of the device you want to use. # See the README/Manual for more details. mpu401=intelligent mididevice=default midiconfig= [sblaster] # sbtype: Type of Soundblaster to emulate. gb is Gameblaster. # Possible values: sb1, sb2, sbpro1, sbpro2, sb16, gb, none. # sbbase: The IO address of the soundblaster. # Possible values: 220, 240, 260, 280, 2a0, 2c0, 2e0, 300. # irq: The IRQ number of the soundblaster. # Possible values: 7, 5, 3, 9, 10, 11, 12. # dma: The DMA number of the soundblaster. # Possible values: 1, 5, 0, 3, 6, 7. # hdma: The High DMA number of the soundblaster. # Possible values: 1, 5, 0, 3, 6, 7. # sbmixer: Allow the soundblaster mixer to modify the DOSBox mixer. # oplmode: Type of OPL emulation. On 'auto' the mode is determined by sblaster type. All OPL modes are Adlib-compatible, except for 'cms'. # Possible values: auto, cms, opl2, dualopl2, opl3, none. # oplemu: Provider for the OPL emulation. compat might provide better quality (see oplrate as well). # Possible values: default, compat, fast. # oplrate: Sample rate of OPL music emulation. Use 49716 for highest quality (set the mixer rate accordingly). # Possible values: 44100, 49716, 48000, 32000, 22050, 16000, 11025, 8000. sbtype=sb16 sbbase=220 irq=7 dma=1 hdma=5 sbmixer=true oplmode=auto oplemu=default oplrate=44100 [gus] # gus: Enable the Gravis Ultrasound emulation. # gusrate: Sample rate of Ultrasound emulation. # Possible values: 44100, 48000, 32000, 22050, 16000, 11025, 8000, 49716. # gusbase: The IO base address of the Gravis Ultrasound. # Possible values: 240, 220, 260, 280, 2a0, 2c0, 2e0, 300. # gusirq: The IRQ number of the Gravis Ultrasound. # Possible values: 5, 3, 7, 9, 10, 11, 12. # gusdma: The DMA channel of the Gravis Ultrasound. # Possible values: 3, 0, 1, 5, 6, 7. # ultradir: Path to Ultrasound directory. In this directory # there should be a MIDI directory that contains # the patch files for GUS playback. Patch sets used # with Timidity should work fine. gus=false gusrate=44100 gusbase=240 gusirq=5 gusdma=3 ultradir=C:\ULTRASND [speaker] # pcspeaker: Enable PC-Speaker emulation. # pcrate: Sample rate of the PC-Speaker sound generation. # Possible values: 44100, 48000, 32000, 22050, 16000, 11025, 8000, 49716. # tandy: Enable Tandy Sound System emulation. For 'auto', emulation is present only if machine is set to 'tandy'. # Possible values: auto, on, off. # tandyrate: Sample rate of the Tandy 3-Voice generation. # Possible values: 44100, 48000, 32000, 22050, 16000, 11025, 8000, 49716. # disney: Enable Disney Sound Source emulation. (Covox Voice Master and Speech Thing compatible). pcspeaker=true pcrate=44100 tandy=auto tandyrate=44100 disney=true [joystick] # joysticktype: Type of joystick to emulate: auto (default), none, # 2axis (supports two joysticks), # 4axis (supports one joystick, first joystick used), # 4axis_2 (supports one joystick, second joystick used), # fcs (Thrustmaster), ch (CH Flightstick). # none disables joystick emulation. # auto chooses emulation depending on real joystick(s). # (Remember to reset dosbox's mapperfile if you saved it earlier) # Possible values: auto, 2axis, 4axis, 4axis_2, fcs, ch, none. # timed: enable timed intervals for axis. Experiment with this option, if your joystick drifts (away). # autofire: continuously fires as long as you keep the button pressed. # swap34: swap the 3rd and the 4th axis. can be useful for certain joysticks. # buttonwrap: enable button wrapping at the number of emulated buttons. joysticktype=auto timed=true autofire=false swap34=false buttonwrap=false [serial] # serial1: set type of device connected to com port. # Can be disabled, dummy, modem, nullmodem, directserial. # Additional parameters must be in the same line in the form of # parameter:value. Parameter for all types is irq (optional). # for directserial: realport (required), rxdelay (optional). # (realport:COM1 realport:ttyS0). # for modem: listenport (optional). # for nullmodem: server, rxdelay, txdelay, telnet, usedtr, # transparent, port, inhsocket (all optional). # Example: serial1=modem listenport:5000 # Possible values: dummy, disabled, modem, nullmodem, directserial. # serial2: see serial1 # Possible values: dummy, disabled, modem, nullmodem, directserial. # serial3: see serial1 # Possible values: dummy, disabled, modem, nullmodem, directserial. # serial4: see serial1 # Possible values: dummy, disabled, modem, nullmodem, directserial. serial1=dummy serial2=dummy serial3=disabled serial4=disabled [dos] # xms: Enable XMS support. # ems: Enable EMS support. # umb: Enable UMB support. # keyboardlayout: Language code of the keyboard layout (or none). xms=true ems=false umb=true keyboardlayout=auto [ipx] # ipx: Enable ipx over UDP/IP emulation. ipx=false [autoexec] # Lines in this section will be run at startup. # You can put your MOUNT lines here. MOUNT C: /games C: ================================================ FILE: game-engine/conf/dosbox/dosbox.conf.template ================================================ set border 0 exec dosbox -conf ~/.dosbox/dosbox.conf -fullscreen root@9fb8fc07e1da:~# cat .dosbox/dosbox.conf # This is the configurationfile for DOSBox 0.74. (Please use the latest version of DOSBox) # Lines starting with a # are commentlines and are ignored by DOSBox. # They are used to (briefly) document the effect of each option. [sdl] # fullscreen: Start dosbox directly in fullscreen. (Press ALT-Enter to go back) # fulldouble: Use double buffering in fullscreen. It can reduce screen flickering, but it can also result in a slow DOSBox. # fullresolution: What resolution to use for fullscreen: original or fixed size (e.g. 1024x768). # Using your monitor's native resolution with aspect=true might give the best results. # If you end up with small window on a large screen, try an output different from surface. # windowresolution: Scale the window to this size IF the output device supports hardware scaling. # (output=surface does not!) # output: What video system to use for output. # Possible values: surface, overlay, opengl, openglnb. # autolock: Mouse will automatically lock, if you click on the screen. (Press CTRL-F10 to unlock) # sensitivity: Mouse sensitivity. # waitonerror: Wait before closing the console if dosbox has an error. # priority: Priority levels for dosbox. Second entry behind the comma is for when dosbox is not focused/minimized. # pause is only valid for the second entry. # Possible values: lowest, lower, normal, higher, highest, pause. # mapperfile: File used to load/save the key/event mappings from. Resetmapper only works with the defaul value. # usescancodes: Avoid usage of symkeys, might not work on all operating systems. fullscreen=true fulldouble=false fullresolution=0x0 windowresolution=0x0 output=opengl autolock=true sensitivity=100 waitonerror=true priority=higher,normal mapperfile=mapper-0.74.map usescancodes=false [dosbox] # language: Select another language file. # machine: The type of machine tries to emulate. # Possible values: hercules, cga, tandy, pcjr, ega, vgaonly, svga_s3, svga_et3000, svga_et4000, svga_paradise, vesa_nolfb, vesa_oldvbe. # captures: Directory where things like wave, midi, screenshot get captured. # memsize: Amount of memory DOSBox has in megabytes. # This value is best left at its default to avoid problems with some games, # though few games might require a higher value. # There is generally no speed advantage when raising this value. language= machine=svga_s3 captures=capture memsize=16 [render] # frameskip: How many frames DOSBox skips before drawing one. # aspect: Do aspect correction, if your output method doesn't support scaling this can slow things down!. # scaler: Scaler used to enlarge/enhance low resolution modes. # If 'forced' is appended, then the scaler will be used even if the result might not be desired. # Possible values: none, normal2x, normal3x, advmame2x, advmame3x, advinterp2x, advinterp3x, hq2x, hq3x, 2xsai, super2xsai, supereagle, tv2x, tv3x, rgb2x, rgb3x, scan2x, scan3x. frameskip=0 aspect=false scaler=none [cpu] # core: CPU Core used in emulation. auto will switch to dynamic if available and appropriate. # Possible values: auto, dynamic, normal, simple. # cputype: CPU Type used in emulation. auto is the fastest choice. # Possible values: auto, 386, 386_slow, 486_slow, pentium_slow, 386_prefetch. # cycles: Amount of instructions DOSBox tries to emulate each millisecond. # Setting this value too high results in sound dropouts and lags. # Cycles can be set in 3 ways: # 'auto' tries to guess what a game needs. # It usually works, but can fail for certain games. # 'fixed #number' will set a fixed amount of cycles. This is what you usually need if 'auto' fails. # (Example: fixed 4000). # 'max' will allocate as much cycles as your computer is able to handle. # # Possible values: auto, fixed, max. # cycleup: Amount of cycles to decrease/increase with keycombo.(CTRL-F11/CTRL-F12) # cycledown: Setting it lower than 100 will be a percentage. core=auto cputype=auto cycles=auto cycleup=10 cycledown=20 [mixer] # nosound: Enable silent mode, sound is still emulated though. # rate: Mixer sample rate, setting any device's rate higher than this will probably lower their sound quality. # Possible values: 44100, 48000, 32000, 22050, 16000, 11025, 8000, 49716. # blocksize: Mixer block size, larger blocks might help sound stuttering but sound will also be more lagged. # Possible values: 1024, 2048, 4096, 8192, 512, 256. # prebuffer: How many milliseconds of data to keep on top of the blocksize. nosound=false rate=44100 blocksize=1024 prebuffer=20 [midi] # mpu401: Type of MPU-401 to emulate. # Possible values: intelligent, uart, none. # mididevice: Device that will receive the MIDI data from MPU-401. # Possible values: default, win32, alsa, oss, coreaudio, coremidi, none. # midiconfig: Special configuration options for the device driver. This is usually the id of the device you want to use. # See the README/Manual for more details. mpu401=intelligent mididevice=default midiconfig= [sblaster] # sbtype: Type of Soundblaster to emulate. gb is Gameblaster. # Possible values: sb1, sb2, sbpro1, sbpro2, sb16, gb, none. # sbbase: The IO address of the soundblaster. # Possible values: 220, 240, 260, 280, 2a0, 2c0, 2e0, 300. # irq: The IRQ number of the soundblaster. # Possible values: 7, 5, 3, 9, 10, 11, 12. # dma: The DMA number of the soundblaster. # Possible values: 1, 5, 0, 3, 6, 7. # hdma: The High DMA number of the soundblaster. # Possible values: 1, 5, 0, 3, 6, 7. # sbmixer: Allow the soundblaster mixer to modify the DOSBox mixer. # oplmode: Type of OPL emulation. On 'auto' the mode is determined by sblaster type. All OPL modes are Adlib-compatible, except for 'cms'. # Possible values: auto, cms, opl2, dualopl2, opl3, none. # oplemu: Provider for the OPL emulation. compat might provide better quality (see oplrate as well). # Possible values: default, compat, fast. # oplrate: Sample rate of OPL music emulation. Use 49716 for highest quality (set the mixer rate accordingly). # Possible values: 44100, 49716, 48000, 32000, 22050, 16000, 11025, 8000. sbtype=sb16 sbbase=220 irq=7 dma=1 hdma=5 sbmixer=true oplmode=auto oplemu=default oplrate=44100 [gus] # gus: Enable the Gravis Ultrasound emulation. # gusrate: Sample rate of Ultrasound emulation. # Possible values: 44100, 48000, 32000, 22050, 16000, 11025, 8000, 49716. # gusbase: The IO base address of the Gravis Ultrasound. # Possible values: 240, 220, 260, 280, 2a0, 2c0, 2e0, 300. # gusirq: The IRQ number of the Gravis Ultrasound. # Possible values: 5, 3, 7, 9, 10, 11, 12. # gusdma: The DMA channel of the Gravis Ultrasound. # Possible values: 3, 0, 1, 5, 6, 7. # ultradir: Path to Ultrasound directory. In this directory # there should be a MIDI directory that contains # the patch files for GUS playback. Patch sets used # with Timidity should work fine. gus=false gusrate=44100 gusbase=240 gusirq=5 gusdma=3 ultradir=C:\ULTRASND [speaker] # pcspeaker: Enable PC-Speaker emulation. # pcrate: Sample rate of the PC-Speaker sound generation. # Possible values: 44100, 48000, 32000, 22050, 16000, 11025, 8000, 49716. # tandy: Enable Tandy Sound System emulation. For 'auto', emulation is present only if machine is set to 'tandy'. # Possible values: auto, on, off. # tandyrate: Sample rate of the Tandy 3-Voice generation. # Possible values: 44100, 48000, 32000, 22050, 16000, 11025, 8000, 49716. # disney: Enable Disney Sound Source emulation. (Covox Voice Master and Speech Thing compatible). pcspeaker=true pcrate=44100 tandy=auto tandyrate=44100 disney=true [joystick] # joysticktype: Type of joystick to emulate: auto (default), none, # 2axis (supports two joysticks), # 4axis (supports one joystick, first joystick used), # 4axis_2 (supports one joystick, second joystick used), # fcs (Thrustmaster), ch (CH Flightstick). # none disables joystick emulation. # auto chooses emulation depending on real joystick(s). # (Remember to reset dosbox's mapperfile if you saved it earlier) # Possible values: auto, 2axis, 4axis, 4axis_2, fcs, ch, none. # timed: enable timed intervals for axis. Experiment with this option, if your joystick drifts (away). # autofire: continuously fires as long as you keep the button pressed. # swap34: swap the 3rd and the 4th axis. can be useful for certain joysticks. # buttonwrap: enable button wrapping at the number of emulated buttons. joysticktype=auto timed=true autofire=false swap34=false buttonwrap=false [serial] # serial1: set type of device connected to com port. # Can be disabled, dummy, modem, nullmodem, directserial. # Additional parameters must be in the same line in the form of # parameter:value. Parameter for all types is irq (optional). # for directserial: realport (required), rxdelay (optional). # (realport:COM1 realport:ttyS0). # for modem: listenport (optional). # for nullmodem: server, rxdelay, txdelay, telnet, usedtr, # transparent, port, inhsocket (all optional). # Example: serial1=modem listenport:5000 # Possible values: dummy, disabled, modem, nullmodem, directserial. # serial2: see serial1 # Possible values: dummy, disabled, modem, nullmodem, directserial. # serial3: see serial1 # Possible values: dummy, disabled, modem, nullmodem, directserial. # serial4: see serial1 # Possible values: dummy, disabled, modem, nullmodem, directserial. serial1=dummy serial2=dummy serial3=disabled serial4=disabled [dos] # xms: Enable XMS support. # ems: Enable EMS support. # umb: Enable UMB support. # keyboardlayout: Language code of the keyboard layout (or none). xms=true ems=false umb=true keyboardlayout=auto [ipx] # ipx: Enable ipx over UDP/IP emulation. ipx=false [autoexec] # Lines in this section will be run at startup. # You can put your MOUNT lines here. @ECHO OFF MOUNT C: /games C: CD ${GAME_DIR} echo "To run this game just type: ${GAME_EXE} + enter" ================================================ FILE: game-engine/conf/novnc/background_patch.diff ================================================ diff --git a/core/rfb.js b/core/rfb.js index 7c4e0c9..7217e7c 100644 --- a/core/rfb.js +++ b/core/rfb.js @@ -152,7 +152,7 @@ export default function RFB(target, url, options) { this._screen.style.width = '100%'; this._screen.style.height = '100%'; this._screen.style.overflow = 'auto'; - this._screen.style.backgroundColor = 'rgb(40, 40, 40)'; + this._screen.style.backgroundColor = 'black'; this._canvas = document.createElement('canvas'); this._canvas.style.margin = 'auto'; // Some browsers add an outline on focus ================================================ FILE: game-engine/conf/novnc/vnc_lite.html ================================================