├── .gitignore ├── .travis.yml ├── BUILDDEFS ├── CMakeLists.txt ├── INSTALL.md ├── LICENSE.game_code.txt ├── NOTES ├── README.md ├── build-packages ├── build-win32-packages ├── buildconfig.h.cmake ├── clean-all ├── configure ├── data ├── demos │ ├── demo_0.dat │ ├── demo_1.dat │ └── demo_2.dat ├── gfx │ ├── loader │ │ ├── DO64-0.24.gpl │ │ ├── header.theme │ │ ├── loaderfont.png │ │ ├── main.theme │ │ ├── oaplanet-pcb.png │ │ └── olofsonarcade-do64-ovl.png │ ├── mono │ │ ├── HW-ZX-Spectrum.gpl │ │ ├── dashboard │ │ │ ├── barleds2.png │ │ │ ├── bottomleds.png │ │ │ ├── chargeleds3.png │ │ │ ├── crosshair.png │ │ │ ├── dashboard-v3.png │ │ │ ├── leftleds.png │ │ │ ├── logo.png │ │ │ ├── rightleds.png │ │ │ ├── topleds.png │ │ │ ├── weapons.png │ │ │ └── weaponslots.png │ │ ├── fonts │ │ │ ├── bigfont.png │ │ │ ├── counterfont.png │ │ │ ├── microfont.png │ │ │ └── smallfont.png │ │ ├── fx │ │ │ ├── fs-gridtfx-tiles.png │ │ │ ├── gridfx2.png │ │ │ ├── gridtfx-tiles-blue.png │ │ │ ├── hitnoise.png │ │ │ ├── noise.png │ │ │ └── shieldfx3.png │ │ ├── header.theme │ │ ├── main.theme │ │ ├── region-1 │ │ │ ├── ground-l10.png │ │ │ ├── ground-l8.png │ │ │ ├── planet.png │ │ │ ├── tiles-clean.png │ │ │ ├── tiles-small.png │ │ │ └── tiles-tiny.png │ │ ├── space.png │ │ └── sprites │ │ │ ├── bigship.png │ │ │ ├── bluebullet.png │ │ │ ├── bluebulletexpl.png │ │ │ ├── bmr1.png │ │ │ ├── bmr2.png │ │ │ ├── bmr3.png │ │ │ ├── bolt.png │ │ │ ├── bomb.png │ │ │ ├── bombdeto.png │ │ │ ├── fighter.png │ │ │ ├── greenbullet.png │ │ │ ├── greenbulletexpl.png │ │ │ ├── kobo-mk3s.png │ │ │ ├── missile.png │ │ │ ├── missile2.png │ │ │ ├── missile3.png │ │ │ ├── redbullet.png │ │ │ ├── redbulletexpl.png │ │ │ ├── ring.png │ │ │ ├── ringexpl.png │ │ │ ├── rock.png │ │ │ └── rockexpl.png │ └── tools │ │ ├── header.theme │ │ ├── main.theme │ │ ├── microfont2.png │ │ ├── microfont3.png │ │ └── soundicons.png └── sfx │ ├── chip │ ├── header.theme │ ├── main.a2s │ ├── master.a2s │ ├── sfx.a2s │ └── uisfx.a2s │ └── loader │ ├── header.theme │ ├── main.a2s │ └── oajingle-short.a2s ├── fix-linux-bz2-package ├── fix-linux-deb-package ├── fix-linux-rpm-package ├── icons ├── koboredux.png ├── net.olofson.koboredux-demo.desktop ├── net.olofson.koboredux.desktop └── windows │ ├── kobord.rc │ └── koboredux.ico ├── install-data ├── install-libs ├── install-win32-redist ├── linux-bundle ├── demo.itch.toml ├── itch.toml ├── kobord-demo.sh ├── kobord.sh ├── koboredux-demo.desktop ├── koboredux.desktop ├── static.demo.itch.toml └── static.itch.toml ├── make-all └── src ├── CMakeLists.txt ├── campaign.cpp ├── campaign.h ├── cfgform.cpp ├── cfgform.h ├── cfgparse.cpp ├── cfgparse.h ├── config.h ├── dashboard.cpp ├── dashboard.h ├── dbgconsole.cpp ├── dbgconsole.h ├── enemies.cpp ├── enemies.h ├── enemy.cpp ├── filemap.cpp ├── filemap.h ├── fire.cpp ├── fire.h ├── form.cpp ├── form.h ├── game.cpp ├── game.h ├── gamectl.cpp ├── gamectl.h ├── gamestate.cpp ├── gamestate.h ├── gfx └── mono │ ├── dashboard │ └── dashboard-v2.xcf │ ├── fonts │ ├── bigfont.xcf │ ├── counterfont.xcf │ └── smallfont.xcf │ ├── render-sprites.eel │ └── sprites │ ├── bigship-src.png │ ├── bigship.aseprite │ ├── bigship.xcf │ ├── bmr-pink.aseprite │ ├── kobo-mk3s-src.png │ ├── kobo-mk3s.xcf │ └── missile.aseprite ├── gfxengine ├── cs.c ├── cs.h ├── filters.c ├── filters.h ├── gfxengine.cpp ├── gfxengine.h ├── palette.c ├── palette.h ├── sofont.cpp ├── sofont.h ├── sprite.c ├── sprite.h ├── toolkit.cpp ├── toolkit.h ├── vidmodes.c ├── vidmodes.h ├── window.cpp └── window.h ├── graphics.cpp ├── graphics.h ├── gridtfx.cpp ├── gridtfx.h ├── kobo.cpp ├── kobo.h ├── kobolog.h ├── logger.c ├── logger.h ├── manage.cpp ├── manage.h ├── map.cpp ├── map.h ├── mathutil.h ├── myship.cpp ├── myship.h ├── openurl.cpp ├── openurl.h ├── options.cpp ├── options.h ├── pfile.cpp ├── pfile.h ├── prefs.cpp ├── prefs.h ├── profiler.h ├── radar.cpp ├── radar.h ├── random.cpp ├── random.h ├── replay.cpp ├── replay.h ├── replay_gst.cpp ├── replay_gst.h ├── savemanager.cpp ├── savemanager.h ├── scenes.cpp ├── scenes.h ├── screen.cpp ├── screen.h ├── sound.cpp ├── sound.h ├── spinplanet.cpp ├── spinplanet.h ├── starfield.cpp ├── starfield.h ├── states.cpp ├── states.h ├── themeparser.cpp └── themeparser.h /.gitignore: -------------------------------------------------------------------------------- 1 | # Compiled Object files 2 | *.slo 3 | *.lo 4 | *.o 5 | *.obj 6 | 7 | # Precompiled Headers 8 | *.gch 9 | *.pch 10 | 11 | # Compiled Dynamic libraries 12 | *.so 13 | *.dylib 14 | *.dll 15 | 16 | # Fortran module files 17 | *.mod 18 | 19 | # Compiled Static libraries 20 | *.lai 21 | *.la 22 | *.a 23 | *.lib 24 | 25 | # Executables 26 | *.exe 27 | *.out 28 | *.app 29 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: cpp 2 | 3 | cache: ccache 4 | 5 | os: 6 | - linux 7 | 8 | env: 9 | - DEMO=ON 10 | - DEMO=OFF 11 | 12 | sudo: required 13 | 14 | dist: trusty 15 | 16 | before_install: 17 | - sudo apt-get update -qq 18 | - sudo apt install rpm 19 | - ./install-libs 20 | - if [[ "$DEMO" == "ON" ]]; then ./install-demo-data; fi 21 | 22 | script: 23 | - cmake --version 24 | - dpkg --version 25 | - rpm --version 26 | - mkdir build 27 | - cd build 28 | - cmake -DCMAKE_INSTALL_PREFIX=/usr -DDEMO_BUILD=$DEMO .. 29 | - make 30 | # - make package 31 | # - cd .. 32 | # - ./fix-linux-bz2-package build/koboredux-*-Linux.tar.bz2 33 | 34 | #deploy: 35 | # skip_cleanup: true 36 | # provider: releases 37 | # api_key: 38 | # secure: FA4FE9EvlMu40snssAbcB/HSv8mqomC5N28/f5pSxggfCXeNKbL1NH7lT+/4dafJxkh1VjdAmUI/ENHnyP8h8a6lIrXD6YRTboV2n0WCovBguqKR4d5TTG1izeVHgHfy5iPFiSpg/bjNntrUCpq7oQ0BPeKcsvuZzBgOfLJYBObkCSb7pron4p22N4b19TS8LGWpzA2XOB74LXs2YkftjtMLjTdoemnJxXBAZKMa2H5UbyCtJTqHuM5pq0uHuaIbSjZLL/5/QR5mbeSzVxL93q2eGUR22MZgqhRiCLxKO48xQv7twH/NYiI+U4cw+DB3UmWtUFZUEdZ061kWS8RLpXYIcBakPT33EgBeSeAReNESvoQi1t42/kPmyweU0i1X77c6V/Wcw1jgS7yYVESbpQdemBHf1WSoam0tCJ7QnW9KuN+o19/O13Ic3IN0RvXlyTQnrZntxs7OtTxutGCSFuqIOCoFYT9wLhbjO0MNLL6ojnKkaoFjuCv/RDae1rJksKrNRh4wx0u0DQIeQ5mNWOViFerB4ocKD9uwrBhfgIn5kyrJlvxc8yCv5jmshaJNZBCZn3DOPjhyTkqbzB/tbGe8YsXBnUVWCDktjvj3U9ykSBkx/AYKgXB4mHsbpc+2SLuQ4NPiYrQykKABXFASC+yl36y1QZ0Fo0mT1w1bvG4= 39 | # file-glob: true 40 | # file: 41 | # - build/koboredux-*-Linux.deb 42 | # - build/koboredux-*-Linux.rpm 43 | # - build/koboredux-*-Linux.tar.bz2 44 | # on: 45 | # tags: true 46 | # repo: olofson/koboredux 47 | -------------------------------------------------------------------------------- /BUILDDEFS: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | #---------------------- 4 | # --- Configuration --- 5 | #---------------------- 6 | 7 | # Set to true to build SDL2, SDL2_image, libpng, and Audiality 2 for static 8 | # linking only. 9 | # 10 | # NOTE: This will NOT work if these libraries are already installed in the 11 | # system! 12 | # 13 | # NOTE 2: Dynamic linking has not been tested after the recent changes, and 14 | # there is at least one known problem: Libs will NOT be copied from the 15 | # system, so packaging will only work if build-packages is run without 16 | # any of these libraries installed in the system. 17 | # 18 | KOBO_STATIC_LINUX=true 19 | 20 | 21 | #------------------- 22 | # --- Kobo Redux --- 23 | #------------------- 24 | 25 | # Demo and full data package versions 26 | DEMO_DATA_RELEASE=0.7.5 27 | FULL_DATA_RELEASE=0.7.5 28 | 29 | # Kobo Redux source git repository 30 | KRREPO="https://github.com/olofson/koboredux" 31 | 32 | # Official Kobo Redux home site (with downloads directory) 33 | KRHOME="http://koboredux.com" 34 | 35 | # Archive with Win32 SDL2 redistributables suitable for this release 36 | REDISTARCH="koboredux-0.7.5-libs-redist-win32.tar.bz2" 37 | 38 | 39 | #-------------------- 40 | # --- Audiality 2 --- 41 | #-------------------- 42 | 43 | # Recommended Audiality 2 version for this Kobo Redux release 44 | A2RELEASE=1.9.4 45 | 46 | # Audiality 2 git repository 47 | A2REPO="https://github.com/olofson/audiality2" 48 | 49 | 50 | #------------- 51 | # --- SDL2 --- 52 | #------------- 53 | 54 | SDLRELEASE=2.0.7 55 | SDLURL="https://www.libsdl.org/release/SDL2-${SDLRELEASE}.tar.gz" 56 | 57 | 58 | #--------------- 59 | # --- libpng --- 60 | #--------------- 61 | 62 | PNGRELEASE=1.6.34 63 | PNGURL="ftp://ftp-osl.osuosl.org/pub/libpng/src/libpng16/libpng-${PNGRELEASE}.tar.xz" 64 | 65 | 66 | #------------------- 67 | # --- SDL2_image --- 68 | #------------------- 69 | 70 | IMGRELEASE=2.0.2 71 | IMGURL="https://www.libsdl.org/projects/SDL_image/release/SDL2_image-${IMGRELEASE}.tar.gz" 72 | 73 | 74 | #-------------------- 75 | # --- Directories --- 76 | #-------------------- 77 | 78 | # Root of the source tree 79 | SOURCEDIR="$(pwd)" 80 | 81 | # CMake top-level build directory. (NOTE: The actual build directories are 82 | # inside this one!) 83 | BUILDDIR="$(pwd)/build" 84 | 85 | # Staging directory for dependency library builds, downloads, packages etc 86 | WORKDIR="$(pwd)/work" 87 | 88 | # Download directory 89 | DLDIR="${WORKDIR}/downloads" 90 | 91 | # Final package output directory 92 | PKGDIR="${WORKDIR}/packages" 93 | 94 | 95 | #------------ 96 | # --- MXE --- 97 | #------------ 98 | 99 | # MinGW32 cross build using MXE (http://mxe.cc/) 100 | if [ -z $MXEPATH ]; then 101 | MXEPATH=/usr/lib/mxe/ 102 | fi 103 | -------------------------------------------------------------------------------- /INSTALL.md: -------------------------------------------------------------------------------- 1 | Kobo Redux 2 | ========== 3 | 4 | This file explains how to build and install Kobo Redux from source. It does NOT cover building of packages, but the executables built from this source tree ARE compatible with the proprietary data files; both demo and full version. 5 | 6 | *NOTE* 7 | ------ 8 | 9 | *The proprietary sound and graphics themes are not included in the source tree! However, placeholder GPL themes "chip" (sound) and "mono" (graphics) are included, making the game mostly playable with no external data.* 10 | 11 | Installing 12 | ---------- 13 | 14 | * Install the dependencies. Note that Audiality 1.9.x is a development branch, which means any given release of Kobo Redux will most likely only work with one specific Audiality version. 15 | * SDL 2.0 16 | * http://libsdl.org 17 | * Audiality 2 (currently 1.9.2) 18 | * https://github.com/olofson/audiality2 19 | * *Optional:* MXE (needed for cross-compiling Windows binaries) 20 | * http://mxe.cc/ 21 | 22 | * Download the source code. 23 | * GitHub/SSH 24 | * git clone git@github.com:olofson/koboredux.git 25 | * *Alternatively:* GitHub/HTTPS 26 | * git clone https://github.com/olofson/koboredux.git 27 | 28 | * Configure the source tree. 29 | * Option 1 (Un*x with bash or compatible shell) 30 | * ./configure [*target*] 31 | * Currently available targets: 32 | * release 33 | * demo 34 | * maintainer 35 | * debug 36 | * mingw-release 37 | * mingw-demo 38 | * mingw-debug 39 | * all *(all of the above)* 40 | * (Default if not specified: release + demo) 41 | * Option 2 (Using CMake directly; see 'configure' script to see how to set up the options) 42 | * mkdir build 43 | * cd build 44 | * cmake .. 45 | 46 | * Build and install. 47 | * ./make-all 48 | * (The resulting executables are found in "build//src/") 49 | * *Alternatively:* Enter the desired build target directory. 50 | * make 51 | * *Optional:* sudo make install 52 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Kobo Redux 2 | ========== 3 | 4 | Because Chain Explosions Never Get Old 5 | -------------------------------------- 6 | 7 | Kobo Redux is a frantic 80's style 2D shooter, inspired by the look and feel of 90's arcade cabinets. The gameplay is fast and unforgiving, although with less of the frustrating quirkiness of the actual games of the 80's. A true challenge in the spirit of the arcade era! 8 | 9 | First, inspired by Bosconian, there was XKobo, a frantic multi-directional scrolling arcade shooter, where the primary objective was to destroy maze-like hostile space bases. Kobo Deluxe brought this addictive game to basically everything with a CPU - but it was never quite finished. Now, with smoother controls, improved gameplay, new pixel art, and a proper soundtrack, Kobo Redux aims to be the XKobo update that Kobo Deluxe never quite became. 10 | 11 | While Kobo Redux is a proprietary title, it is implemented using portable Free/Open Source technologies, and the full game source code will be made available as the game is released. 12 | 13 | *NOTE* 14 | ------ 15 | 16 | *The proprietary sound and graphics themes are not included in the source tree! However, placeholder GPL themes "chip" (sound) and "mono" (graphics) are included, making the game mostly playable with no external data.* 17 | -------------------------------------------------------------------------------- /build-packages: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | . ./BUILDDEFS 3 | 4 | shopt -s extglob 5 | shopt -s nullglob 6 | 7 | if [ $# -eq 0 ]; then 8 | # Default: Build all native demo and release packages 9 | FILTER=@(release|demo) 10 | elif [ "$1" == all ]; then 11 | FILTER="*" 12 | else 13 | FILTER="$1" 14 | fi 15 | 16 | ./install-libs 17 | ./install-data "v${FULL_DATA_RELEASE}" "full-data" 18 | ./install-data "demo-${DEMO_DATA_RELEASE}" "demo-data" 19 | ./install-win32-redist 20 | 21 | ./configure "${FILTER}" 22 | 23 | mkdir -p "${PKGDIR}" 24 | rm -rf "${PKGDIR}/*" 25 | 26 | for i in ${BUILDDIR}/${FILTER} ; do 27 | echo 28 | echo "[ Building $(basename $i) ]" 29 | echo $i 30 | cd $i 31 | make -j20 32 | make package 33 | mv *.@(rpm|deb|tar.bz2|zip) "${PKGDIR}" 34 | echo "[ Leaving $(basename $i) ]" 35 | echo 36 | done 37 | cd ${SOURCEDIR} 38 | 39 | # HAX: Can't get CPack to stop adding those bogus directories... 40 | for a in ${PKGDIR}/KoboRedux-*-win32.zip ; do 41 | echo $a 42 | zip -d $a "*/home/*" 43 | done 44 | 45 | # HAX: No reliable way of selectively flattening archives with CPack. >:-/ 46 | for a in ${PKGDIR}/koboredux-*-Linux.tar.bz2 ; do 47 | echo $a 48 | "${SOURCEDIR}/fix-linux-bz2-package" $a 49 | done 50 | 51 | # HAX: CPack makes pretty bad DEBs and RPMs 52 | for a in ${PKGDIR}/koboredux-*-Linux.deb ; do 53 | echo $a 54 | fakeroot "${SOURCEDIR}/fix-linux-deb-package" $a 55 | done 56 | for a in ${PKGDIR}/koboredux-*-Linux.rpm ; do 57 | echo $a 58 | "${SOURCEDIR}/fix-linux-rpm-package" $a 59 | done 60 | -------------------------------------------------------------------------------- /build-win32-packages: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | shopt -s extglob 3 | # Build only Win32 demo and release packages 4 | ./build-packages mingw-@(release|demo) 5 | -------------------------------------------------------------------------------- /buildconfig.h.cmake: -------------------------------------------------------------------------------- 1 | /* 2 | --------------------------------------------------------------------------- 3 | @KOBOREDUX_AUTO_MESSAGE@ 4 | --------------------------------------------------------------------------- 5 | */ 6 | 7 | #cmakedefine KOBO_HAVE_SNPRINTF 8 | #cmakedefine KOBO_HAVE__SNPRINTF 9 | #cmakedefine KOBO_HAVE_VSNPRINTF 10 | #cmakedefine KOBO_HAVE__VSNPRINTF 11 | #cmakedefine KOBO_HAVE_STAT 12 | #cmakedefine KOBO_HAVE_LSTAT 13 | 14 | #cmakedefine KOBO_HAVE_GETEGID 15 | #cmakedefine KOBO_HAVE_SETGID 16 | 17 | #cmakedefine KOBO_ENABLE_TOUCHSCREEN 18 | 19 | #define RETSIGTYPE @RETSIGTYPE@ 20 | 21 | #define PACKAGE "@PACKAGE@" 22 | #define KOBO_VERSION_STRING "@VERSION_STRING@" 23 | #define KOBO_MAKE_VERSION(major, minor, micro, build) \ 24 | (((major) << 24) | ((minor) << 16) | ((micro) << 8) | (build)) 25 | #define KOBO_MAJOR(ver) (((ver) >> 24) & 0xff) 26 | #define KOBO_MINOR(ver) (((ver) >> 16) & 0xff) 27 | #define KOBO_MICRO(ver) (((ver) >> 8) & 0xff) 28 | #define KOBO_BUILD(ver) ((ver) & 0xff) 29 | #define KOBO_VERSION KOBO_MAKE_VERSION(@VERSION_MAJOR@, @VERSION_MINOR@, @VERSION_PATCH@, @VERSION_BUILD@) 30 | 31 | #cmakedefine KOBO_ORGANIZATION "@KOBO_ORGANIZATION@" 32 | #cmakedefine KOBO_APPLICATION "@KOBO_APPLICATION@" 33 | 34 | #cmakedefine KOBO_DATADIR "@KOBO_DATADIR@" 35 | #cmakedefine KOBO_USERDIR "@KOBO_USERDIR@" 36 | #cmakedefine KOBO_EXEFILE "@KOBO_EXEFILE@" 37 | #cmakedefine KOBO_CONFIGFILE "@KOBO_CONFIGFILE@" 38 | 39 | #cmakedefine KOBO_SYSCONFDIR "@KOBO_SYSCONFDIR@" 40 | -------------------------------------------------------------------------------- /clean-all: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | . ./BUILDDEFS 3 | 4 | rm -rf "${BUILDDIR}" 5 | rm -rf "${WORKDIR}" 6 | -------------------------------------------------------------------------------- /configure: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | . ./BUILDDEFS 3 | 4 | # Required for static linking, because CMake doesn't get them from SDL2 5 | if [ "${KOBO_STATIC_LINUX}" = true ] ; then 6 | LINUX_EXTRA_LIBS="-lpthread -ldl -lrt -lm -lpng -lz" 7 | else 8 | LINUX_EXTRA_LIBS="" 9 | fi 10 | 11 | # Similar problem as above, but for Win32 12 | WIN32_EXTRA_LIBS="-lws2_32 -liphlpapi -lz" 13 | 14 | shopt -s extglob 15 | shopt -s nullglob 16 | 17 | if [ $# -eq 0 ]; then 18 | FILTER=@(release|demo) 19 | elif [ "$1" == all ]; then 20 | FILTER="*" 21 | else 22 | FILTER="$1" 23 | fi 24 | 25 | mkdir -p $BUILDDIR 26 | 27 | create_build_dir() { 28 | local dname=$1 29 | local btype=$2 30 | local desc=$3 31 | echo 32 | echo "=== build/$dname ($btype, $desc) ===" 33 | if [ ! -e $BUILDDIR/$dname ]; then 34 | mkdir $BUILDDIR/$dname 35 | fi 36 | if [ ! -e $BUILDDIR/$dname/src ]; then 37 | mkdir $BUILDDIR/$dname/src 38 | fi 39 | cd $BUILDDIR/$dname 40 | } 41 | 42 | setup_header() { 43 | local dname=$1 44 | local desc=$2 45 | echo 46 | echo "==========================================================" 47 | echo "Setting up build dirs for ${dname} ($desc)" 48 | echo "==========================================================" 49 | } 50 | 51 | setup_footer() { 52 | echo 53 | echo "==========================================================" 54 | echo "Done!" 55 | echo "==========================================================" 56 | echo 57 | } 58 | 59 | setup_native() { 60 | local dname=$1 61 | local btype=$2 62 | local desc=$3 63 | local prefix=$4 64 | local opts="$5" 65 | setup_header $dname "$desc" 66 | create_build_dir $dname $btype "$desc" 67 | cmake $opts $SOURCEDIR -DCMAKE_INSTALL_PREFIX=$prefix -DCMAKE_BUILD_TYPE="$btype" -DWORKDIR="${WORKDIR}" -DKOBO_EXTRA_LIBRARIES="${LINUX_EXTRA_LIBS}" 68 | cd $SOURCEDIR 69 | setup_footer 70 | } 71 | 72 | setup_cross() { 73 | local dname=$1 74 | local btype=$2 75 | local desc=$3 76 | local target=$4 77 | local opts="$5 -DWIN32_ZIP_BUILD=ON" 78 | if [ -e $MXEPATH ]; then 79 | setup_header $dname "$desc" 80 | create_build_dir $dname $btype "$desc" 81 | cmake $opts $SOURCEDIR -DCMAKE_BUILD_TYPE="$btype" -DCMAKE_TOOLCHAIN_FILE=$MXEPATH/usr/$target/share/cmake/mxe-conf.cmake -DBUILD_SHARED_LIBS=ON -DWORKDIR="${WORKDIR}" -DKOBO_EXTRA_LIBRARIES="${WIN32_EXTRA_LIBS}" 82 | cd $SOURCEDIR 83 | setup_footer 84 | else 85 | echo "MXE not found! Skipping target ${dname} ($desc)." 86 | fi 87 | } 88 | 89 | if [[ "release" = ${FILTER} ]] ; then 90 | setup_native release Release "host native" /usr 91 | fi 92 | 93 | if [[ "demo" = ${FILTER} ]] ; then 94 | setup_native demo Release "host native DEMO" /usr "-DDEMO_BUILD=ON" 95 | fi 96 | 97 | if [[ "maintainer" = ${FILTER} ]] ; then 98 | setup_native maintainer Maintainer "host native" /usr 99 | fi 100 | 101 | if [[ "debug" = ${FILTER} ]] ; then 102 | setup_native debug Debug "host native" /usr 103 | fi 104 | 105 | if [[ "mingw-release" = ${FILTER} ]] ; then 106 | setup_cross mingw-release Release "MXE cross" i686-w64-mingw32.shared 107 | fi 108 | 109 | if [[ "mingw-demo" = ${FILTER} ]] ; then 110 | setup_cross mingw-demo Release "MXE cross DEMO" i686-w64-mingw32.shared "-DDEMO_BUILD=ON" 111 | fi 112 | 113 | if [[ "mingw-debug" = ${FILTER} ]] ; then 114 | setup_cross mingw-debug Debug "MXE cross" i686-w64-mingw32.shared 115 | fi 116 | -------------------------------------------------------------------------------- /data/demos/demo_0.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/olofson/koboredux/cf92b8a61d002ccaa9fbcda7a96dab08a681dee4/data/demos/demo_0.dat -------------------------------------------------------------------------------- /data/demos/demo_1.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/olofson/koboredux/cf92b8a61d002ccaa9fbcda7a96dab08a681dee4/data/demos/demo_1.dat -------------------------------------------------------------------------------- /data/demos/demo_2.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/olofson/koboredux/cf92b8a61d002ccaa9fbcda7a96dab08a681dee4/data/demos/demo_2.dat -------------------------------------------------------------------------------- /data/gfx/loader/DO64-0.24.gpl: -------------------------------------------------------------------------------- 1 | GIMP Palette 2 | Name: DO64-0.24 3 | Columns: 4 4 | # 5 | 0 0 0 Index 0 6 | 24 24 24 Index 1 7 | 40 40 40 Index 2 8 | 66 66 66 Index 3 9 | 92 92 92 Index 4 10 | 124 124 124 Index 5 11 | 160 160 160 Index 6 12 | 192 192 192 Index 7 13 | 224 224 224 Index 8 14 | 255 255 255 Index 9 15 | 230 199 184 Index 10 16 | 199 166 149 Index 11 17 | 168 134 118 Index 12 18 | 122 94 79 Index 13 19 | 77 58 50 Index 14 20 | 44 34 30 Index 15 21 | 74 23 23 Index 16 22 | 99 24 24 Index 17 23 | 135 27 27 Index 18 24 | 171 40 17 Index 19 25 | 217 70 22 Index 20 26 | 230 112 35 Index 21 27 | 140 116 68 Index 22 28 | 189 161 76 Index 23 29 | 232 159 14 Index 24 30 | 235 193 34 Index 25 31 | 255 237 0 Index 26 32 | 214 230 124 Index 27 33 | 179 219 77 Index 28 34 | 132 201 64 Index 29 35 | 71 184 48 Index 30 36 | 43 145 43 Index 31 37 | 34 110 34 Index 32 38 | 25 80 30 Index 33 39 | 24 70 50 Index 34 40 | 20 44 20 Index 35 41 | 24 59 53 Index 36 42 | 35 92 78 Index 37 43 | 48 120 108 Index 38 44 | 63 158 143 Index 39 45 | 101 201 185 Index 40 46 | 138 230 215 Index 41 47 | 128 206 255 Index 42 48 | 98 177 250 Index 43 49 | 71 140 235 Index 44 50 | 44 106 176 Index 45 51 | 37 79 122 Index 46 52 | 34 59 84 Index 47 53 | 45 107 235 Index 48 54 | 35 83 199 Index 49 55 | 26 58 143 Index 50 56 | 17 41 110 Index 51 57 | 14 28 82 Index 52 58 | 63 36 82 Index 53 59 | 87 41 117 Index 54 60 | 136 68 184 Index 55 61 | 172 96 224 Index 56 62 | 198 136 240 Index 57 63 | 220 182 242 Index 58 64 | 240 158 186 Index 59 65 | 227 127 161 Index 60 66 | 201 98 135 Index 61 67 | 156 69 96 Index 62 68 | 120 48 71 Index 63 69 | -------------------------------------------------------------------------------- /data/gfx/loader/header.theme: -------------------------------------------------------------------------------- 1 | set D_THEMETYPE "loadergfx" 2 | set D_THEMENAME "Loader" 3 | set D_AUTHOR "David Olofson" 4 | set D_CONTACT "david@olofson.net" 5 | set D_COPYRIGHT "Copyright 2017 David Olofson" 6 | set D_LICENSE "CC BY-SA 4.0 (http://creativecommons.org/licenses/by-sa/4.0/)" 7 | -------------------------------------------------------------------------------- /data/gfx/loader/loaderfont.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/olofson/koboredux/cf92b8a61d002ccaa9fbcda7a96dab08a681dee4/data/gfx/loader/loaderfont.png -------------------------------------------------------------------------------- /data/gfx/loader/main.theme: -------------------------------------------------------------------------------- 1 | message "Olofson Arcade Loader Theme for Kobo Redux" 2 | message "Copyright 2016 David Olofson" 3 | message "CC BY-ND 4.0 (http://creativecommons.org/licenses/by-nd/4.0/)" 4 | 5 | //----------------------------------------------------------------------------- 6 | message "Loading loading screen graphics" 7 | //----------------------------------------------------------------------------- 8 | 9 | set D_DASH_LOADER_PLANET 152 12 336 336 // x y w h 10 | 11 | palette P_LOADER "DO64-0.24.gpl" 12 | palette P_LOADER_NOISE P_LOADER 0 1 35 53 33 54 32 55 13 | palette P_LOADER_STARS P_LOADER 1 52 51 2 47 3 46 4 14 | palette P_PROGRESS_BAR P_LOADER 52 51 50 15 | 16 | image B_OALOGO "olofsonarcade-do64-ovl.png" CENTER 17 | image B_OAPLANET "oaplanet-pcb.png" 2 ABSSCALE SCALE2X 18 | 19 | sfont B_LOADER_FONT "loaderfont.png" 20 | alias B_SMALL_FONT B_LOADER_FONT FALLBACK 21 | alias B_NORMAL_FONT B_LOADER_FONT FALLBACK 22 | alias B_MEDIUM_FONT B_LOADER_FONT FALLBACK 23 | alias B_BIG_FONT B_LOADER_FONT FALLBACK 24 | -------------------------------------------------------------------------------- /data/gfx/loader/oaplanet-pcb.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/olofson/koboredux/cf92b8a61d002ccaa9fbcda7a96dab08a681dee4/data/gfx/loader/oaplanet-pcb.png -------------------------------------------------------------------------------- /data/gfx/loader/olofsonarcade-do64-ovl.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/olofson/koboredux/cf92b8a61d002ccaa9fbcda7a96dab08a681dee4/data/gfx/loader/olofsonarcade-do64-ovl.png -------------------------------------------------------------------------------- /data/gfx/mono/HW-ZX-Spectrum.gpl: -------------------------------------------------------------------------------- 1 | GIMP Palette 2 | Name: HW ZX Spectrum 3 | Columns: 8 4 | # https://en.wikipedia.org/wiki/List_of_8-bit_computer_hardware_palettes#ZX_Spectrum 5 | 0 0 0 0 - black 6 | 0 0 170 1 - basic blue 7 | 170 0 0 2 - basic red 8 | 170 0 170 3 - basic magenta 9 | 0 170 0 4 - basic green 10 | 0 170 170 5 - basic cyan 11 | 170 170 0 6 - basic yellow 12 | 170 170 170 7 - basic white 13 | 0 0 0 8 - black 14 | 0 0 255 9 - bright blue 15 | 255 0 0 10 - bright red 16 | 255 0 255 11 - bright magenta 17 | 0 255 0 12 - bright green 18 | 0 255 255 13 - bright cyan 19 | 255 255 0 14 - bright yellow 20 | 255 255 255 15 - bright white 21 | -------------------------------------------------------------------------------- /data/gfx/mono/dashboard/barleds2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/olofson/koboredux/cf92b8a61d002ccaa9fbcda7a96dab08a681dee4/data/gfx/mono/dashboard/barleds2.png -------------------------------------------------------------------------------- /data/gfx/mono/dashboard/bottomleds.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/olofson/koboredux/cf92b8a61d002ccaa9fbcda7a96dab08a681dee4/data/gfx/mono/dashboard/bottomleds.png -------------------------------------------------------------------------------- /data/gfx/mono/dashboard/chargeleds3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/olofson/koboredux/cf92b8a61d002ccaa9fbcda7a96dab08a681dee4/data/gfx/mono/dashboard/chargeleds3.png -------------------------------------------------------------------------------- /data/gfx/mono/dashboard/crosshair.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/olofson/koboredux/cf92b8a61d002ccaa9fbcda7a96dab08a681dee4/data/gfx/mono/dashboard/crosshair.png -------------------------------------------------------------------------------- /data/gfx/mono/dashboard/dashboard-v3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/olofson/koboredux/cf92b8a61d002ccaa9fbcda7a96dab08a681dee4/data/gfx/mono/dashboard/dashboard-v3.png -------------------------------------------------------------------------------- /data/gfx/mono/dashboard/leftleds.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/olofson/koboredux/cf92b8a61d002ccaa9fbcda7a96dab08a681dee4/data/gfx/mono/dashboard/leftleds.png -------------------------------------------------------------------------------- /data/gfx/mono/dashboard/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/olofson/koboredux/cf92b8a61d002ccaa9fbcda7a96dab08a681dee4/data/gfx/mono/dashboard/logo.png -------------------------------------------------------------------------------- /data/gfx/mono/dashboard/rightleds.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/olofson/koboredux/cf92b8a61d002ccaa9fbcda7a96dab08a681dee4/data/gfx/mono/dashboard/rightleds.png -------------------------------------------------------------------------------- /data/gfx/mono/dashboard/topleds.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/olofson/koboredux/cf92b8a61d002ccaa9fbcda7a96dab08a681dee4/data/gfx/mono/dashboard/topleds.png -------------------------------------------------------------------------------- /data/gfx/mono/dashboard/weapons.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/olofson/koboredux/cf92b8a61d002ccaa9fbcda7a96dab08a681dee4/data/gfx/mono/dashboard/weapons.png -------------------------------------------------------------------------------- /data/gfx/mono/dashboard/weaponslots.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/olofson/koboredux/cf92b8a61d002ccaa9fbcda7a96dab08a681dee4/data/gfx/mono/dashboard/weaponslots.png -------------------------------------------------------------------------------- /data/gfx/mono/fonts/bigfont.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/olofson/koboredux/cf92b8a61d002ccaa9fbcda7a96dab08a681dee4/data/gfx/mono/fonts/bigfont.png -------------------------------------------------------------------------------- /data/gfx/mono/fonts/counterfont.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/olofson/koboredux/cf92b8a61d002ccaa9fbcda7a96dab08a681dee4/data/gfx/mono/fonts/counterfont.png -------------------------------------------------------------------------------- /data/gfx/mono/fonts/microfont.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/olofson/koboredux/cf92b8a61d002ccaa9fbcda7a96dab08a681dee4/data/gfx/mono/fonts/microfont.png -------------------------------------------------------------------------------- /data/gfx/mono/fonts/smallfont.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/olofson/koboredux/cf92b8a61d002ccaa9fbcda7a96dab08a681dee4/data/gfx/mono/fonts/smallfont.png -------------------------------------------------------------------------------- /data/gfx/mono/fx/fs-gridtfx-tiles.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/olofson/koboredux/cf92b8a61d002ccaa9fbcda7a96dab08a681dee4/data/gfx/mono/fx/fs-gridtfx-tiles.png -------------------------------------------------------------------------------- /data/gfx/mono/fx/gridfx2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/olofson/koboredux/cf92b8a61d002ccaa9fbcda7a96dab08a681dee4/data/gfx/mono/fx/gridfx2.png -------------------------------------------------------------------------------- /data/gfx/mono/fx/gridtfx-tiles-blue.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/olofson/koboredux/cf92b8a61d002ccaa9fbcda7a96dab08a681dee4/data/gfx/mono/fx/gridtfx-tiles-blue.png -------------------------------------------------------------------------------- /data/gfx/mono/fx/hitnoise.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/olofson/koboredux/cf92b8a61d002ccaa9fbcda7a96dab08a681dee4/data/gfx/mono/fx/hitnoise.png -------------------------------------------------------------------------------- /data/gfx/mono/fx/noise.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/olofson/koboredux/cf92b8a61d002ccaa9fbcda7a96dab08a681dee4/data/gfx/mono/fx/noise.png -------------------------------------------------------------------------------- /data/gfx/mono/fx/shieldfx3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/olofson/koboredux/cf92b8a61d002ccaa9fbcda7a96dab08a681dee4/data/gfx/mono/fx/shieldfx3.png -------------------------------------------------------------------------------- /data/gfx/mono/header.theme: -------------------------------------------------------------------------------- 1 | set D_THEMETYPE "gamegfx" 2 | set D_THEMENAME "Mono" 3 | set D_AUTHOR "David Olofson" 4 | set D_CONTACT "david@olofson.net" 5 | set D_COPYRIGHT "Copyright 2017 David Olofson" 6 | set D_LICENSE "CC BY-SA 4.0 (http://creativecommons.org/licenses/by-sa/4.0/)" 7 | -------------------------------------------------------------------------------- /data/gfx/mono/region-1/ground-l10.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/olofson/koboredux/cf92b8a61d002ccaa9fbcda7a96dab08a681dee4/data/gfx/mono/region-1/ground-l10.png -------------------------------------------------------------------------------- /data/gfx/mono/region-1/ground-l8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/olofson/koboredux/cf92b8a61d002ccaa9fbcda7a96dab08a681dee4/data/gfx/mono/region-1/ground-l8.png -------------------------------------------------------------------------------- /data/gfx/mono/region-1/planet.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/olofson/koboredux/cf92b8a61d002ccaa9fbcda7a96dab08a681dee4/data/gfx/mono/region-1/planet.png -------------------------------------------------------------------------------- /data/gfx/mono/region-1/tiles-clean.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/olofson/koboredux/cf92b8a61d002ccaa9fbcda7a96dab08a681dee4/data/gfx/mono/region-1/tiles-clean.png -------------------------------------------------------------------------------- /data/gfx/mono/region-1/tiles-small.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/olofson/koboredux/cf92b8a61d002ccaa9fbcda7a96dab08a681dee4/data/gfx/mono/region-1/tiles-small.png -------------------------------------------------------------------------------- /data/gfx/mono/region-1/tiles-tiny.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/olofson/koboredux/cf92b8a61d002ccaa9fbcda7a96dab08a681dee4/data/gfx/mono/region-1/tiles-tiny.png -------------------------------------------------------------------------------- /data/gfx/mono/space.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/olofson/koboredux/cf92b8a61d002ccaa9fbcda7a96dab08a681dee4/data/gfx/mono/space.png -------------------------------------------------------------------------------- /data/gfx/mono/sprites/bigship.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/olofson/koboredux/cf92b8a61d002ccaa9fbcda7a96dab08a681dee4/data/gfx/mono/sprites/bigship.png -------------------------------------------------------------------------------- /data/gfx/mono/sprites/bluebullet.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/olofson/koboredux/cf92b8a61d002ccaa9fbcda7a96dab08a681dee4/data/gfx/mono/sprites/bluebullet.png -------------------------------------------------------------------------------- /data/gfx/mono/sprites/bluebulletexpl.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/olofson/koboredux/cf92b8a61d002ccaa9fbcda7a96dab08a681dee4/data/gfx/mono/sprites/bluebulletexpl.png -------------------------------------------------------------------------------- /data/gfx/mono/sprites/bmr1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/olofson/koboredux/cf92b8a61d002ccaa9fbcda7a96dab08a681dee4/data/gfx/mono/sprites/bmr1.png -------------------------------------------------------------------------------- /data/gfx/mono/sprites/bmr2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/olofson/koboredux/cf92b8a61d002ccaa9fbcda7a96dab08a681dee4/data/gfx/mono/sprites/bmr2.png -------------------------------------------------------------------------------- /data/gfx/mono/sprites/bmr3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/olofson/koboredux/cf92b8a61d002ccaa9fbcda7a96dab08a681dee4/data/gfx/mono/sprites/bmr3.png -------------------------------------------------------------------------------- /data/gfx/mono/sprites/bolt.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/olofson/koboredux/cf92b8a61d002ccaa9fbcda7a96dab08a681dee4/data/gfx/mono/sprites/bolt.png -------------------------------------------------------------------------------- /data/gfx/mono/sprites/bomb.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/olofson/koboredux/cf92b8a61d002ccaa9fbcda7a96dab08a681dee4/data/gfx/mono/sprites/bomb.png -------------------------------------------------------------------------------- /data/gfx/mono/sprites/bombdeto.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/olofson/koboredux/cf92b8a61d002ccaa9fbcda7a96dab08a681dee4/data/gfx/mono/sprites/bombdeto.png -------------------------------------------------------------------------------- /data/gfx/mono/sprites/fighter.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/olofson/koboredux/cf92b8a61d002ccaa9fbcda7a96dab08a681dee4/data/gfx/mono/sprites/fighter.png -------------------------------------------------------------------------------- /data/gfx/mono/sprites/greenbullet.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/olofson/koboredux/cf92b8a61d002ccaa9fbcda7a96dab08a681dee4/data/gfx/mono/sprites/greenbullet.png -------------------------------------------------------------------------------- /data/gfx/mono/sprites/greenbulletexpl.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/olofson/koboredux/cf92b8a61d002ccaa9fbcda7a96dab08a681dee4/data/gfx/mono/sprites/greenbulletexpl.png -------------------------------------------------------------------------------- /data/gfx/mono/sprites/kobo-mk3s.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/olofson/koboredux/cf92b8a61d002ccaa9fbcda7a96dab08a681dee4/data/gfx/mono/sprites/kobo-mk3s.png -------------------------------------------------------------------------------- /data/gfx/mono/sprites/missile.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/olofson/koboredux/cf92b8a61d002ccaa9fbcda7a96dab08a681dee4/data/gfx/mono/sprites/missile.png -------------------------------------------------------------------------------- /data/gfx/mono/sprites/missile2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/olofson/koboredux/cf92b8a61d002ccaa9fbcda7a96dab08a681dee4/data/gfx/mono/sprites/missile2.png -------------------------------------------------------------------------------- /data/gfx/mono/sprites/missile3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/olofson/koboredux/cf92b8a61d002ccaa9fbcda7a96dab08a681dee4/data/gfx/mono/sprites/missile3.png -------------------------------------------------------------------------------- /data/gfx/mono/sprites/redbullet.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/olofson/koboredux/cf92b8a61d002ccaa9fbcda7a96dab08a681dee4/data/gfx/mono/sprites/redbullet.png -------------------------------------------------------------------------------- /data/gfx/mono/sprites/redbulletexpl.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/olofson/koboredux/cf92b8a61d002ccaa9fbcda7a96dab08a681dee4/data/gfx/mono/sprites/redbulletexpl.png -------------------------------------------------------------------------------- /data/gfx/mono/sprites/ring.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/olofson/koboredux/cf92b8a61d002ccaa9fbcda7a96dab08a681dee4/data/gfx/mono/sprites/ring.png -------------------------------------------------------------------------------- /data/gfx/mono/sprites/ringexpl.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/olofson/koboredux/cf92b8a61d002ccaa9fbcda7a96dab08a681dee4/data/gfx/mono/sprites/ringexpl.png -------------------------------------------------------------------------------- /data/gfx/mono/sprites/rock.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/olofson/koboredux/cf92b8a61d002ccaa9fbcda7a96dab08a681dee4/data/gfx/mono/sprites/rock.png -------------------------------------------------------------------------------- /data/gfx/mono/sprites/rockexpl.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/olofson/koboredux/cf92b8a61d002ccaa9fbcda7a96dab08a681dee4/data/gfx/mono/sprites/rockexpl.png -------------------------------------------------------------------------------- /data/gfx/tools/header.theme: -------------------------------------------------------------------------------- 1 | set D_THEMETYPE "toolsgfx" 2 | set D_THEMENAME "Tools" 3 | set D_AUTHOR "David Olofson" 4 | set D_CONTACT "david@olofson.net" 5 | set D_COPYRIGHT "Copyright 2017 David Olofson" 6 | set D_LICENSE "CC BY-SA 4.0 (http://creativecommons.org/licenses/by-sa/4.0/)" 7 | -------------------------------------------------------------------------------- /data/gfx/tools/main.theme: -------------------------------------------------------------------------------- 1 | message "Kobo Redux Tools Theme" 2 | message "Copyright 2016-2017 David Olofson" 3 | message "CC BY-SA 4.0 (http://creativecommons.org/licenses/by-sa/4.0/)" 4 | 5 | //----------------------------------------------------------------------------- 6 | message "Loading graphics for tools" 7 | //----------------------------------------------------------------------------- 8 | 9 | path "" 10 | sprites B_SOUND_ICONS "soundicons.png" 16 16 CENTER 11 | sfont B_DEBUG_FONT "microfont2.png" 1 ABSSCALE 12 | sfont B_TOOL_FONT "microfont3.png" 13 | 14 | set D_SOUNDTOOLS_HOTKEYS 0 151 104 71 D_DASH_CONSOLE 15 | set D_SOUNDTOOLS_SYMNAME 0 223 104 16 D_DASH_CONSOLE 16 | set D_SOUNDTOOLS_GRPNAME 0 240 104 16 D_DASH_CONSOLE 17 | 18 | set D_PFXTOOLS_HOTKEYS 0 214 128 25 D_DASH_RADAR 19 | set D_PFXTOOLS_SYMNAME 0 240 128 16 D_DASH_RADAR 20 | -------------------------------------------------------------------------------- /data/gfx/tools/microfont2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/olofson/koboredux/cf92b8a61d002ccaa9fbcda7a96dab08a681dee4/data/gfx/tools/microfont2.png -------------------------------------------------------------------------------- /data/gfx/tools/microfont3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/olofson/koboredux/cf92b8a61d002ccaa9fbcda7a96dab08a681dee4/data/gfx/tools/microfont3.png -------------------------------------------------------------------------------- /data/gfx/tools/soundicons.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/olofson/koboredux/cf92b8a61d002ccaa9fbcda7a96dab08a681dee4/data/gfx/tools/soundicons.png -------------------------------------------------------------------------------- /data/sfx/chip/header.theme: -------------------------------------------------------------------------------- 1 | set D_THEMETYPE "gamesfx" 2 | set D_THEMENAME "Chip" 3 | set D_AUTHOR "David Olofson" 4 | set D_CONTACT "david@olofson.net" 5 | set D_COPYRIGHT "Copyright 2017 David Olofson" 6 | set D_LICENSE "CC BY-SA 4.0 (http://creativecommons.org/licenses/by-sa/4.0/)" 7 | -------------------------------------------------------------------------------- /data/sfx/chip/main.a2s: -------------------------------------------------------------------------------- 1 | def title "KRChip" 2 | def version "1.0.0" 3 | def description "Kobo Redux Chip Sound Theme" 4 | def author "David Olofson" 5 | def copyright "Copyright 2016 David Olofson" 6 | def license "GPL" 7 | def a2sversion "1.9.1" 8 | 9 | 10 | ////////////////////////////////// 11 | // Master section 12 | ////////////////////////////////// 13 | 14 | export import "master.a2s" 15 | 16 | 17 | ////////////////////////////////// 18 | // Game sound effects 19 | ////////////////////////////////// 20 | 21 | export import "sfx.a2s" 22 | 23 | 24 | ////////////////////////////////// 25 | // UI sound effects 26 | ////////////////////////////////// 27 | 28 | export import "uisfx.a2s" 29 | 30 | 31 | ////////////////////////////////// 32 | // Music 33 | ////////////////////////////////// 34 | 35 | TitleSong() 36 | { 37 | struct { 38 | wtosc o1; wtosc o1b 39 | wtosc o2; wtosc o2b 40 | env o3e; wtosc o3 41 | wire o3e.out o3.a 42 | } 43 | o1.w pulse30; o1b.w pulse40 44 | o2.w saw; o2b.w saw 45 | o3.w noise 46 | 47 | !base (rand 6n quant 1n) 48 | 49 | //Intro 50 | o1.p (base - 36n1); o1b.p (o1.p + 0n2); set 51 | o1.a .15; o1b.a .15 52 | d 1000 53 | 54 | o2.p (base - 12n); o2b.p (o2.p + 8n05); set 55 | o2.a .2; o2b.a .2; ramp o2.a 4000; ramp o2b.a 4000 56 | d 2000 57 | 58 | -o2b.p 1n; ramp o2b.p 1000 59 | d 3000 60 | 61 | o2.a 0; o2b.a 0 62 | @o3.p 3; o3e.mode o3e.IEXP3 63 | d 2000 64 | 65 | for { 66 | // Calculate harmony 67 | o1.p (base - 36n1); o1b.p (o1.p + 0n2) 68 | o2.p (base + 3n + (rand 7n quant 4n) - 12n) 69 | o2b.p (o2.p + 7n05) 70 | set 71 | 72 | // 1 73 | @o3.p (rand .5) 74 | @o3e.target .6; o3e.target 0; ramp o3e.target 4000 75 | o1.a .3; o1b.a .3 76 | o2.a .2; o2b.a .2 77 | d 2000 78 | 79 | // 2 80 | @o3.p (1 + rand .5) 81 | @o3e.target .5; o3e.target 0; ramp o3e.target 4000 82 | o1.a .1; o1b.a .1 83 | o2.a .1; o2b.a .1 84 | d 2000 85 | 86 | // 3 87 | @o3.p (2 + rand .5) 88 | @o3e.target .3; o3e.target 0; ramp o3e.target 4000 89 | o1.a .2; o1b.a .2 90 | o2.a 0; o2b.a 0 91 | d 2000 92 | 93 | // 4 94 | @o3.p (3 + rand .5) 95 | @o3e.target .25; o3e.target 0; ramp o3e.target 4000 96 | base (rand 6n quant 1n) 97 | !nb (base - 36n1) 98 | 200 { 99 | +o1.p (nb - o1.p * .02); o1b.p (o1.p + 0n2) 100 | d 10 101 | } 102 | } 103 | } 104 | 105 | export S_TITLESONG() 106 | { 107 | struct { 108 | inline 0 1 109 | fbdelay 1 2 110 | panmix 2 > 111 | } 112 | fbdelay 900; fbgain .3 113 | ldelay 976; lgain .2 114 | rdelay 1133; rgain .2 115 | vol .5 116 | set 117 | 1:TitleSong 118 | end 119 | .stop vol 0; d 1000 120 | kill 1 121 | 1() { 122 | force stop 123 | } 124 | } 125 | 126 | 127 | IngameSong() 128 | { 129 | struct { 130 | wtosc o1 131 | wtosc o2 132 | wtosc o3 133 | } 134 | 135 | o1.w noise; o2.w noise; o3.w noise 136 | o1.p 0; o2.p 1; o3.p 3; set 137 | 138 | for { 139 | o1.p (rand 1 - .5); o2.p (rand 2); o3.p (rand 2 + 2) 140 | o1.a (rand .4); o2.a (rand .2); o3.a (rand .1) 141 | d 3000 142 | } 143 | } 144 | 145 | export S_INGAMESONG1() 146 | { 147 | struct { 148 | inline 0 2 149 | fbdelay 2 2 150 | panmix 2 > 151 | } 152 | fbdelay 1500; fbgain .5 153 | ldelay 1333; lgain .5 154 | rdelay 1444; rgain .5 155 | vol .1 156 | set 157 | 1:IngameSong 158 | end 159 | .stop vol 0; d 1000 160 | kill 1 161 | 1() { 162 | force stop 163 | } 164 | } 165 | export def S_INGAMESONG2 S_INGAMESONG1 166 | export def S_INGAMESONG3 S_INGAMESONG1 167 | export def S_INGAMESONG4 S_INGAMESONG1 168 | export def S_INGAMESONG5 S_INGAMESONG1 169 | -------------------------------------------------------------------------------- /data/sfx/chip/master.a2s: -------------------------------------------------------------------------------- 1 | def title "KRChipMaster" 2 | def version "1.0.0" 3 | def description "Kobo Redux Chip Sound Theme - Master Section" 4 | def author "David Olofson" 5 | def copyright "Copyright 2016-2017 David Olofson" 6 | def license "GPL" 7 | def a2sversion "1.9.1" 8 | 9 | def FADETIME 250 10 | 11 | MasterGroup() 12 | { 13 | struct { 14 | inline 0 2 15 | dcblock DCB 2 2 16 | waveshaper WS 2 2 17 | panmix PM 2 > 18 | } 19 | DCB.cutoff 10f 20 | WS.amount .5 21 | PM.vol .5 22 | set 23 | 2(V Dur=FADETIME) 24 | { 25 | PM.vol V 26 | ramp PM.vol Dur 27 | } 28 | 3(WSA Dur=FADETIME) 29 | { 30 | WS.amount (WSA * .25) 31 | ramp WS.amount Dur 32 | } 33 | } 34 | 35 | SubGroup() 36 | { 37 | struct { 38 | inline 0 2 39 | panmix PM 2 > 40 | } 41 | PM.vol .5 42 | set 43 | 2(V Dur=FADETIME) 44 | { 45 | PM.vol V 46 | ramp PM.vol Dur 47 | } 48 | } 49 | 50 | MonoGroup() 51 | { 52 | struct { 53 | inline 0 1 54 | panmix PM 1 > 55 | } 56 | PM.vol .5 57 | set 58 | 2(V Dur=FADETIME) 59 | { 60 | PM.vol V 61 | ramp PM.vol Dur 62 | } 63 | } 64 | 65 | export def S_G_MASTER MasterGroup 66 | export def S_G_UI MonoGroup 67 | export def S_G_SFX SubGroup 68 | export def S_G_MUSIC SubGroup 69 | export def S_G_TITLE SubGroup 70 | -------------------------------------------------------------------------------- /data/sfx/chip/uisfx.a2s: -------------------------------------------------------------------------------- 1 | def title "KRChipUISFX" 2 | def version "1.0.0" 3 | def description "Kobo Redux Chip Sound Theme - UI" 4 | def author "David Olofson" 5 | def copyright "Copyright 2016 David Olofson" 6 | def license "GPL" 7 | def a2sversion "1.9.1" 8 | 9 | export S_UI_OPEN() 10 | { 11 | struct { wtosc } 12 | w triangle 13 | @p -3 14 | a 1 15 | 10 { 16 | +p .15 17 | d 10 18 | } 19 | a 0; d 50 20 | } 21 | 22 | export S_UI_OK() 23 | { 24 | struct { wtosc } 25 | w triangle 26 | @p .5 27 | a 1 28 | 15 { 29 | -p .3 30 | d 10 31 | } 32 | a 0; d 100 33 | } 34 | 35 | export S_UI_MOVE() 36 | { 37 | struct { wtosc } 38 | w square 39 | @p 4; @a .03 40 | p 4; a 0; d 5 41 | w noise 42 | @p 0; 43 | p 1; a .005; d 100 44 | p 0; a 0; d 200 45 | } 46 | 47 | export S_UI_TICK() 48 | { 49 | struct { wtosc } 50 | w square 51 | @p 3 52 | @a .1; d 10 53 | @a 0 54 | } 55 | 56 | export S_UI_CDTICK(P V=1) 57 | { 58 | struct { wtosc } 59 | +tr P 60 | w pulse10 61 | a (V * .2); set a 62 | @p 0; d 10 63 | @p 1; d 10 64 | @p 2; d 10 65 | @p 3; d 10 66 | 100 { 67 | *a .8; d 10 68 | } 69 | a 0; d 10 70 | } 71 | 72 | export S_UI_GAMEOVER() 73 | { 74 | struct { wtosc } 75 | w pulse10 76 | a .4 77 | @p 0 78 | p -3; d 2000 79 | a 0; d 10 80 | } 81 | 82 | export S_UI_READY() 83 | { 84 | struct { wtosc } 85 | tempo 120 32 86 | w triangle 87 | a .2 88 | tr -1 89 | 15 { 90 | @p 0n; td 1 91 | @p 4n; td 1 92 | @p 7n; td 1 93 | @p 4n; td 1 94 | +tr 1n 95 | +a .025 96 | } 97 | -tr 1n 98 | 10 { 99 | *a .5 100 | 3 { 101 | @p 0n; td 1 102 | @p 4n; td 1 103 | @p 7n; td 1 104 | @p 4n; td 1 105 | } 106 | } 107 | a 0 108 | d 20 109 | } 110 | 111 | export S_UI_PLAY() 112 | { 113 | struct { wtosc } 114 | tempo 120 16 115 | w saw 116 | a .2 117 | tr 0 118 | 3 { 119 | @p 0; td 1 120 | @p 4n; td 1 121 | @p 7n; td 1 122 | @p 4n; td 1 123 | +tr 1 124 | } 125 | -tr 1 126 | 5 { 127 | *a .25 128 | @p 0; td 1 129 | @p 4n; td 1 130 | @p 7n; td 1 131 | @p 4n; td 1 132 | } 133 | a 0 134 | d 20 135 | } 136 | 137 | export S_UI_PAUSE() 138 | { 139 | struct { wtosc } 140 | tempo 120 16 141 | w saw 142 | a .05 143 | tr 2 144 | 2 { 145 | @p 4n; td 1 146 | @p 7n; td 1 147 | @p 4n; td 1 148 | @p 0; td 1 149 | +a .05 150 | } 151 | a .2 152 | 3 { 153 | -tr 1 154 | @p 4n; td 1 155 | @p 7n; td 1 156 | @p 4n; td 1 157 | @p 0; td 1 158 | } 159 | -tr 1 160 | a 0 161 | d 20 162 | } 163 | 164 | export S_UI_CANCEL() 165 | { 166 | struct { wtosc } 167 | w triangle 168 | 5 { 169 | @p 1; a .35; d 10 170 | @p 0; a 0; d 10 171 | } 172 | } 173 | 174 | export S_UI_ERROR() 175 | { 176 | struct { wtosc } 177 | w square 178 | 10 { 179 | @p 2.5; @a .15; d 10 180 | @p 1.5; a 0; d 10 181 | } 182 | } 183 | 184 | export S_UI_LOADER() 185 | { 186 | struct { wtosc } 187 | w square; a .02 188 | for { 189 | if (rand 1 > .5) { 190 | @p 2400f 191 | } else { 192 | @p 1200f 193 | } 194 | d (1000 / 600) 195 | } 196 | .stop 197 | a 0; d 1 198 | 199 | 1() { 200 | force stop 201 | } 202 | } 203 | 204 | export S_UI_NOISE() 205 | { 206 | struct { wtosc } 207 | w noise; @p 4 208 | !running 1 209 | while running { 210 | @a .1; a 0; d 10 211 | d 10 212 | } 213 | 214 | 1() { 215 | running 0 216 | } 217 | } 218 | -------------------------------------------------------------------------------- /data/sfx/loader/header.theme: -------------------------------------------------------------------------------- 1 | set D_THEMETYPE "loadersfx" 2 | set D_THEMENAME "Loader" 3 | set D_AUTHOR "David Olofson" 4 | set D_CONTACT "david@olofson.net" 5 | set D_COPYRIGHT "Copyright 2017 David Olofson" 6 | set D_LICENSE "CC BY-SA 4.0 (http://creativecommons.org/licenses/by-sa/4.0/)" 7 | -------------------------------------------------------------------------------- /data/sfx/loader/main.a2s: -------------------------------------------------------------------------------- 1 | def title "OAJingleTheme" 2 | def version "1.0.0" 3 | def description "Olofson Arcade Jingle Theme" 4 | def author "David Olofson" 5 | def copyright "Copyright 2016 David Olofson" 6 | def license "CC BY-NC-ND 3.0" 7 | def a2sversion "1.9.1" 8 | 9 | import "oajingle-short.a2s" as aoj 10 | export def S_OAJINGLE aoj.Song 11 | -------------------------------------------------------------------------------- /fix-linux-bz2-package: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | . ./BUILDDEFS 3 | 4 | set -ex 5 | 6 | PKGPATH=$1 7 | ARCHNAME=$(basename ${PKGPATH%}) 8 | PKGNAME=${ARCHNAME%.*.*} 9 | [[ "${PKGNAME}" == *"demo"* ]] && DEMO="-demo" || DEMO="" 10 | 11 | cd $(dirname "${PKGPATH}") 12 | 13 | echo "Flattening package ${PKGNAME}..." 14 | 15 | # Extract 16 | tar -xjvf ${ARCHNAME} 17 | if [ ! -d "${PKGNAME}/usr" ] ; then 18 | echo "This package has already been flattened!" 19 | rm -rf ${PKGNAME} 20 | exit 21 | fi 22 | rm -f ${ARCHNAME} 23 | ORIGPKG="${PKGNAME}.orig" 24 | mv ${PKGNAME} ${ORIGPKG} 25 | 26 | # Rebuild 27 | mkdir ${PKGNAME} 28 | mv ${ORIGPKG}/usr/bin/kobord${DEMO} ${PKGNAME} 29 | mv ${ORIGPKG}/usr/share/koboredux${DEMO}/* ${PKGNAME} 30 | mv ${ORIGPKG}/usr/share/doc/koboredux${DEMO}/* ${PKGNAME} 31 | mv ${PKGNAME}/copyright ${PKGNAME}/EULA.txt 32 | 33 | ITCHMANIFEST="itch.toml" 34 | if [[ ! "${DEMO}" == "" ]] ; then 35 | ITCHMANIFEST="demo.${ITCHMANIFEST}" 36 | fi 37 | if [ "${KOBO_STATIC_LINUX}" = true ] ; then 38 | ITCHMANIFEST="static.${ITCHMANIFEST}" 39 | else 40 | mkdir ${PKGNAME}/lib 41 | cp ${WORKDIR}/linux-bundle-lib/* ${PKGNAME}/lib 42 | cp ${SOURCEDIR}/linux-bundle/kobord${DEMO}.sh ${PKGNAME} 43 | cp ${SOURCEDIR}/linux-bundle/koboredux${DEMO}.desktop ${PKGNAME} 44 | fi 45 | cp ${SOURCEDIR}/linux-bundle/${ITCHMANIFEST} ${PKGNAME}/.itch.toml 46 | 47 | # Archive 48 | BZIP2=--best tar -cvjSf ${ARCHNAME} ${PKGNAME} 49 | 50 | # Clean up 51 | rm -rf ${PKGNAME} 52 | rm -rf ${ORIGPKG} 53 | 54 | echo "Package ${PKGNAME} flattened!" 55 | -------------------------------------------------------------------------------- /fix-linux-deb-package: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # === THIS SCRIPT NEEDS TO RUN AS (FAKE)ROOT === 4 | # 5 | . ./BUILDDEFS 6 | 7 | set -ex 8 | 9 | PKGFILE=$1 10 | PKGTMP="${WORKDIR}/$(basename ${PKGFILE}).tmp" 11 | rm -rf ${PKGTMP} 12 | 13 | # Unpack 14 | mkdir ${PKGTMP} 15 | dpkg-deb -R ${PKGFILE} ${PKGTMP} 16 | rm ${PKGFILE} 17 | cd ${PKGTMP} 18 | 19 | # Generate new md5sums 20 | find . -type f ! -regex '.*.hg.*' ! -regex '.*?debian-binary.*' ! -regex '.*?DEBIAN.*' -printf '%P ' | xargs md5sum > DEBIAN/md5sums 21 | chmod 644 DEBIAN/md5sums 22 | 23 | # Fix bogus permissions 24 | find . -type d -print0 | xargs -0 chmod 755 25 | find usr/share -type f -print0 | xargs -0 chmod 644 26 | find usr/bin -type f -print0 | xargs -0 chmod 755 27 | 28 | # Repackage and clean up 29 | cd .. 30 | dpkg-deb -b ${PKGTMP} ${PKGFILE} 31 | rm -rf ${PKGTMP} 32 | -------------------------------------------------------------------------------- /fix-linux-rpm-package: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | . ./BUILDDEFS 3 | 4 | # Create RPM spec file from existing RPM 5 | create_rpm_spec() { 6 | local package=$1 7 | local spec=$2 8 | rpm -qp --qf "Name: %{NAME} 9 | Version: %{VERSION} 10 | Release: %{RELEASE} 11 | BuildArch: %{ARCH} 12 | Group: %{GROUP} 13 | License: %{LICENSE} 14 | Source RPM: %{SOURCERPM} 15 | Vendor: Olofson Arcade 16 | Packager: David Olofson 17 | URL: %{URL} 18 | Summary: %{SUMMARY} 19 | 20 | %%description 21 | %{DESCRIPTION} 22 | 23 | %%files 24 | /usr/bin/* 25 | /usr/share/doc/* 26 | /usr/share/kobo*/* 27 | /usr/share/applications/* 28 | /usr/share/pixmaps/* 29 | " ${package} > ${spec} 30 | } 31 | 32 | set -ex 33 | 34 | PKGFILE=$1 35 | PKGTMP="${WORKDIR}/$(basename ${PKGFILE}).tmp" 36 | rm -rf ${PKGTMP} 37 | 38 | # Unpack 39 | mkdir ${PKGTMP} 40 | cd ${PKGTMP} 41 | rpm2cpio ${PKGFILE} | cpio -idmv 42 | cd .. 43 | 44 | # Fix bogus permissions 45 | find "${PKGTMP}/." -type d -print0 | xargs -0 chmod 755 46 | find "${PKGTMP}/usr/share" -type f -print0 | xargs -0 chmod 644 47 | find "${PKGTMP}/usr/bin" -type f -print0 | xargs -0 chmod 755 48 | 49 | create_rpm_spec ${PKGFILE} "${WORKDIR}/koboredux.spec" 50 | echo "--- Generated spec ---" 51 | cat "${WORKDIR}/koboredux.spec" 52 | echo "----------------------" 53 | 54 | # Repackage and clean up 55 | archdir=$(rpm -qp --qf "%{ARCH}" ${PKGFILE}) 56 | rm ${PKGFILE} 57 | rpmbuild --buildroot "${PKGTMP}" --define "_rpmdir $(pwd)" -bb "${WORKDIR}/koboredux.spec" 58 | mv ${archdir}/*.rpm ${PKGFILE} 59 | rm -rf ${archdir} 60 | rm "${WORKDIR}/koboredux.spec" 61 | rm -rf ${PKGTMP} 62 | -------------------------------------------------------------------------------- /icons/koboredux.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/olofson/koboredux/cf92b8a61d002ccaa9fbcda7a96dab08a681dee4/icons/koboredux.png -------------------------------------------------------------------------------- /icons/net.olofson.koboredux-demo.desktop: -------------------------------------------------------------------------------- 1 | [Desktop Entry] 2 | Version=1.0 3 | Type=Application 4 | Name=Kobo Redux Demo 5 | GenericName=Arcade Game 6 | Comment=Arcade style 2D shooter (Demo version) 7 | TryExec=kobord-demo 8 | Exec=kobord-demo 9 | Icon=koboredux-demo 10 | Terminal=false 11 | Categories=Application;Game;ArcadeGame;2DGraphics; 12 | -------------------------------------------------------------------------------- /icons/net.olofson.koboredux.desktop: -------------------------------------------------------------------------------- 1 | [Desktop Entry] 2 | Version=1.0 3 | Type=Application 4 | Name=Kobo Redux 5 | GenericName=Arcade Game 6 | Comment=Arcade style 2D shooter 7 | TryExec=kobord 8 | Exec=kobord 9 | Icon=koboredux 10 | Terminal=false 11 | Categories=Application;Game;ArcadeGame;2DGraphics; 12 | -------------------------------------------------------------------------------- /icons/windows/kobord.rc: -------------------------------------------------------------------------------- 1 | 1 ICON "koboredux.ico" 2 | -------------------------------------------------------------------------------- /icons/windows/koboredux.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/olofson/koboredux/cf92b8a61d002ccaa9fbcda7a96dab08a681dee4/icons/windows/koboredux.ico -------------------------------------------------------------------------------- /install-data: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # This script checks out and prepares the full version Kobo Redux data files. 4 | # (Of course, this will not work without access to the private repository.) 5 | # 6 | . ./BUILDDEFS 7 | 8 | if [ $# -eq 2 ]; then 9 | TAG="$1" 10 | DATADIR="$2" 11 | else 12 | echo "Usage: install-data " 13 | exit 1 14 | fi 15 | 16 | if [ -d "${WORKDIR}/${DATADIR}" ]; then 17 | # TODO: Check if it's the right version. If not, overwrite! 18 | echo "Data directory ${DATADIR} already exists!" 19 | exit 0 20 | fi 21 | 22 | set -ex 23 | 24 | render=false 25 | 26 | # Clone or update repository as needed 27 | if [ ! -d "${DLDIR}" ]; then 28 | mkdir -p "${DLDIR}" 29 | fi 30 | cd ${DLDIR} 31 | if [ ! -d "koboreduxassets" ]; then 32 | git clone git@github.com:olofson/koboreduxassets.git 33 | cd koboreduxassets 34 | git checkout ${TAG} 35 | render=true 36 | else 37 | cd koboreduxassets 38 | if ! git checkout ${TAG} ; then 39 | git checkout master 40 | git pull 41 | git checkout ${TAG} 42 | render=true 43 | fi 44 | git clean -d -x -f 45 | fi 46 | 47 | # Render the TIPE sprites 48 | cd src 49 | eel render-sprites 50 | cd .. 51 | 52 | # Copy the checked out and rendered data to the destination directory 53 | if [ ! -d "${WORKDIR}" ]; then 54 | mkdir "${WORKDIR}" 55 | fi 56 | cp -r "${DLDIR}/koboreduxassets/data" "${WORKDIR}/${DATADIR}" 57 | echo ${TAG} > "${WORKDIR}/${DATADIR}/DATAVERSION" 58 | -------------------------------------------------------------------------------- /install-libs: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | . ./BUILDDEFS 3 | 4 | # FIXME: Grab libs from system if we build dynamic, but don't build libs here! 5 | 6 | set -ex 7 | 8 | if [ ! -d "${WORKDIR}/libs-build" ]; then 9 | mkdir -p "${WORKDIR}/libs-build" 10 | fi 11 | 12 | rm -rf "${WORKDIR}/linux-bundle-lib" 13 | if [ "${KOBO_STATIC_LINUX}" = true ] ; then 14 | AUTOTOOLS_EXTRA="--enable-static --disable-shared" 15 | LIBPNG_FLAGS="--enable-png --disable-png-shared" 16 | CMAKE_EXTRA="-DBUILD_SHARED_LIBS=OFF" 17 | else 18 | AUTOTOOLS_EXTRA="--disable-static --enable-shared" 19 | LIBPNG_FLAGS="--enable-png --enable-png-shared" 20 | CMAKE_EXTRA="-DBUILD_SHARED_LIBS=ON" 21 | mkdir "${WORKDIR}/linux-bundle-lib" 22 | fi 23 | 24 | cd "${WORKDIR}/libs-build" 25 | 26 | # SDL2 27 | if pkg-config sdl2 --exists; then 28 | echo "SDL2 already installed in the system!" 29 | else 30 | if [ ! -f "SDL2-${SDLRELEASE}.tar.gz" ]; then 31 | curl -O ${SDLURL} 32 | fi 33 | tar -xzvf "SDL2-${SDLRELEASE}.tar.gz" 34 | cd SDL2-${SDLRELEASE} 35 | ./configure --prefix=/usr ${AUTOTOOLS_EXTRA} 36 | make 37 | sudo make install 38 | if [ ! "${KOBO_STATIC_LINUX}" = true ] ; then 39 | cp -L build/.libs/libSDL2-*.so.0 "${WORKDIR}/linux-bundle-lib" 40 | fi 41 | cd .. 42 | fi 43 | 44 | # libPNG 45 | if [ -f "/usr/include/png.h" ]; then 46 | echo "libpng already installed in the system!" 47 | else 48 | if [ ! -f "libpng-${PNGRELEASE}.tar.xz" ]; then 49 | curl -O ${PNGURL} 50 | fi 51 | tar -xf "libpng-${PNGRELEASE}.tar.xz" 52 | cd libpng-${PNGRELEASE} 53 | ./configure --prefix=/usr ${AUTOTOOLS_EXTRA} 54 | make 55 | sudo make install 56 | if [ ! "${KOBO_STATIC_LINUX}" = true ] ; then 57 | cp -L build/.libs/libSDL2-*.so.0 "${WORKDIR}/linux-bundle-lib" 58 | fi 59 | cd .. 60 | fi 61 | 62 | # SDL2_image 63 | if [ -f "/usr/include/SDL2/SDL_image.h" ]; then 64 | echo "SDL2_image already installed in the system!" 65 | else 66 | if [ ! -f "SDL2_image-${IMGRELEASE}.tar.gz" ]; then 67 | curl -O ${IMGURL} 68 | fi 69 | tar -xzvf "SDL2_image-${IMGRELEASE}.tar.gz" 70 | cd SDL2_image-${IMGRELEASE} 71 | ./configure --prefix=/usr ${AUTOTOOLS_EXTRA} ${LIBPNG_FLAGS} --disable-bmp --disable-gif --disable-jpg --disable-jpg-shared --disable-lbm --disable-pcx --disable-pnm --disable-tga --disable-tif --disable-tif-shared --disable-xcf --disable-xpm --disable-xv --disable-webp --disable-webp-shared 72 | make 73 | sudo make install 74 | if [ ! "${KOBO_STATIC_LINUX}" = true ] ; then 75 | cp -L .libs/libSDL2_image-*.so.0 "${WORKDIR}/linux-bundle-lib" 76 | fi 77 | cd .. 78 | fi 79 | 80 | # Audiality 2 81 | if pkg-config audiality2 --exists; then 82 | echo "Audiality 2 already installed in the system!" 83 | else 84 | if [ ! -d "audiality2" ]; then 85 | git clone https://github.com/olofson/audiality2.git 86 | cd audiality2 87 | else 88 | cd audiality2 89 | git checkout master 90 | git pull 91 | fi 92 | git checkout v${A2RELEASE} 93 | ./configure static 94 | cd build/static 95 | make 96 | sudo make install 97 | if [ ! "${KOBO_STATIC_LINUX}" = true ] ; then 98 | cp -L build/src/libaudiality2-*.so.0 "${WORKDIR}/linux-bundle-lib" 99 | fi 100 | cd ../.. 101 | fi 102 | 103 | if [ ! "${KOBO_STATIC_LINUX}" = true ] ; then 104 | strip "${WORKDIR}/linux-bundle-lib/*" 105 | fi 106 | -------------------------------------------------------------------------------- /install-win32-redist: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | . ./BUILDDEFS 3 | 4 | if [ ! -d "${WORKDIR}" ]; then 5 | mkdir "${WORKDIR}" 6 | fi 7 | 8 | if [ -d "${WORKDIR}/win32-redist" ]; then 9 | echo "Win32 redistributables (win32-redist) already in place!" 10 | exit 11 | fi 12 | 13 | set -ex 14 | 15 | mkdir "${WORKDIR}/win32-redist" 16 | cd "${WORKDIR}/win32-redist" 17 | 18 | # Grab Win32 DLL package from koboredux.com 19 | wget "${KRHOME}/download/${REDISTARCH}" 20 | tar -xjvf ${REDISTARCH} --strip-components=1 21 | rm ${REDISTARCH} 22 | 23 | # Grab Audiality2 DLL and COPYING file from GitHub 24 | wget "${A2REPO}/releases/download/v${A2RELEASE}/libaudiality2.dll" 25 | wget https://raw.githubusercontent.com/olofson/audiality2/master/LICENSE.txt 26 | awk 'sub("$", "\r")' LICENSE.txt > LICENSE-Audiality2.txt 27 | rm LICENSE.txt 28 | -------------------------------------------------------------------------------- /linux-bundle/demo.itch.toml: -------------------------------------------------------------------------------- 1 | [[actions]] 2 | name = "play" 3 | path = "kobord-demo.sh" 4 | -------------------------------------------------------------------------------- /linux-bundle/itch.toml: -------------------------------------------------------------------------------- 1 | [[actions]] 2 | name = "play" 3 | path = "kobord.sh" 4 | -------------------------------------------------------------------------------- /linux-bundle/kobord-demo.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | cd "`dirname "$0"`" 3 | export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:./lib/ 4 | ./kobord-demo $@ 5 | -------------------------------------------------------------------------------- /linux-bundle/kobord.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | cd "`dirname "$0"`" 3 | export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:./lib/ 4 | ./kobord $@ 5 | -------------------------------------------------------------------------------- /linux-bundle/koboredux-demo.desktop: -------------------------------------------------------------------------------- 1 | [Desktop Entry] 2 | Version=1.0 3 | Type=Application 4 | Name=Kobo Redux Demo 5 | GenericName=Arcade Game 6 | Comment=Arcade style 2D shooter (Demo version) 7 | TryExec=kobord-demo 8 | Exec=bash -c '"$(dirname "$1")"/kobord-demo.sh' dummy %k 9 | Terminal=false 10 | Categories=Application;Game;ArcadeGame;2DGraphics; 11 | -------------------------------------------------------------------------------- /linux-bundle/koboredux.desktop: -------------------------------------------------------------------------------- 1 | [Desktop Entry] 2 | Version=1.0 3 | Type=Application 4 | Name=Kobo Redux 5 | GenericName=Arcade Game 6 | Comment=Arcade style 2D shooter 7 | TryExec=kobord 8 | Exec=bash -c '"$(dirname "$1")"/kobord.sh' dummy %k 9 | Terminal=false 10 | Categories=Application;Game;ArcadeGame;2DGraphics; 11 | -------------------------------------------------------------------------------- /linux-bundle/static.demo.itch.toml: -------------------------------------------------------------------------------- 1 | [[actions]] 2 | name = "play" 3 | path = "kobord-demo" 4 | -------------------------------------------------------------------------------- /linux-bundle/static.itch.toml: -------------------------------------------------------------------------------- 1 | [[actions]] 2 | name = "play" 3 | path = "kobord" 4 | -------------------------------------------------------------------------------- /make-all: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | . ./BUILDDEFS 3 | 4 | shopt -s nullglob 5 | for i in ${BUILDDIR}/* ; do 6 | echo 7 | echo "[ Building $(basename $i) ]" 8 | echo $i 9 | cd $i 10 | make -j20 11 | echo "[ Leaving $(basename $i) ]" 12 | echo 13 | done 14 | -------------------------------------------------------------------------------- /src/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(sources 2 | cfgform.cpp 3 | dashboard.cpp 4 | enemy.cpp 5 | form.cpp 6 | gamectl.cpp 7 | kobo.cpp 8 | map.cpp 9 | options.cpp 10 | prefs.cpp 11 | random.cpp 12 | sound.cpp 13 | graphics.cpp 14 | cfgparse.cpp 15 | enemies.cpp 16 | filemap.cpp 17 | game.cpp 18 | gamestate.cpp 19 | manage.cpp 20 | myship.cpp 21 | radar.cpp 22 | scenes.cpp 23 | screen.cpp 24 | states.cpp 25 | spinplanet.cpp 26 | starfield.cpp 27 | gridtfx.cpp 28 | fire.cpp 29 | themeparser.cpp 30 | replay.cpp 31 | replay_gst.cpp 32 | pfile.cpp 33 | campaign.cpp 34 | savemanager.cpp 35 | openurl.cpp 36 | logger.c 37 | dbgconsole.cpp 38 | gfxengine/gfxengine.cpp 39 | gfxengine/sofont.cpp 40 | gfxengine/toolkit.cpp 41 | gfxengine/window.cpp 42 | gfxengine/vidmodes.c 43 | gfxengine/sprite.c 44 | gfxengine/filters.c 45 | gfxengine/cs.c 46 | gfxengine/palette.c 47 | ) 48 | 49 | include(FindPkgConfig) 50 | include(CheckIncludeFiles) 51 | include(CheckFunctionExists) 52 | include(CheckCSourceCompiles) 53 | 54 | include_directories(${KOBOREDUX_SOURCE_DIR}) 55 | include_directories(${KOBOREDUX_SOURCE_DIR}/src) 56 | include_directories(${KOBOREDUX_SOURCE_DIR}/src/gfxengine) 57 | include_directories(${CMAKE_BINARY_DIR}/include) 58 | 59 | if(DEMO_BUILD) 60 | add_definitions(-DKOBO_DEMO) 61 | set(KOBO_EXE_SUFFIX "-demo") 62 | else(DEMO_BUILD) 63 | set(KOBO_EXE_SUFFIX "") 64 | endif(DEMO_BUILD) 65 | 66 | pkg_search_module(SDL2 REQUIRED sdl2) 67 | include_directories(${SDL2_INCLUDE_DIRS}) 68 | link_directories(${SDL2_LIBDIR}) 69 | 70 | pkg_search_module(SDL2IMAGE REQUIRED SDL2_image>=2.0.0) 71 | include_directories(${SDL2IMAGE_INCLUDE_DIRS}) 72 | 73 | #find_package(PNG REQUIRED) 74 | #include_directories(${PNG_INCLUDE_DIR}) 75 | 76 | #find_package(AUDIALITY2 REQUIRED) 77 | #include_directories(${AUDIALITY2_INCLUDE_DIR}) 78 | pkg_search_module(AUDIALITY2 REQUIRED audiality2) 79 | include_directories(${AUDIALITY2_INCLUDE_DIRS}) 80 | 81 | set(RES_FILES "") 82 | if(MINGW) 83 | set(RES_FILES "${KOBOREDUX_SOURCE_DIR}/icons/windows/kobord.rc") 84 | set(CMAKE_RC_COMPILER_INIT windres) 85 | ENABLE_LANGUAGE(RC) 86 | SET(CMAKE_RC_COMPILE_OBJECT 87 | " -O coff -i -o ") 88 | endif(MINGW) 89 | 90 | add_executable(kobord WIN32 MACOSX_BUNDLE ${sources} ${RES_FILES}) 91 | set_target_properties(kobord PROPERTIES OUTPUT_NAME 92 | "kobord${KOBO_EXE_SUFFIX}") 93 | 94 | target_link_libraries(kobord ${SDL2_LIBRARIES} ${SDL2IMAGE_LIBRARIES} 95 | ${AUDIALITY2_LIBRARIES} ${KOBO_EXTRA_LIBRARIES}) 96 | 97 | if(WIN32) 98 | target_link_libraries(kobord winmm dxguid) 99 | endif(WIN32) 100 | 101 | # Release build: full optimization, no debug features, no debug info 102 | set(CMAKE_C_FLAGS_RELEASE "-O3 -DNDEBUG") 103 | set(CMAKE_CXX_FLAGS_RELEASE "-O3 -DNDEBUG") 104 | 105 | # Maintainer build: No optimizations, lots of warnings, fail on warnings 106 | set(f "-O1 -g -DDEBUG -Wall -Wwrite-strings -Wcast-align") 107 | set(f "${f} -Waggregate-return") 108 | set(f "${f} -fno-builtin -Wshadow") 109 | set(f "${f} -Wmissing-declarations -Wdisabled-optimization") 110 | set(fc "${f} -Wbad-function-cast -Wstrict-prototypes") 111 | set(fc "${f} -Wdeclaration-after-statement -Wmissing-prototypes") 112 | set(CMAKE_C_FLAGS_MAINTAINER "${fc} -Werror") 113 | set(CMAKE_CXX_FLAGS_MAINTAINER "${f} -Werror") 114 | 115 | # Debug build: Maintainer + extra debug features, don't fail on warnings 116 | set(CMAKE_C_FLAGS_DEBUG ${fc}) 117 | set(CMAKE_CXX_FLAGS_DEBUG ${f}) 118 | 119 | set(CMAKE_EXTRA_INCLUDE_FILES stdio.h) 120 | check_function_exists(snprintf KOBO_HAVE_SNPRINTF) 121 | check_function_exists(_snprintf KOBO_HAVE__SNPRINTF) 122 | check_function_exists(vsnprintf KOBO_HAVE_VSNPRINTF) 123 | check_function_exists(_vsnprintf KOBO_HAVE__VSNPRINTF) 124 | 125 | set(CMAKE_EXTRA_INCLUDE_FILES unistd.h) 126 | check_function_exists(getegid KOBO_HAVE_GETEGID) 127 | check_function_exists(setgid KOBO_HAVE_SETGID) 128 | 129 | set(CMAKE_EXTRA_INCLUDE_FILES sys/types.h sys/stat.h unistd.h) 130 | check_function_exists(stat KOBO_HAVE_STAT) 131 | check_function_exists(lstat KOBO_HAVE_LSTAT) 132 | 133 | set(CMAKE_EXTRA_INCLUDE_FILES) 134 | 135 | if(NOT WIN32) 136 | set(KOBO_DATADIR "${CMAKE_INSTALL_PREFIX}/share/${KOBO_PACKAGE_NAME}") 137 | set(KOBO_USERDIR "HOME>>.${KOBO_PACKAGE_NAME}") 138 | set(KOBO_SYSCONFDIR "/etc") 139 | endif(NOT WIN32) 140 | set(KOBO_CONFIGFILE "${KOBO_PACKAGE_NAME}.cfg") 141 | 142 | CHECK_C_SOURCE_COMPILES( 143 | "#include 144 | #include 145 | int main(void) { 146 | return *(signal(0,0))(0) == 1; 147 | }" 148 | RETSIGTYPE_INT 149 | ) 150 | if(RETSIGTYPE_INT) 151 | set(RETSIGTYPE int) 152 | else(RETSIGTYPE_INT) 153 | set(RETSIGTYPE void) 154 | endif(RETSIGTYPE_INT) 155 | MESSAGE(STATUS "Signal handler return type: ${RETSIGTYPE}") 156 | 157 | set(KOBOREDUX_AUTO_MESSAGE 158 | "This file is automatically generated. Do not edit!") 159 | configure_file(${CMAKE_SOURCE_DIR}/buildconfig.h.cmake 160 | ${CMAKE_BINARY_DIR}/include/buildconfig.h) 161 | 162 | install(TARGETS kobord DESTINATION "${KOBO_BIN_DIR}") 163 | -------------------------------------------------------------------------------- /src/campaign.h: -------------------------------------------------------------------------------- 1 | /*(GPLv2) 2 | ------------------------------------------------------------ 3 | Kobo Redux - Campaign 4 | ------------------------------------------------------------ 5 | * Copyright 2017 David Olofson 6 | * 7 | * This program is free software; you can redistribute it and/or modify it 8 | * under the terms of the GNU General Public License as published by the 9 | * Free Software Foundation; either version 2 of the License, or (at your 10 | * option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, but 13 | * WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General 15 | * Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License along 18 | * with this program; if not, write to the Free Software Foundation, Inc., 19 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 | */ 21 | 22 | #ifndef _KOBO_CAMPAIGN_H_ 23 | #define _KOBO_CAMPAIGN_H_ 24 | 25 | #include "replay.h" 26 | #include 27 | 28 | // Campaign header 29 | #define KOBO_PF_CPGN_4CC MAKE_4CC('C', 'P', 'G', 'N') 30 | #define KOBO_PF_CPGN_VERSION 1 31 | 32 | class KOBO_campaign_info 33 | { 34 | public: 35 | KOBO_campaign_info(); 36 | ~KOBO_campaign_info(); 37 | 38 | time_t starttime; // Campaign start time 39 | time_t endtime; // Campaign end time 40 | char *dat_path; // Campaign file path (system) 41 | 42 | int stage; 43 | int type; // game_types_t 44 | int skill; // skill_levels_t 45 | 46 | int health; // Player health 47 | int charge; // Player secondary weapon accu charge 48 | int score; // Player score 49 | }; 50 | 51 | class KOBO_campaign 52 | { 53 | int32_t version; // Game logic version 54 | int32_t gameversion; // Game version that generated this 55 | 56 | time_t starttime; // Campaign start time 57 | std::vector replays; 58 | char *dat_path; 59 | char *bak_path; 60 | bool _modified; 61 | bool _empty; 62 | 63 | KOBO_replay_compat compat; // Full campaign compatibility status 64 | 65 | void clear(bool to_load); 66 | char *construct_path(unsigned slot, const char *ext); 67 | bool backup(); 68 | bool load_header(pfile_t *pf); 69 | public: 70 | KOBO_campaign(const char *dat, const char *bak); 71 | virtual ~KOBO_campaign(); 72 | 73 | // Status 74 | bool modified(); // true if there is unsaved data 75 | bool empty(); // true if no data has been recorded or loaded 76 | 77 | // Load/analyze/save 78 | bool exists(); 79 | void reset(); 80 | bool load(bool quiet = false); 81 | KOBO_campaign_info *analyze(); 82 | bool save(bool force = false); 83 | 84 | // Compatibility check 85 | KOBO_replay_compat compatibility() { return compat; } 86 | 87 | KOBO_replay *get_replay(int stage); 88 | void add_replay(KOBO_replay *replay); 89 | int last_stage(); 90 | }; 91 | 92 | #endif // _KOBO_CAMPAIGN_H_ 93 | -------------------------------------------------------------------------------- /src/cfgform.cpp: -------------------------------------------------------------------------------- 1 | /*(GPLv2) 2 | ------------------------------------------------------------ 3 | Kobo Deluxe - An enhanced SDL port of XKobo 4 | ------------------------------------------------------------ 5 | * Copyright 2001-2003, 2006-2007, 2009 David Olofson 6 | * Copyright 2015-2017 David Olofson (Kobo Redux) 7 | * 8 | * This program is free software; you can redistribute it and/or modify it 9 | * under the terms of the GNU General Public License as published by the 10 | * Free Software Foundation; either version 2 of the License, or (at your 11 | * option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, but 14 | * WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General 16 | * Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License along 19 | * with this program; if not, write to the Free Software Foundation, Inc., 20 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 21 | */ 22 | 23 | #include "kobolog.h" 24 | #include "config.h" 25 | #include "cfgform.h" 26 | #include "kobo.h" 27 | #include "sound.h" 28 | 29 | int global_status = 0; 30 | 31 | 32 | config_form_t::config_form_t(gfxengine_t *e) : kobo_form_t(e) 33 | { 34 | prf = NULL; 35 | stat = 0; 36 | undostat = 0; 37 | } 38 | 39 | 40 | void config_form_t::open(prefs_t *p) 41 | { 42 | place(woverlay->px(), woverlay->py(), woverlay->width(), 43 | woverlay->height()); 44 | font(B_NORMAL_FONT); 45 | foreground(woverlay->map_rgb(0xffffff)); 46 | background(woverlay->map_rgb(0x000000)); 47 | prf = p; 48 | prfbak = *p; 49 | stat = global_status & (OS_RELOAD | OS_RESTART | OS_UPDATE); 50 | build_all(); 51 | } 52 | 53 | 54 | void config_form_t::build() 55 | { 56 | } 57 | 58 | 59 | void config_form_t::close() 60 | { 61 | clean(); 62 | } 63 | 64 | 65 | void config_form_t::undo() 66 | { 67 | *prf = prfbak; 68 | stat = undostat; 69 | } 70 | 71 | 72 | int config_form_t::status() 73 | { 74 | return stat; 75 | } 76 | 77 | 78 | void config_form_t::clearstatus(int mask) 79 | { 80 | stat &= ~mask; 81 | global_status = stat & (OS_RELOAD | OS_RESTART | OS_UPDATE); 82 | } 83 | 84 | 85 | void config_form_t::setstatus(int mask) 86 | { 87 | stat |= mask; 88 | undostat |= mask; 89 | global_status = stat & (OS_RELOAD | OS_RESTART | OS_UPDATE); 90 | } 91 | 92 | 93 | void config_form_t::change(int delta) 94 | { 95 | kobo_form_t::change(delta); 96 | 97 | if(!selected()) 98 | return; 99 | 100 | if(selected()->tag & OS_CLOSE) 101 | { 102 | if(delta == 0) 103 | { 104 | sound.ui_play(S_UI_OK); 105 | setstatus(OS_CLOSE); 106 | } 107 | } 108 | else if(selected()->tag & OS_CANCEL) 109 | { 110 | if(delta == 0) 111 | { 112 | sound.ui_play(S_UI_CANCEL); 113 | undo(); 114 | setstatus(OS_CLOSE); 115 | } 116 | } 117 | else 118 | sound.ui_play(S_UI_TICK); 119 | } 120 | 121 | 122 | void config_form_t::apply_change(ct_widget_t *w) 123 | { 124 | kobo_form_t::apply_change(w); 125 | 126 | if(w->user) 127 | prf->changed = 1; 128 | 129 | if(w->tag & OS_CLOSE) 130 | prepare_to_apply(); 131 | 132 | setstatus(w->tag & (OS_RELOAD | OS_RESTART | OS_UPDATE)); 133 | 134 | if(w->tag & OS_REBUILD) 135 | rebuild(); 136 | } 137 | 138 | 139 | void config_form_t::prepare_to_apply() 140 | { 141 | } 142 | -------------------------------------------------------------------------------- /src/cfgform.h: -------------------------------------------------------------------------------- 1 | /*(GPLv2) 2 | ------------------------------------------------------------ 3 | Kobo Deluxe - An enhanced SDL port of XKobo 4 | ------------------------------------------------------------ 5 | * Copyright 2001, 2003, 2009 David Olofson 6 | * Copyright 2015-2017 David Olofson (Kobo Redux) 7 | * 8 | * This program is free software; you can redistribute it and/or modify it 9 | * under the terms of the GNU General Public License as published by the 10 | * Free Software Foundation; either version 2 of the License, or (at your 11 | * option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, but 14 | * WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General 16 | * Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License along 19 | * with this program; if not, write to the Free Software Foundation, Inc., 20 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 21 | */ 22 | 23 | #ifndef _CONFIG_FORM_H_ 24 | #define _CONFIG_FORM_H_ 25 | 26 | #include "form.h" 27 | #include "prefs.h" 28 | 29 | enum 30 | { 31 | OS_CLOSE = 0x0001, 32 | OS_CANCEL = 0x0002, 33 | OS_REBUILD = 0x0004, 34 | OS_ACTION = 0x000f, 35 | 36 | OS_RELOAD_GRAPHICS = 0x0010, 37 | OS_RELOAD_SOUNDS = 0x0020, 38 | OS_RELOAD = 0x00f0, 39 | 40 | OS_RESTART_VIDEO = 0x0100, 41 | OS_RESTART_AUDIO = 0x0200, 42 | OS_RESTART_INPUT = 0x0400, 43 | OS_RESTART_LOGGER = 0x0800, 44 | OS_RESTART = 0x0f00, 45 | 46 | OS_UPDATE_AUDIO = 0x1000, 47 | OS_UPDATE_ENGINE = 0x2000, 48 | OS_UPDATE_SCREEN = 0x4000, 49 | OS_UPDATE = 0xf000 50 | }; 51 | 52 | 53 | class config_form_t : public kobo_form_t 54 | { 55 | protected: 56 | prefs_t *prf; 57 | prefs_t prfbak; 58 | int stat; 59 | int undostat; 60 | public: 61 | config_form_t(gfxengine_t *e); 62 | void open(prefs_t *p); 63 | 64 | // Override this to construct the menu. Note that this is called both 65 | // for open() and for OS_REBUILD. 66 | void build(); 67 | 68 | // ...and this, if you need to. Normally, it just sets the status to 0. 69 | void close(); 70 | 71 | int status(); 72 | void setstatus(int mask); 73 | void clearstatus(int mask); 74 | void undo(); 75 | void change(int delta); 76 | void apply_change(ct_widget_t *w); 77 | 78 | // Override this to do stuff when leaving the menu, in preparation for 79 | // passing any OS_RESTART_* or OS_UPDATE_* flags to the main loop. 80 | virtual void prepare_to_apply(); 81 | }; 82 | 83 | extern int global_status; 84 | 85 | #endif //_CONFIG_FORM_H_ 86 | -------------------------------------------------------------------------------- /src/dbgconsole.cpp: -------------------------------------------------------------------------------- 1 | /*(GPLv2) 2 | ------------------------------------------------------------ 3 | Kobo Deluxe - An enhanced SDL port of XKobo 4 | ------------------------------------------------------------ 5 | * Copyright 2017 David Olofson (Kobo Redux) 6 | * 7 | * This program is free software; you can redistribute it and/or modify it 8 | * under the terms of the GNU General Public License as published by the 9 | * Free Software Foundation; either version 2 of the License, or (at your 10 | * option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, but 13 | * WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General 15 | * Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License along 18 | * with this program; if not, write to the Free Software Foundation, Inc., 19 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 | */ 21 | 22 | #include "config.h" 23 | #include "dbgconsole.h" 24 | #include 25 | #ifdef WIN32 26 | # include 27 | # include 28 | #endif 29 | 30 | bool debug_console_open = false; 31 | 32 | 33 | void open_debug_console(int force) 34 | { 35 | if(debug_console_open) 36 | return; 37 | 38 | #ifdef WIN32 39 | HANDLE h = GetStdHandle(STD_OUTPUT_HANDLE); 40 | if(!h) 41 | { 42 | if(force) 43 | { 44 | AllocConsole(); 45 | h = GetStdHandle(STD_OUTPUT_HANDLE); 46 | } 47 | else 48 | return; 49 | } 50 | 51 | SetConsoleTitle("Kobo Redux " KOBO_VERSION_STRING); 52 | 53 | // Redirect stdout 54 | int fd = _open_osfhandle((intptr_t)h, _O_TEXT); 55 | FILE *fp = _fdopen(fd, "w"); 56 | *stdout = *fp; 57 | setvbuf(stdout, NULL, _IONBF, 0); 58 | 59 | // Set up a proper scrollback buffer 60 | CONSOLE_SCREEN_BUFFER_INFO csbi; 61 | if(GetConsoleScreenBufferInfo(h, &csbi)) 62 | { 63 | COORD bs; 64 | bs.X = csbi.dwSize.X; 65 | bs.Y = 10000; 66 | SetConsoleScreenBufferSize(h, bs); 67 | } 68 | 69 | // Redirect stderr 70 | h = GetStdHandle(STD_ERROR_HANDLE); 71 | fd = _open_osfhandle((intptr_t)h, _O_TEXT); 72 | fp = _fdopen(fd, "w"); 73 | *stderr = *fp; 74 | setvbuf(stderr, NULL, _IONBF, 0); 75 | #else 76 | if(force) 77 | printf("open_debug_console() not implemented on this " 78 | "platform.\n"); 79 | #endif 80 | 81 | debug_console_open = true; 82 | } 83 | -------------------------------------------------------------------------------- /src/dbgconsole.h: -------------------------------------------------------------------------------- 1 | /*(GPLv2) 2 | ------------------------------------------------------------ 3 | Kobo Deluxe - An enhanced SDL port of XKobo 4 | ------------------------------------------------------------ 5 | * Copyright 2017 David Olofson (Kobo Redux) 6 | * 7 | * This program is free software; you can redistribute it and/or modify it 8 | * under the terms of the GNU General Public License as published by the 9 | * Free Software Foundation; either version 2 of the License, or (at your 10 | * option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, but 13 | * WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General 15 | * Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License along 18 | * with this program; if not, write to the Free Software Foundation, Inc., 19 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 | */ 21 | 22 | #ifndef _KOBO_DBGCON_H_ 23 | #define _KOBO_DBGCON_H_ 24 | 25 | void open_debug_console(int force); 26 | 27 | #endif // _KOBO_DBGCON_H_ 28 | -------------------------------------------------------------------------------- /src/enemies.cpp: -------------------------------------------------------------------------------- 1 | /*(GPLv2) 2 | ------------------------------------------------------------ 3 | Kobo Deluxe - An enhanced SDL port of XKobo 4 | ------------------------------------------------------------ 5 | * Copyright 1995, 1996 Akira Higuchi 6 | * Copyright 2001, 2003, 2007, 2009 David Olofson 7 | * Copyright 2015-2017 David Olofson (Kobo Redux) 8 | * 9 | * This program is free software; you can redistribute it and/or modify it 10 | * under the terms of the GNU General Public License as published by the 11 | * Free Software Foundation; either version 2 of the License, or (at your 12 | * option) any later version. 13 | * 14 | * This program is distributed in the hope that it will be useful, but 15 | * WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General 17 | * Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License along 20 | * with this program; if not, write to the Free Software Foundation, Inc., 21 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 22 | */ 23 | 24 | #include 25 | #include "enemies.h" 26 | #include "random.h" 27 | #include "radar.h" 28 | 29 | KOBO_enemy *KOBO_enemies::active = NULL; 30 | KOBO_enemy *KOBO_enemies::pool = NULL; 31 | const KOBO_enemy_kind *KOBO_enemies::ekind_to_generate_1; 32 | const KOBO_enemy_kind *KOBO_enemies::ekind_to_generate_2; 33 | int KOBO_enemies::e1_interval; 34 | int KOBO_enemies::e2_interval; 35 | int KOBO_enemies::is_intro = 0; 36 | int KOBO_enemies::sound_update_period = 3; 37 | KOBO_enemystats KOBO_enemies::stats[KOBO_EK__COUNT]; 38 | 39 | 40 | //---------------------------------------------------------------------------// 41 | KOBO_enemy::KOBO_enemy() 42 | { 43 | } 44 | 45 | void KOBO_enemy::detachsound() 46 | { 47 | if(soundhandle > 0) 48 | { 49 | sound.g_release(soundhandle); 50 | soundhandle = 0; 51 | } 52 | } 53 | 54 | void KOBO_enemy::restartsound() 55 | { 56 | stopsound(); 57 | if(ek->sound) 58 | startsound(ek->sound); 59 | } 60 | 61 | //---------------------------------------------------------------------------// 62 | #define KOBO_DEFS(x, y) case KOBO_EK_##x: return #y; 63 | const char *KOBO_enemies::enemy_name(KOBO_enemy_kinds eki) 64 | { 65 | switch(eki) 66 | { 67 | KOBO_ALLENEMYKINDS 68 | default: return ""; 69 | } 70 | } 71 | #undef KOBO_DEFS 72 | 73 | void KOBO_enemies::off() 74 | { 75 | while(active) 76 | { 77 | KOBO_enemy *e = active; 78 | active = active->next; 79 | if(e->ek) 80 | e->release(); 81 | e->next = pool; 82 | pool = e; 83 | } 84 | } 85 | 86 | int KOBO_enemies::init() 87 | { 88 | off(); 89 | ekind_to_generate_1 = NULL; 90 | ekind_to_generate_2 = NULL; 91 | e1_interval = 1; 92 | e2_interval = 1; 93 | is_intro = 0; 94 | sound_update_period = KOBO_SOUND_UPDATE_PERIOD / game.speed; 95 | memset(stats, 0, sizeof(stats)); 96 | return 0; 97 | } 98 | 99 | void KOBO_enemies::clean() 100 | { 101 | KOBO_enemy *p = NULL; 102 | KOBO_enemy *e = active; 103 | while(e) 104 | { 105 | KOBO_enemy *de = e; 106 | e = e->next; 107 | if(!de->ek) 108 | { 109 | if(p) 110 | p->next = e; 111 | else 112 | active = e; 113 | de->next = pool; 114 | pool = de; 115 | } 116 | else 117 | p = de; 118 | } 119 | } 120 | 121 | void KOBO_enemies::move() 122 | { 123 | clean(); 124 | for(KOBO_enemy *e = NULL; (e = next(e)); ) 125 | e->move(); 126 | } 127 | 128 | void KOBO_enemies::move_intro() 129 | { 130 | clean(); 131 | for(KOBO_enemy *e = NULL; (e = next(e)); ) 132 | e->move_intro(); 133 | } 134 | 135 | void KOBO_enemies::detach_sounds() 136 | { 137 | for(KOBO_enemy *e = NULL; (e = next(e)); ) 138 | e->detachsound(); 139 | } 140 | 141 | void KOBO_enemies::restart_sounds() 142 | { 143 | for(KOBO_enemy *e = NULL; (e = next(e)); ) 144 | e->restartsound(); 145 | } 146 | 147 | void KOBO_enemies::put() 148 | { 149 | for(KOBO_enemy *e = NULL; (e = next(e)); ) 150 | e->put(); 151 | } 152 | 153 | void KOBO_enemies::force_positions() 154 | { 155 | for(KOBO_enemy *e = NULL; (e = next(e)); ) 156 | e->force_position(); 157 | } 158 | 159 | void KOBO_enemies::render_hit_zones() 160 | { 161 | woverlay->blendmode(GFX_BLENDMODE_ADD); 162 | for(KOBO_enemy *e = NULL; (e = next(e)); ) 163 | e->render_hit_zone(); 164 | woverlay->blendmode(); 165 | } 166 | 167 | KOBO_enemy *KOBO_enemies::make(const KOBO_enemy_kind *ek, 168 | int x, int y, int h, int v, int di) 169 | { 170 | KOBO_enemy *e = pool; 171 | if(e) 172 | pool = e->next; 173 | else 174 | e = new KOBO_enemy; 175 | e->init(ek, x, y, h, v, di); 176 | stats[ek->eki].spawned++; 177 | stats[ek->eki].health += e->health; 178 | e->next = active; 179 | active = e; 180 | return e; 181 | } 182 | 183 | int KOBO_enemies::erase_cannon(int x, int y) 184 | { 185 | int count = 0; 186 | for(KOBO_enemy *e = NULL; (e = next(e)); ) 187 | count += e->erase_cannon(x, y); 188 | if(count) 189 | wradar->update(x, y); 190 | return count; 191 | } 192 | 193 | void KOBO_enemies::hit_map(int x, int y, int dmg) 194 | { 195 | if(!dmg) 196 | return; 197 | for(KOBO_enemy *e = NULL; (e = next(e)); ) 198 | if(e->can_hit_map(x, y)) 199 | e->hit(dmg); 200 | } 201 | 202 | int KOBO_enemies::exist_pipe() 203 | { 204 | int count = 0; 205 | for(KOBO_enemy *e = NULL; (e = next(e)); ) 206 | if(e->is_pipe()) 207 | count++; 208 | return count; 209 | } 210 | 211 | void KOBO_enemies::set_ekind_to_generate(const KOBO_enemy_kind * e1, int i1, 212 | const KOBO_enemy_kind * e2, int i2) 213 | { 214 | ekind_to_generate_1 = e1; 215 | ekind_to_generate_2 = e2; 216 | e1_interval = i1; 217 | e2_interval = i2; 218 | } 219 | 220 | void KOBO_enemies::splash_damage(int x, int y, int damage) 221 | { 222 | int maxdist = PIXEL2CS(damage); 223 | int dist; 224 | 225 | // Enemies 226 | for(KOBO_enemy *e = NULL; (e = next(e)); ) 227 | { 228 | if(!e->can_splash_damage()) 229 | continue; 230 | if(!e->in_range(x, y, maxdist, dist)) 231 | continue; 232 | int dmg = damage * ENEMY_SPLASH_DAMAGE_MULTIPLIER * 233 | (maxdist - dist) / maxdist; 234 | if(dmg) 235 | e->hit(dmg); 236 | } 237 | 238 | // Player 239 | if(myship.in_range(x, y, maxdist, dist)) 240 | { 241 | int dmg = damage * game.splash_damage_multiplier * 242 | (maxdist - dist) / maxdist; 243 | if(dmg) 244 | myship.hit(dmg); 245 | } 246 | } 247 | -------------------------------------------------------------------------------- /src/form.h: -------------------------------------------------------------------------------- 1 | /*(GPLv2) 2 | ------------------------------------------------------------ 3 | Kobo Deluxe - An enhanced SDL port of XKobo 4 | ------------------------------------------------------------ 5 | * Copyright 2001, 2007, 2009 David Olofson 6 | * Copyright 2005 Erik Auerswald 7 | * Copyright 2015-2017 David Olofson (Kobo Redux) 8 | * 9 | * This program is free software; you can redistribute it and/or modify it 10 | * under the terms of the GNU General Public License as published by the 11 | * Free Software Foundation; either version 2 of the License, or (at your 12 | * option) any later version. 13 | * 14 | * This program is distributed in the hope that it will be useful, but 15 | * WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General 17 | * Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License along 20 | * with this program; if not, write to the Free Software Foundation, Inc., 21 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 22 | */ 23 | 24 | #ifndef _KOBO_FORM_H_ 25 | #define _KOBO_FORM_H_ 26 | 27 | #include "toolkit.h" 28 | #include "cfgparse.h" 29 | 30 | class kobo_binding_t : public ct_string_t 31 | { 32 | protected: 33 | const char *hint; 34 | bool scanning; 35 | SDL_EventType evtype; 36 | void render(); 37 | public: 38 | kobo_binding_t(gfxengine_t *e, const char *cap, SDL_EventType _evtype); 39 | void value(double val); 40 | void change(int delta); 41 | bool rawevent(SDL_Event *ev); 42 | }; 43 | 44 | class kobo_form_t : public ct_form_t 45 | { 46 | //Called by build_all(). 47 | void begin(); 48 | void end(); 49 | protected: 50 | ct_widget_t *current_widget; 51 | ct_list_t *current_list; 52 | ct_label_t *help_bar; 53 | int ypos; 54 | int _font; 55 | float xoffs; 56 | ct_align_t halign; 57 | virtual void init_widget(ct_widget_t *wg, int def_font); 58 | void update_help(); 59 | int get_font(int def); 60 | 61 | //Toolkit 62 | void font(int bank = 0); // Override widget default font 63 | void title(const char *cap); 64 | void label(const char *cap); 65 | void yesno(const char *cap, int *var, int tag = 0); 66 | void onoff(const char *cap, int *var, int tag = 0); 67 | void spin(const char *cap, int *var, int min, int max, 68 | const char *unit, int tag = 0); 69 | void keybinding(const char *cap, int *var, int tag = 0); 70 | void axisbinding(const char *cap, int *var, int tag = 0); 71 | void buttonbinding(const char *cap, int *var, int tag = 0); 72 | void hatbinding(const char *cap, int *var, int tag = 0); 73 | void button(const char *cap, int tag = 0); 74 | void space(float lines = 1.0f); // Negative values are "virtual" pixels 75 | void help(); 76 | 77 | //List tools 78 | void list(const char *cap, void *var, int tag = 0); 79 | void item(const char *cap, int value, int ind = 0); 80 | void item(const char *cap, float value, int ind = 0); 81 | void item(const char *cap, const char *value, int ind = 0); 82 | void perc_list(int first, int last, int step); 83 | void enum_list(int first, int last); 84 | 85 | //Internal wrapper for build() 86 | void build_all(); 87 | public: 88 | kobo_form_t(gfxengine_t *e); 89 | virtual ~kobo_form_t(); 90 | void clean(); 91 | using ct_form_t::select; 92 | bool select(ct_widget_t *w); 93 | void rebuild(); 94 | void apply_change(ct_widget_t *w); 95 | virtual void build(); 96 | }; 97 | 98 | #endif 99 | -------------------------------------------------------------------------------- /src/game.cpp: -------------------------------------------------------------------------------- 1 | /*(GPLv2) 2 | ------------------------------------------------------------ 3 | Kobo Deluxe - An enhanced SDL port of XKobo 4 | ------------------------------------------------------------ 5 | * Copyright 2002, 2007, 2009 David Olofson 6 | * Copyright 2015-2017 David Olofson (Kobo Redux) 7 | * 8 | * This program is free software; you can redistribute it and/or modify it 9 | * under the terms of the GNU General Public License as published by the 10 | * Free Software Foundation; either version 2 of the License, or (at your 11 | * option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, but 14 | * WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General 16 | * Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License along 19 | * with this program; if not, write to the Free Software Foundation, Inc., 20 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 21 | */ 22 | 23 | #include "kobo.h" 24 | #include "game.h" 25 | #include "cs.h" 26 | #include 27 | 28 | game_t game; 29 | 30 | 31 | game_t::game_t() 32 | { 33 | reset(); 34 | } 35 | 36 | 37 | void game_t::reset() 38 | { 39 | set(GAME_SINGLE, SKILL_NORMAL); 40 | } 41 | 42 | 43 | void game_t::set(game_types_t tp, skill_levels_t sk) 44 | { 45 | type = tp; 46 | skill = sk; 47 | 48 | // Master game parameters 49 | speed = 30; 50 | if(prefs && prefs->cheat_speed) 51 | speed /= prefs->cheat_speed; 52 | splash_damage_multiplier = 2; 53 | 54 | // Player ship: Health and damage 55 | top_speed = PIXEL2CS(4); 56 | cruise_speed = PIXEL2CS(2); 57 | max_health = 200; 58 | health = 100; 59 | regen_step = 20; 60 | health_fade = 10; 61 | 62 | // Player guns 63 | bolt_damage = 40; 64 | 65 | // Player guns: Accumulator 66 | initial_charge = level_charge = charge = 1000; 67 | charge_rate = 10; 68 | 69 | // Player ship: Velocity dependent damage 70 | vdmg_minvel = PIXEL2CS(1); 71 | vdmg_maxvel = PIXEL2CS(5); 72 | vdmg_linear = 128; 73 | vdmg_quadratic = 128; 74 | ram_damage = 100; 75 | crash_damage = 30; 76 | 77 | // Player guns: Primary (Nose + Tail) 78 | bolt_speed = 12; 79 | bolt_range = (VIEWLIMIT >> 1) + 16 + 32; 80 | bolt_drain = 15; 81 | if(prefs && prefs->cheat_firepower) 82 | noseloadtime = tailloadtime = 0; 83 | else 84 | noseloadtime = tailloadtime = 1; 85 | 86 | // Player guns: Secondary (Charged Blast) 87 | charged_min = 200; 88 | charged_max = 500; 89 | charged_drain = 10; 90 | charged_spread = 3; 91 | charged_cooldown = 10; 92 | 93 | // Player guns: Tertiary (Fire Blossom) 94 | blossom_min = 750; 95 | blossom_max = 750; 96 | blossom_drain = 5; 97 | blossom_cooldown = 10; 98 | 99 | // Enemies 100 | rock_health = 3000; 101 | rock_damage = 40; 102 | core_health = 1000; 103 | node_health = 40; 104 | 105 | switch(skill) 106 | { 107 | case SKILL_NEWBIE: 108 | // Master game parameters 109 | launch_speed = 160; // 0.625 110 | bullet_speed = 192; // 0.75 111 | core_destroyed_health_bonus = 50; 112 | stage_cleared_health_bonus = 50; 113 | splash_damage_multiplier = 1; 114 | 115 | // Player ship: Velocity dependent damage 116 | ram_damage = 100; 117 | crash_damage = 20; 118 | 119 | // Player guns 120 | bolt_damage = 50; 121 | 122 | // Enemies 123 | rock_health = 500; 124 | rock_damage = 20; 125 | enemy_m_health = 2000; 126 | bomb_delay = 12; 127 | break; 128 | 129 | case SKILL_EASY: 130 | // Master game parameters 131 | launch_speed = 192; // 0.75 132 | bullet_speed = 224; // 0.875 133 | core_destroyed_health_bonus = 35; 134 | stage_cleared_health_bonus = 35; 135 | 136 | // Player ship: Velocity dependent damage 137 | ram_damage = 100; 138 | crash_damage = 25; 139 | 140 | // Player guns 141 | bolt_damage = 45; 142 | 143 | // Enemies 144 | rock_health = 1000; 145 | rock_damage = 30; 146 | enemy_m_health = 2500; 147 | bomb_delay = 10; 148 | break; 149 | 150 | case SKILL_NORMAL: 151 | // Master game parameters 152 | launch_speed = 256; // 1.0 153 | bullet_speed = 256; // 1.0 154 | core_destroyed_health_bonus = 25; 155 | stage_cleared_health_bonus = 25; 156 | 157 | // Enemies 158 | enemy_m_health = 3000; 159 | bomb_delay = 8; 160 | break; 161 | 162 | case SKILL_HARD: 163 | // Master game parameters 164 | launch_speed = 384; // 1.5 165 | bullet_speed = 448; // 1.75 166 | core_destroyed_health_bonus = 10; 167 | stage_cleared_health_bonus = 25; 168 | 169 | // Enemies 170 | enemy_m_health = 4000; 171 | bomb_delay = 4; 172 | break; 173 | 174 | case SKILL_INSANE: 175 | default: 176 | // Master game parameters 177 | launch_speed = 448; // 1.75 178 | bullet_speed = 512; // 2.00 179 | core_destroyed_health_bonus = 10; 180 | stage_cleared_health_bonus = 10; 181 | 182 | // Enemies 183 | enemy_m_health = 5000; 184 | bomb_delay = 1; 185 | break; 186 | } 187 | } 188 | 189 | 190 | int game_t::scale_vel_damage(int vel, int dmg) 191 | { 192 | vel = labs(vel); 193 | 194 | // Upper velocity limit 195 | if(vel > vdmg_maxvel) 196 | vel = vdmg_maxvel; 197 | 198 | // Lower velocity limit/truncation 199 | // Note that this will "compress" the response, as we still 200 | // normalize to the ship's nominal top speed! 201 | vel -= vdmg_minvel; 202 | if(vel <= 0) 203 | return 0; 204 | 205 | // Normalize to top speed 206 | int ds = (vel << 8) / top_speed; 207 | int ds2 = ds * ds >> 8; 208 | return dmg * (ds * vdmg_linear + ds2 * vdmg_quadratic) >> 16; 209 | } 210 | -------------------------------------------------------------------------------- /src/gamectl.h: -------------------------------------------------------------------------------- 1 | /*(GPLv2) 2 | ------------------------------------------------------------ 3 | Kobo Deluxe - An enhanced SDL port of XKobo 4 | ------------------------------------------------------------ 5 | * Copyright 1995, 1996 Akira Higuchi 6 | * Copyright 2001, 2002, 2006, 2009 David Olofson 7 | * Copyright 2015-2017 David Olofson (Kobo Redux) 8 | * 9 | * This program is free software; you can redistribute it and/or modify it 10 | * under the terms of the GNU General Public License as published by the 11 | * Free Software Foundation; either version 2 of the License, or (at your 12 | * option) any later version. 13 | * 14 | * This program is distributed in the hope that it will be useful, but 15 | * WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General 17 | * Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License along 20 | * with this program; if not, write to the Free Software Foundation, Inc., 21 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 22 | */ 23 | 24 | #ifndef _KOBO_GAMECTL_H_ 25 | #define _KOBO_GAMECTL_H_ 26 | 27 | #include "SDL.h" 28 | #include "config.h" 29 | 30 | 31 | enum gc_targets_t 32 | { 33 | BTN_NONE = -1, 34 | 35 | BTN_UP = 0, //Joystick, arrows, numpad etc 36 | BTN_DOWN, 37 | BTN_LEFT, 38 | BTN_RIGHT, 39 | BTN_UL, 40 | BTN_UR, 41 | BTN_DL, 42 | BTN_DR, 43 | 44 | BTN_INC, // + 45 | BTN_DEC, // - 46 | 47 | BTN_NEXT, // PageUp 48 | BTN_PREV, // PageDn 49 | 50 | BTN_YES, // 'Y' 51 | BTN_NO, // 'N' 52 | 53 | BTN_PRIMARY, // Primary fire (ctrl, fire button, LMB,...) 54 | BTN_SECONDARY, // Secondary fire (shift, space, mouse button,... 55 | BTN_TERTIARY, // Tertiary fire 56 | BTN_SELECT, // Return, enter, LMB, ... 57 | BTN_MENU, // ESC, RMB, ... 58 | BTN_PAUSE, // Pause or P; also used as an internal event. 59 | BTN_CLOSE, // Window close button, ALT-F4,... 60 | 61 | // When using ingame mouse control, these are passed to the GUI, so we 62 | // can trap them explicitly where desired. When not using ingame mouse 63 | // control, mouse buttons generate BTN_SELECT or BTN_EXIT instead. 64 | BTN_LMB, // Left 65 | BTN_MMB, // Middle 66 | BTN_RMB, // Right 67 | 68 | BTN__COUNT 69 | }; 70 | 71 | 72 | enum gc_mousemodes_t 73 | { 74 | MMD_OFF = 0, 75 | MMD_CROSSHAIR, 76 | MMD_RELATIVE 77 | }; 78 | 79 | 80 | enum gc_sources_t 81 | { 82 | GC_SRC_JOYSTICK = 0, 83 | GC_SRC_MOUSE, 84 | GC_SRC_KEY0, 85 | GC_SRC_KEY1, 86 | GC_SRC_KEY2, 87 | GC_SRC_KEY3, 88 | GC_SRC__COUNT 89 | }; 90 | 91 | 92 | enum KOBO_player_controls 93 | { 94 | KOBO_PC_NONE = 0, 95 | 96 | KOBO_PC_DIR = 0x0f, // Dirs 1..8; 0 is "neutral" 97 | 98 | KOBO_PC_PRIMARY = 0x10, // Fire primary weapon 99 | KOBO_PC_SECONDARY = 0x20, // Fire secondary weapon 100 | KOBO_PC_TERTIARY = 0x40, // Fire tertiary weapon 101 | KOBO_PC_QUATERNARY = 0x80, // Fire quaternary weapon 102 | KOBO_PC_FIRE = KOBO_PC_PRIMARY | KOBO_PC_SECONDARY | 103 | KOBO_PC_TERTIARY | KOBO_PC_QUATERNARY, 104 | 105 | KOBO_PC_END = 0xff00 // End-of-replay 106 | }; 107 | 108 | 109 | class gamecontrol_t 110 | { 111 | static unsigned state[BTN__COUNT]; // Current state 112 | static unsigned _pressed[BTN__COUNT]; // Pressed during this frame 113 | static unsigned _released[BTN__COUNT]; // Released during this frame 114 | static int direction, new_direction; 115 | static int latch_timer; 116 | static bool movekey_pressed, key_sprint, mouse_sprint, mouse_muted; 117 | static int js_x, js_y; 118 | static bool js_sprint; 119 | static void change(); 120 | static gc_targets_t mapsrc(SDL_Keysym sym, int &src); 121 | public: 122 | gamecontrol_t(); 123 | static void init(); 124 | static void clear(); // Clear all input state 125 | static void reset_flanks(); // Reset the pressed()/released() state 126 | static void mouse_mute(bool m); // Mute mouse motion (not buttons!) 127 | static gc_targets_t map(SDL_Keysym sym) 128 | { 129 | int src; 130 | return mapsrc(sym, src); 131 | } 132 | static gc_targets_t map_js_button(int button); 133 | static void pressbtn(gc_targets_t b, gc_sources_t s); 134 | static void releasebtn(gc_targets_t b, gc_sources_t s); 135 | static void press(SDL_Keysym sym); 136 | static void release(SDL_Keysym sym); 137 | static void mouse_position(int h, int v); 138 | static void js_axis(int axis, int value); 139 | static void js_hat(int value); 140 | static int dir() { return direction; } 141 | static bool dir_push(); 142 | static bool down(gc_targets_t b) { return state[b]; } 143 | static bool pressed(gc_targets_t b) { return _pressed[b]; } 144 | static bool released(gc_targets_t b) { return _released[b]; } 145 | static int primary_fire() 146 | { 147 | return down(BTN_PRIMARY) || pressed(BTN_PRIMARY); 148 | } 149 | static int secondary_fire() 150 | { 151 | return down(BTN_SECONDARY) || pressed(BTN_SECONDARY); 152 | } 153 | static void frame(); // Call after processing game logic frame! 154 | }; 155 | 156 | extern gamecontrol_t gamecontrol; 157 | 158 | #endif //_KOBO_KEY_H_ 159 | -------------------------------------------------------------------------------- /src/gamestate.h: -------------------------------------------------------------------------------- 1 | /*(LGPLv2.1) 2 | ------------------------------------------------------------ 3 | Game State Manager 4 | ------------------------------------------------------------ 5 | * Copyright 2001-2003, 2009 David Olofson 6 | * Copyright 2015, 2017 David Olofson (Kobo Redux) 7 | * 8 | * This library is free software; you can redistribute it and/or modify it 9 | * under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation; either version 2.1 of the License, or (at 11 | * your option) any later version. 12 | * 13 | * This library is distributed in the hope that it will be useful, but 14 | * WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser 16 | * General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public License 19 | * along with this library; if not, write to the Free Software Foundation, 20 | * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA 21 | */ 22 | 23 | #ifndef _GAMESTATEMANAGER_H_ 24 | #define _GAMESTATEMANAGER_H_ 25 | 26 | #include "gamectl.h" 27 | 28 | class gamestatemanager_t; 29 | 30 | class gamestate_t 31 | { 32 | friend class gamestatemanager_t; 33 | private: 34 | gamestate_t *prev; //LIFO stack 35 | gamestatemanager_t *manager; 36 | bool pushed; 37 | protected: 38 | void pop(); 39 | void tail_pop(); 40 | 41 | virtual void press(gc_targets_t button); 42 | virtual void release(gc_targets_t button); 43 | virtual void pos(int x, int y); 44 | virtual void delta(int dx, int dy); 45 | 46 | virtual void enter(); 47 | virtual void leave(); 48 | virtual void yield(); 49 | virtual void reenter(); 50 | virtual void rebuild(); 51 | 52 | public: 53 | const char *name; 54 | const char *info; 55 | 56 | gamestate_t(); 57 | virtual ~gamestate_t(); 58 | gamestate_t *previous() { return prev; } 59 | virtual void frame(); //Control system stuff 60 | virtual void pre_render(); //Background rendering 61 | virtual void post_render(); //Foreground rendering 62 | }; 63 | 64 | 65 | class gamestatemanager_t 66 | { 67 | friend class gamestate_t; 68 | private: 69 | gamestate_t *top; //Stack top 70 | protected: 71 | void tail_pop(); 72 | public: 73 | gamestatemanager_t(); 74 | ~gamestatemanager_t(); 75 | 76 | // Event router interface 77 | void press(SDL_Keysym sym); 78 | void release(SDL_Keysym sym); 79 | void pressbtn(gc_targets_t button); 80 | void releasebtn(gc_targets_t button); 81 | void pos(int x, int y); 82 | void delta(int dx, int dy); 83 | 84 | // CS frame and rendering callbacks 85 | void rebuild(); 86 | void frame(); 87 | void pre_render(); 88 | void post_render(); 89 | 90 | // State management 91 | void change(gamestate_t *gs); 92 | void push(gamestate_t *gs); 93 | void tail_push(gamestate_t *gs); 94 | void pop(); 95 | gamestate_t *current(); 96 | gamestate_t *previous(); 97 | }; 98 | 99 | #endif /*_GAMESTATEMANAGER_H_*/ 100 | -------------------------------------------------------------------------------- /src/gfx/mono/dashboard/dashboard-v2.xcf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/olofson/koboredux/cf92b8a61d002ccaa9fbcda7a96dab08a681dee4/src/gfx/mono/dashboard/dashboard-v2.xcf -------------------------------------------------------------------------------- /src/gfx/mono/fonts/bigfont.xcf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/olofson/koboredux/cf92b8a61d002ccaa9fbcda7a96dab08a681dee4/src/gfx/mono/fonts/bigfont.xcf -------------------------------------------------------------------------------- /src/gfx/mono/fonts/counterfont.xcf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/olofson/koboredux/cf92b8a61d002ccaa9fbcda7a96dab08a681dee4/src/gfx/mono/fonts/counterfont.xcf -------------------------------------------------------------------------------- /src/gfx/mono/fonts/smallfont.xcf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/olofson/koboredux/cf92b8a61d002ccaa9fbcda7a96dab08a681dee4/src/gfx/mono/fonts/smallfont.xcf -------------------------------------------------------------------------------- /src/gfx/mono/render-sprites.eel: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////// 2 | // render-sprites.eel - Render all rotated Kobo Redux sprites 3 | // Copyright 2016 David Olofson 4 | //////////////////////////////////////////////////////////////// 5 | 6 | import eelium.tipe as tipe; 7 | 8 | constant DSTPATH = "../../../data/gfx/mono/"; 9 | 10 | static defaults = { 11 | .verbose true, 12 | .scale .125, 13 | .tilew 16, 14 | .tileh 16, 15 | .filtermode "dominant", 16 | .frames 64, 17 | .columns 8, 18 | .palette DSTPATH + "HW-ZX-Spectrum.gpl" 19 | }; 20 | 21 | static sprites = [ 22 | { 23 | // "Big ship" 24 | .output DSTPATH + "sprites/bigship.png", 25 | .palette [0x000000, 0xffffff], 26 | .dither_tint 0x333333, 27 | .tilew 48, 28 | .tileh 48, 29 | .frames 32, 30 | .sources [ 31 | { 32 | // 0 33 | .source "sprites/bigship-src.png", 34 | .tilew 256, 35 | .tileh 256, 36 | 37 | }, 38 | { 39 | // 1 40 | .source [0, 8], 41 | .tilew 128, 42 | .tileh 128 43 | }, 44 | { 45 | // 2 46 | .source 0, 47 | .tilew 0, 48 | .tiles [ 49 | [0, 256, 256, 384, 384] 50 | ] 51 | }, 52 | { 53 | // 3 54 | .source [0, 11], 55 | .tilew 128, 56 | .tileh 128 57 | }, 58 | { 59 | // 4 60 | .source [0, 7], 61 | .tilew 128, 62 | .tileh 128 63 | } 64 | ], 65 | .layers [ 66 | { 67 | // Lower body 68 | .source 2, 69 | .frame 0 70 | }, 71 | { 72 | // Lower body detail 73 | .sxoffset 128, 74 | .syoffset 0, 75 | .rotation [360, 0], 76 | .source 1, 77 | .frame 0, 78 | .clones 10 79 | }, 80 | { 81 | // Upper body 82 | .frame 0 83 | }, 84 | { 85 | // Spinner cluster shadows 86 | .blendmode "multiply", 87 | .clampcolor 0xffffffff, 88 | .xoffset 16, 89 | .yoffset 16, 90 | .sxoffset 128, 91 | .syoffset 0, 92 | .rotation [0, 360], 93 | .rotationoffset 45, 94 | .source 4, 95 | .frame 0, 96 | .clones 4 97 | }, 98 | { 99 | // Spinner clusters 100 | .sxoffset 128, 101 | .syoffset 0, 102 | .rotation [0, 360], 103 | .rotationoffset 45, 104 | .source 3, 105 | .frame 0, 106 | .clones 4 107 | }, 108 | { 109 | // Spinner shadow 110 | .blendmode "multiply", 111 | .clampcolor 0xffffffff, 112 | .xoffset 16, 113 | .yoffset 16, 114 | .rotation [0, 90], 115 | .frame 1 116 | }, 117 | { 118 | // Core 119 | .frame 4 120 | }, 121 | { 122 | // Spinner 123 | .rotation [0, 90], 124 | .frame 2 125 | } 126 | ] 127 | }, 128 | 129 | { 130 | // Kobo Mark 3 Small - Mono Edition 131 | .output DSTPATH + "sprites/kobo-mk3s.png", 132 | .palette [0x000000/*, 0xaaaaaa*/, 0x00ffff], 133 | .tilew 24, 134 | .tileh 24, 135 | .sources [ 136 | { 137 | // 0: Full sheet; no tiling 138 | .source "sprites/kobo-mk3s-src.png", 139 | .tilew 0 140 | 141 | }, 142 | { 143 | // 1: Engine 144 | .source [0, 0, 0, 256, 256], 145 | .tilew 64, 146 | .tileh 128 147 | }, 148 | { 149 | // 2: Cannon 150 | .source [0, 320, 128, 64, 192], 151 | .tilew 64, 152 | .tileh 192 153 | }, 154 | { 155 | // 3: Wing 156 | .source [0, 0, 128 + 192, 384, 192], 157 | .tilew 192, 158 | .tileh 192 159 | }, 160 | { 161 | // 4: Fuselage 162 | .source [0, 0, 128 + 192 + 192, 384, 2 * 192], 163 | .tilew 128, 164 | .tileh 192 165 | } 166 | ], 167 | .layers [ 168 | { 169 | // Left engine 170 | .sxoffset -56, 171 | .syoffset -16, 172 | .rotation [0, 360], 173 | .source 1, 174 | .frame [0, 1, 1, 2, 2, 3, 3, 4, 175 | 4, 5, 5, 6, 6, 7, 7, 0] 176 | }, 177 | { 178 | // Right engine 179 | .sxoffset 56, 180 | .syoffset -16, 181 | .rotation [0, 360], 182 | .source 1, 183 | .frame [0, 1, 1, 2, 2, 3, 3, 4, 184 | 4, 5, 5, 6, 6, 7, 7, 0] 185 | }, 186 | { 187 | // Fuselage shadow onto engines 188 | .blendmode "multiply", 189 | .clampcolor 0xffffffff, 190 | .xoffset 16, 191 | .yoffset 16, 192 | .rotation [0, 360], 193 | .source 4, 194 | .frame 1 195 | }, 196 | { 197 | // Wing shadow 198 | .blendmode "multiply", 199 | .clampcolor 0xffffffff, 200 | .xoffset 8, 201 | .yoffset 8, 202 | .rotation [0, 360], 203 | .source 3, 204 | .frame 1 205 | }, 206 | { 207 | // Wing 208 | .rotation [0, 360], 209 | .source 3 210 | }, 211 | { 212 | // Cannon 213 | .rotation [0, 360], 214 | .source 2 215 | }, 216 | { 217 | // Fuselage shadow onto wing 218 | .blendmode "multiply", 219 | .clampcolor 0xffffffff, 220 | .xoffset 8, 221 | .yoffset 8, 222 | .rotation [0, 360], 223 | .source 4, 224 | .frame 1 225 | }, 226 | { 227 | // Fuselage 228 | .rotation [0, 360], 229 | .source 4 230 | } 231 | ] 232 | } 233 | 234 | ]; 235 | 236 | export function main 237 | { 238 | local draft = false; 239 | local first = 0; 240 | local last = sizeof sprites - 1; 241 | for local a = 1, arguments - 1 242 | switch args[a] 243 | case "-d" 244 | draft = true; 245 | default 246 | first, last = -(integer)(args[a]) - 1; 247 | 248 | local e = tipe.Engine(); 249 | for local i = first, last 250 | { 251 | local params = clone defaults; 252 | params.+ sprites[i]; 253 | if draft 254 | params.filtermode = "nearest"; 255 | e:Reset(); 256 | e:SetParams(params); 257 | e:Log("[ Sprite sheet ", i + 1, "/", sizeof sprites, " ]\n\n"); 258 | e:Process(); 259 | e:Log("\n"); 260 | } 261 | return 0; 262 | } 263 | -------------------------------------------------------------------------------- /src/gfx/mono/sprites/bigship-src.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/olofson/koboredux/cf92b8a61d002ccaa9fbcda7a96dab08a681dee4/src/gfx/mono/sprites/bigship-src.png -------------------------------------------------------------------------------- /src/gfx/mono/sprites/bigship.aseprite: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/olofson/koboredux/cf92b8a61d002ccaa9fbcda7a96dab08a681dee4/src/gfx/mono/sprites/bigship.aseprite -------------------------------------------------------------------------------- /src/gfx/mono/sprites/bigship.xcf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/olofson/koboredux/cf92b8a61d002ccaa9fbcda7a96dab08a681dee4/src/gfx/mono/sprites/bigship.xcf -------------------------------------------------------------------------------- /src/gfx/mono/sprites/bmr-pink.aseprite: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/olofson/koboredux/cf92b8a61d002ccaa9fbcda7a96dab08a681dee4/src/gfx/mono/sprites/bmr-pink.aseprite -------------------------------------------------------------------------------- /src/gfx/mono/sprites/kobo-mk3s-src.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/olofson/koboredux/cf92b8a61d002ccaa9fbcda7a96dab08a681dee4/src/gfx/mono/sprites/kobo-mk3s-src.png -------------------------------------------------------------------------------- /src/gfx/mono/sprites/kobo-mk3s.xcf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/olofson/koboredux/cf92b8a61d002ccaa9fbcda7a96dab08a681dee4/src/gfx/mono/sprites/kobo-mk3s.xcf -------------------------------------------------------------------------------- /src/gfx/mono/sprites/missile.aseprite: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/olofson/koboredux/cf92b8a61d002ccaa9fbcda7a96dab08a681dee4/src/gfx/mono/sprites/missile.aseprite -------------------------------------------------------------------------------- /src/gfxengine/palette.c: -------------------------------------------------------------------------------- 1 | /*(LGPLv2.1) 2 | ---------------------------------------------------------------------- 3 | palette.c - GIMP .gpl palette loader 4 | ---------------------------------------------------------------------- 5 | * Copyright 2015, 2016 David Olofson (Kobo Redux) 6 | * 7 | * This library is free software; you can redistribute it and/or modify it 8 | * under the terms of the GNU Lesser General Public License as published by 9 | * the Free Software Foundation; either version 2.1 of the License, or (at 10 | * your option) any later version. 11 | * 12 | * This library is distributed in the hope that it will be useful, but 13 | * WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser 15 | * General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with this library; if not, write to the Free Software Foundation, 19 | * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA 20 | */ 21 | 22 | #include "palette.h" 23 | #include 24 | #include 25 | #include 26 | #include 27 | 28 | 29 | GFX_palette *gfx_palette_new(unsigned initsize) 30 | { 31 | GFX_palette *p = (GFX_palette *)calloc(1, sizeof(GFX_palette)); 32 | if(!p) 33 | return NULL; 34 | 35 | p->nentries = initsize; 36 | p->entries = (uint32_t *)calloc(p->nentries, sizeof(uint32_t)); 37 | if(!p->entries) 38 | { 39 | free(p); 40 | return NULL; 41 | } 42 | 43 | return p; 44 | } 45 | 46 | 47 | /* Find 'tk' in 's'. Return NULL if a NUL terminator is found instead. */ 48 | static const char *read_until(const char *s, char tk) 49 | { 50 | while(*s != tk) 51 | if(!*s) 52 | return NULL; 53 | else 54 | ++s; 55 | return s; 56 | } 57 | 58 | static const char *parse_header(GFX_palette *p, const char *s) 59 | { 60 | const char *e; 61 | 62 | /* "GIMP Palette" */ 63 | if(!(e = read_until(s, 10))) 64 | return NULL; 65 | if(strncmp(s, "GIMP Palette", e - s) != 0) 66 | return NULL; 67 | s = e + 1; 68 | 69 | /* Not interested in the metadata, so we skip the rest */ 70 | while(*s != '#') 71 | { 72 | if(!(s = read_until(s, 10))) 73 | return NULL; 74 | ++s; 75 | } 76 | 77 | if((s = read_until(s, 10))) 78 | ++s; 79 | return s; 80 | } 81 | 82 | static int parse_entry(const char *s, uint32_t *color) 83 | { 84 | int c; 85 | const char *e = s; 86 | *color = 0; 87 | for(c = 0; c < 3; ++c) 88 | { 89 | while(isblank(*s)) 90 | ++s; 91 | e = s; 92 | while(isdigit(*e)) 93 | ++e; 94 | if(!*e || (e == s)) 95 | return 0; 96 | *color <<= 8; 97 | *color |= atoi(s) & 0xff; 98 | s = e; 99 | } 100 | return 1; 101 | } 102 | 103 | GFX_palette *gfx_palette_parse(const char *data) 104 | { 105 | int i; 106 | const char *s; 107 | GFX_palette *p; 108 | 109 | /* Count lines and allocate space for the entries */ 110 | s = data; 111 | i = 0; 112 | while((s = read_until(s, 10))) 113 | { 114 | ++i; 115 | ++s; 116 | } 117 | if(i <= 4) 118 | return NULL; 119 | i -= 4; 120 | p = gfx_palette_new(i); 121 | if(!p) 122 | return NULL; 123 | 124 | if(!(s = parse_header(p, data))) 125 | { 126 | fprintf(stderr, "Invalid .gpl palette header!\n"); 127 | gfx_palette_free(p); 128 | return NULL; 129 | } 130 | 131 | for(i = 0; i < p->nentries; ++i) 132 | { 133 | if(!parse_entry(s, p->entries + i)) 134 | { 135 | fprintf(stderr, "Invalid .gpl palette data!\n"); 136 | gfx_palette_free(p); 137 | return NULL; 138 | } 139 | s = read_until(s, 10); 140 | if(!s) 141 | { 142 | fprintf(stderr, "Unexpected end of .gpl palette!\n"); 143 | gfx_palette_free(p); 144 | return NULL; 145 | } 146 | ++s; 147 | } 148 | 149 | return p; 150 | } 151 | 152 | 153 | GFX_palette *gfx_palette_load(const char *path) 154 | { 155 | GFX_palette *p; 156 | FILE *f; 157 | size_t fsize; 158 | char *buf; 159 | if(!(f = fopen(path, "rb"))) 160 | return NULL; 161 | fseek(f, 0, SEEK_END); 162 | fsize = ftell(f); 163 | fseek(f, 0, SEEK_SET); 164 | if(!(buf = malloc(fsize + 1))) 165 | { 166 | fclose(f); 167 | return NULL; 168 | } 169 | buf[fsize] = 0; 170 | if(fread(buf, 1, fsize, f) != fsize) 171 | { 172 | fclose(f); 173 | free(buf); 174 | return NULL; 175 | } 176 | fclose(f); 177 | 178 | p = gfx_palette_parse(buf); 179 | 180 | free(buf); 181 | return p; 182 | } 183 | 184 | 185 | void gfx_palette_set(GFX_palette *p, unsigned i, uint32_t color) 186 | { 187 | if(i >= p->nentries) 188 | { 189 | int j; 190 | uint32_t *ne = (uint32_t *)realloc(p->entries, 191 | (i + 1) * sizeof(uint32_t)); 192 | if(!ne) 193 | { 194 | fprintf(stderr, "Palette reallocation failed!\n"); 195 | return; 196 | } 197 | p->entries = ne; 198 | for(j = p->nentries; j < i; ++j) 199 | p->entries[j] = 0; 200 | p->nentries = i + 1; 201 | } 202 | p->entries[i] = color; 203 | } 204 | 205 | 206 | void gfx_palette_free(GFX_palette *p) 207 | { 208 | free(p->entries); 209 | free(p); 210 | } 211 | -------------------------------------------------------------------------------- /src/gfxengine/palette.h: -------------------------------------------------------------------------------- 1 | /*(LGPLv2.1) 2 | ---------------------------------------------------------------------- 3 | palette.h - GIMP .gpl palette loader 4 | ---------------------------------------------------------------------- 5 | * Copyright 2015, 2016 David Olofson (Kobo Redux) 6 | * 7 | * This library is free software; you can redistribute it and/or modify it 8 | * under the terms of the GNU Lesser General Public License as published by 9 | * the Free Software Foundation; either version 2.1 of the License, or (at 10 | * your option) any later version. 11 | * 12 | * This library is distributed in the hope that it will be useful, but 13 | * WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser 15 | * General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with this library; if not, write to the Free Software Foundation, 19 | * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA 20 | */ 21 | 22 | #ifndef _PALETTE_H_ 23 | #define _PALETTE_H_ 24 | 25 | #ifdef __cplusplus 26 | extern "C" { 27 | #endif 28 | 29 | #include 30 | 31 | typedef struct GFX_palette { 32 | unsigned nentries; 33 | uint32_t *entries; 34 | } GFX_palette; 35 | 36 | GFX_palette *gfx_palette_new(unsigned initsize); 37 | GFX_palette *gfx_palette_parse(const char *data); 38 | GFX_palette *gfx_palette_load(const char *path); 39 | 40 | void gfx_palette_set(GFX_palette *p, unsigned i, uint32_t color); 41 | 42 | static inline uint32_t gfx_palette_get(GFX_palette *p, unsigned i) 43 | { 44 | if(i >= p->nentries) 45 | return p->entries[0]; 46 | return p->entries[i]; 47 | } 48 | 49 | void gfx_palette_free(GFX_palette *p); 50 | 51 | #ifdef __cplusplus 52 | }; 53 | #endif 54 | 55 | #endif /* _PALETTE_H_ */ 56 | -------------------------------------------------------------------------------- /src/gfxengine/sofont.h: -------------------------------------------------------------------------------- 1 | /*(LGPLv2.1) 2 | ------------------------------------------------------------ 3 | SoFont - SDL Object Font Library 4 | ------------------------------------------------------------ 5 | * Copyright ???? Karl Bartel 6 | * Copyright ???? Luc-Olivier de Charriere 7 | * Copyright 2009 David Olofson 8 | * Copyright 2015-2017 David Olofson (Kobo Redux) 9 | * 10 | * This library is free software; you can redistribute it and/or modify it 11 | * under the terms of the GNU Lesser General Public License as published by 12 | * the Free Software Foundation; either version 2.1 of the License, or (at 13 | * your option) any later version. 14 | * 15 | * This library is distributed in the hope that it will be useful, but 16 | * WITHOUT ANY WARRANTY; without even the implied warranty of 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser 18 | * General Public License for more details. 19 | * 20 | * You should have received a copy of the GNU Lesser General Public License 21 | * along with this library; if not, write to the Free Software Foundation, 22 | * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA 23 | 24 | Originally from C Library: 25 | Karl Bartel 26 | 27 | * SFONT - SDL Font Library by Karl Bartel * 28 | * * 29 | * All functions are explained below. There are two versions of each * 30 | * funtction. The first is the normal one, the function with the * 31 | * 2 at the end can be used when you want to handle more than one font * 32 | * in your program. * 33 | * * 34 | 35 | Copied into a C++ object to allow multiple fonts by: 36 | Luc-Olivier de Charriere 37 | 38 | David Olofson : 39 | * Strings changed to 'const char *' 40 | * Cursor tests first check if '|' is present. 41 | * Shadowed variables fixed. 42 | * Garbage data in spacing table fixed. (Thanks to 43 | Andreas Sp�ngberg for discovering this one!) 44 | * Added ExtraSpace(). (Scaling support hack...) 45 | * Disabled colorkeying. (Ruins some RGBA fonts!) 46 | 47 | David Olofson 2015: 48 | * SDL 2 port 49 | * Glyph marker color is now anything more purple than #808080. 50 | * The top (marker) pixel row is now simply cleared after 51 | glyphs have been extracted, completely disregarding contents. 52 | * Added scaling support. 53 | * Fixed some API naming inconsistencies. 54 | 55 | David Olofson 2016: 56 | * ExtraSpace() default changed to 0, to avoid ugly hacks when 57 | scaling the source textures. Fonts need to include full 58 | spacing in their encoding! 59 | * Added GetGlyphs() to allow the application to access SDL2 60 | blending parameters. 61 | 62 | David Olofson 2017: 63 | * Added TabSize() and '\t' tab support. 64 | */ 65 | 66 | #ifndef __SOFONT_H 67 | #define __SOFONT_H 68 | 69 | #include "SDL.h" 70 | 71 | #define START_CHAR 33 72 | 73 | class SoFont 74 | { 75 | public: 76 | SoFont(SDL_Renderer *_target); 77 | ~SoFont(); 78 | 79 | bool Load(SDL_Surface *FontSurface); 80 | void SetScale(float xs, float ys) 81 | { 82 | xscale = (int)(xs * 256.0f); 83 | yscale = (int)(ys * 256.0f); 84 | } 85 | 86 | // Renders a string to the target 87 | void PutString(int x, int y, const char *text, SDL_Rect *clip = NULL); 88 | void PutStringWithCursor(int x, int y, const char *text, int cursPos, 89 | SDL_Rect *clip = NULL, bool showCurs = true); 90 | 91 | // Returns the width of "text" in pixels 92 | int TextWidth(const char *text, int min = 0, int max = 255); 93 | 94 | int FontHeight() { return height; } 95 | 96 | // Blits a string to with centered x position 97 | void XCenteredString(int y, const char *text, SDL_Rect* clip=NULL); 98 | // Blits a string to with centered x & y position 99 | void CenteredString(const char *text, SDL_Rect* clip=NULL); 100 | // Blits a string to with centered around x & y positions 101 | void CenteredString(int x, int y, const char *text, 102 | SDL_Rect* clip = NULL); 103 | 104 | // This was specially developed for GUI 105 | void PutStringCleverCursor(const char *text, int cursPos, SDL_Rect *r, 106 | SDL_Rect* clip = NULL, bool showCurs = true); 107 | 108 | // Gives the cursor position given a x-axix point in the text 109 | int TextCursorAt(const char *text, int px); 110 | int CleverTextCursorAt(const char *text, int px, int cursPos, 111 | SDL_Rect *r); 112 | 113 | int GetMinChar() { return START_CHAR; } 114 | int GetMaxChar() { return max_i; } 115 | 116 | void ExtraSpace(int xs) { xspace = xs; } 117 | void TabSize(int ts) { tabsize = ts; } 118 | 119 | SDL_Texture *GetGlyphs() { return glyphs; } 120 | 121 | protected: 122 | SDL_Renderer *target; 123 | SDL_Texture *glyphs; 124 | int height; 125 | int *CharPos; 126 | int *CharOffset; 127 | int *Spacing; 128 | int xspace; 129 | int max_i, spacew, cursShift; 130 | int tabsize; 131 | Uint32 background; 132 | int xscale, yscale; 133 | bool DoStartNewChar(SDL_Surface *surface, Sint32 x); 134 | void CleanSurface(SDL_Surface *surface); 135 | }; 136 | 137 | #endif 138 | -------------------------------------------------------------------------------- /src/gfxengine/vidmodes.h: -------------------------------------------------------------------------------- 1 | /*(LGPLv2.1) 2 | --------------------------------------------------------------------------- 3 | vidmodes.h - Video Mode Manager for Kobo Deluxe 4 | --------------------------------------------------------------------------- 5 | * Copyright 2007, 2009 David Olofson 6 | * Copyright 2015 David Olofson (Kobo Redux) 7 | * 8 | * This library is free software; you can redistribute it and/or modify it 9 | * under the terms of the GNU Lesser General Public License as published by 10 | * the Free Software Foundation; either version 2.1 of the License, or (at 11 | * your option) any later version. 12 | * 13 | * This library is distributed in the hope that it will be useful, but 14 | * WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser 16 | * General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public License 19 | * along with this library; if not, write to the Free Software Foundation, 20 | * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA 21 | */ 22 | 23 | #ifndef KOBO_VIDMODES_H 24 | #define KOBO_VIDMODES_H 25 | 26 | #ifdef __cplusplus 27 | extern "C" { 28 | #endif 29 | 30 | 31 | /*------------------------------------------------------------------------- 32 | Data Types and Structures 33 | -------------------------------------------------------------------------*/ 34 | 35 | /* Video mode categories */ 36 | typedef enum 37 | { 38 | VMM_ALL = 0xffffffff, 39 | VMM_DETECT = 0x00000001, /* Available modes detected by SDL */ 40 | VMM_DESKTOP = 0x00000002, /* Automatic desktop resolution */ 41 | VMM_4_3 = 0x00000010, /* 4:3 modes */ 42 | VMM_3_2 = 0x00000020, /* 3:2 modes */ 43 | VMM_5_4 = 0x00000040, /* 5:4 modes */ 44 | VMM_16_10 = 0x00000080, /* 16:10 modes */ 45 | VMM_16_9 = 0x00000100, /* 16:9 modes */ 46 | VMM_PC = 0x00010000, /* Standard PC/Mac modes */ 47 | VMM_WPC = 0x00020000, /* Widescreen PC/Mac modes */ 48 | VMM_TV = 0x00040000, /* Standard TV modes */ 49 | VMM_WTV = 0x00080000, /* Widescreen TV modes */ 50 | VMM_CINEMA = 0x00100000, /* Cinematography resolutions */ 51 | VMM_LORES = 0x10000000 /* Special low resolution modes */ 52 | } VMM_Flags; 53 | 54 | #define VMM__RECOMMENDED (VMM_DESKTOP | VMM_16_9) 55 | #define VMM__COMMON (VMM_PC | VMM_16_10 | VMM_16_9) 56 | #define VMM__WIDESCREEN (VMM_16_10 | VMM_16_9) 57 | #define VMM__NONWIDESCREEN (VMM_TV | VMM_4_3 | VMM_3_2 | VMM_5_4) 58 | 59 | /* Special video mode IDs */ 60 | typedef enum 61 | { 62 | VMID_CUSTOM = 0, /* Custom size/resolution */ 63 | VMID_DESKTOP = 1, /* Desktop resolution */ 64 | VMID_FULLWINDOW = 2 /* Fullscreen window */ 65 | } VMM_ModeID; 66 | 67 | typedef struct VMM_Mode VMM_Mode; 68 | struct VMM_Mode 69 | { 70 | VMM_Mode *next; /* Next mode in list */ 71 | char *name; /* Name, if any */ 72 | VMM_ModeID id; /* Somewhat constant mode ID */ 73 | int width; /* Display width in pixels */ 74 | int height; /* Display height in pixels */ 75 | int flags; /* (WMM_Flags) */ 76 | float aspect; /* Pixel aspect ratio */ 77 | }; 78 | 79 | 80 | /*------------------------------------------------------------------------- 81 | Gathering and constructing modes 82 | -------------------------------------------------------------------------*/ 83 | int vmm_Init(void); 84 | void vmm_Close(void); 85 | 86 | 87 | /*------------------------------------------------------------------------- 88 | Scanning 89 | -------------------------------------------------------------------------*/ 90 | VMM_Mode *vmm_Next(VMM_Mode *current); 91 | VMM_Mode *vmm_FindNext(VMM_Mode *current, int include, int skip, 92 | int maxwidth, int maxheight); 93 | 94 | 95 | /*------------------------------------------------------------------------- 96 | Indexing 97 | -------------------------------------------------------------------------*/ 98 | VMM_Mode *vmm_GetMode(int id); 99 | 100 | 101 | /*------------------------------------------------------------------------- 102 | Searching 103 | -------------------------------------------------------------------------*/ 104 | /* TODO: VMM_Mode *vmm_Find(int width, int height, int aspect); */ 105 | 106 | #ifdef __cplusplus 107 | }; 108 | #endif 109 | 110 | #endif /* KOBO_VIDMODES_H */ 111 | -------------------------------------------------------------------------------- /src/graphics.cpp: -------------------------------------------------------------------------------- 1 | /*(GPLv2) 2 | ------------------------------------------------------------ 3 | Kobo Deluxe - An enhanced SDL port of XKobo 4 | ------------------------------------------------------------ 5 | * Copyright 2016-2017 David Olofson (Kobo Redux) 6 | * 7 | * This program is free software; you can redistribute it and/or modify it 8 | * under the terms of the GNU General Public License as published by the 9 | * Free Software Foundation; either version 2 of the License, or (at your 10 | * option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, but 13 | * WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General 15 | * Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License along 18 | * with this program; if not, write to the Free Software Foundation, Inc., 19 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 | */ 21 | 22 | #include "graphics.h" 23 | 24 | 25 | #define KOBO_DEFS(x) "B_" #x, 26 | const char *kobo_gfxbanknames[] = 27 | { 28 | KOBO_ALLGFXBANKS 29 | }; 30 | #undef KOBO_DEFS 31 | 32 | 33 | #define KOBO_DEFS(x) "P_" #x, 34 | const char *kobo_palettenames[] = 35 | { 36 | KOBO_ALLPALETTES 37 | }; 38 | #undef KOBO_DEFS 39 | 40 | #define KOBO_DEFS(x) "D_" #x, 41 | const char *kobo_datanames[] = 42 | { 43 | KOBO_ALLTDITEMS 44 | }; 45 | #undef KOBO_DEFS 46 | 47 | #define KOBO_DEFS(x) "PFX_" #x, 48 | const char *kobo_pfxnames[] = 49 | { 50 | KOBO_ALLPARTICLEFX 51 | }; 52 | #undef KOBO_DEFS 53 | -------------------------------------------------------------------------------- /src/gridtfx.cpp: -------------------------------------------------------------------------------- 1 | /*(GPLv2) 2 | ------------------------------------------------------------ 3 | gridtfx.cpp - Grid Transition Effects 4 | ------------------------------------------------------------ 5 | * Copyright 2017 David Olofson (Kobo Redux) 6 | * 7 | * This program is free software; you can redistribute it and/or modify it 8 | * under the terms of the GNU General Public License as published by the 9 | * Free Software Foundation; either version 2 of the License, or (at your 10 | * option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, but 13 | * WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General 15 | * Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License along 18 | * with this program; if not, write to the Free Software Foundation, Inc., 19 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 | */ 21 | 22 | #include "kobo.h" 23 | #include "gridtfx.h" 24 | #include "random.h" 25 | 26 | KOBO_GridTFX::KOBO_GridTFX() 27 | { 28 | target = NULL; 29 | tilebank = -1; 30 | levels = 16; 31 | current_state = 0.0f; 32 | target_state = false; 33 | t0 = SDL_GetTicks(); 34 | duration = 0; 35 | style = pubrand.get(); 36 | tileset = pubrand.get(); 37 | } 38 | 39 | 40 | KOBO_GridTFX::~KOBO_GridTFX() 41 | { 42 | } 43 | 44 | 45 | void KOBO_GridTFX::Target(window_t *t) 46 | { 47 | target = t; 48 | } 49 | 50 | 51 | void KOBO_GridTFX::Tiles(int bank, int tiles_per_set) 52 | { 53 | tilebank = bank; 54 | levels = tiles_per_set; 55 | } 56 | 57 | 58 | enum KOBO_GridTFXStyles 59 | { 60 | KOBO_GRIDTFX_STYLE_0 = 0, 61 | KOBO_GRIDTFX_STYLE_1, 62 | KOBO_GRIDTFX_STYLE_2, 63 | KOBO_GRIDTFX_STYLE_3, 64 | KOBO_GRIDTFX_STYLE_4, 65 | 66 | KOBO_GRIDTFX_STYLES 67 | }; 68 | 69 | 70 | float KOBO_GridTFX::fxbias(float x, float y) 71 | { 72 | float z; 73 | switch(style % KOBO_GRIDTFX_STYLES) 74 | { 75 | default: 76 | case KOBO_GRIDTFX_STYLE_0: 77 | z = 0.0f; 78 | break; 79 | case KOBO_GRIDTFX_STYLE_1: 80 | z = (x + y) * 0.5f; 81 | break; 82 | case KOBO_GRIDTFX_STYLE_2: 83 | z = ((1.0f - x) + y) * 0.5f; 84 | break; 85 | case KOBO_GRIDTFX_STYLE_3: 86 | z = 1.0f - (x + y) * 0.5f; 87 | break; 88 | case KOBO_GRIDTFX_STYLE_4: 89 | z = (x + (1.0f - y)) * 0.5f; 90 | break; 91 | } 92 | return z * z; 93 | } 94 | 95 | 96 | void KOBO_GridTFX::Render() 97 | { 98 | float p = Progress(); 99 | if(target_state) 100 | current_state = p; 101 | else 102 | current_state = 1.0f - p; 103 | if(current_state == 0.0f) 104 | return; 105 | 106 | int tilesets = 1; 107 | int tw = 16; 108 | int th = 16; 109 | int tile0 = 0; 110 | s_bank_t *b = s_get_bank(gengine->get_gfx(), tilebank); 111 | if(b && levels) 112 | tilesets = (b->max + 1) / levels; 113 | if(b && tilesets) 114 | { 115 | tile0 = tileset % tilesets; 116 | tw = b->w; 117 | th = b->h; 118 | } 119 | else 120 | target->foreground(0x666666); 121 | 122 | float zoffs = 2.0f * current_state - 1.0f; 123 | int w = target->width(); 124 | int h = target->height(); 125 | for(int y = 0; y < h; y += th) 126 | for(int x = 0; x < w; x += tw) 127 | { 128 | float z = fxbias((float)x / w, (float)y / h) + zoffs; 129 | if(z < 0.0f) 130 | z = 0.0f; 131 | else if(z > 1.0f) 132 | z = 1.0f; 133 | if(b) 134 | { 135 | int sc = levels * (1.0f - z) + 0.5f; 136 | if(sc < levels) 137 | target->sprite(x, y, tilebank, 138 | tile0 + sc); 139 | } 140 | else 141 | { 142 | int scx = tw * z * 0.5f + 0.5f; 143 | int scy = th * z * 0.5f + 0.5f; 144 | target->fillrect(x + (tw / 2) - scx, 145 | y + (th / 2) - scy, 146 | scx * 2, scy * 2); 147 | } 148 | } 149 | } 150 | 151 | 152 | void KOBO_GridTFX::State(bool st, float dur) 153 | { 154 | float skip = 0.0f; 155 | if(Done()) 156 | { 157 | style = pubrand.get(); 158 | if(!target_state) 159 | tileset = pubrand.get(); 160 | if(target_state == st) 161 | return; 162 | } 163 | else 164 | { 165 | if(st) 166 | skip = current_state; 167 | else 168 | skip = 1.0f - current_state; 169 | } 170 | target_state = st; 171 | duration = dur * 1000.0f; 172 | t0 = SDL_GetTicks() - duration * skip; 173 | if(!duration) 174 | current_state = target_state ? 1.0f : 0.0f; 175 | } 176 | 177 | 178 | bool KOBO_GridTFX::State() 179 | { 180 | return target_state; 181 | } 182 | 183 | 184 | float KOBO_GridTFX::Progress() 185 | { 186 | if(!duration) 187 | return 1.0f; 188 | Uint32 t = SDL_GetTicks(); 189 | if(SDL_TICKS_PASSED(t, t0 + duration)) 190 | return 1.0f; 191 | return ((float)(t - t0)) / duration; 192 | } 193 | 194 | 195 | bool KOBO_GridTFX::Done() 196 | { 197 | return Progress() == 1.0f; 198 | } 199 | -------------------------------------------------------------------------------- /src/gridtfx.h: -------------------------------------------------------------------------------- 1 | /*(GPLv2) 2 | ------------------------------------------------------------ 3 | gridtfx.h - Grid Transition Effects 4 | ------------------------------------------------------------ 5 | * Copyright 2017 David Olofson (Kobo Redux) 6 | * 7 | * This program is free software; you can redistribute it and/or modify it 8 | * under the terms of the GNU General Public License as published by the 9 | * Free Software Foundation; either version 2 of the License, or (at your 10 | * option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, but 13 | * WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General 15 | * Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License along 18 | * with this program; if not, write to the Free Software Foundation, Inc., 19 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 | */ 21 | 22 | #ifndef KOBO_GRIDTFX_H 23 | #define KOBO_GRIDTFX_H 24 | 25 | #include "window.h" 26 | 27 | class KOBO_GridTFX 28 | { 29 | window_t *target; 30 | int tilebank; 31 | int levels; 32 | float current_state; // [0, 1] 33 | bool target_state; 34 | Uint32 t0; // Transition start time 35 | Uint32 duration; // Transition duration 36 | Uint32 style; 37 | Uint32 tileset; 38 | float fxbias(float x, float y); 39 | public: 40 | KOBO_GridTFX(); 41 | ~KOBO_GridTFX(); 42 | void Target(window_t *t); 43 | void Tiles(int bank, int tiles_per_set); 44 | void Render(); 45 | void State(bool st, float dur = 1.0f); 46 | bool State(); 47 | float Progress(); 48 | bool Done(); 49 | }; 50 | 51 | #endif /* KOBO_GRIDTFX_H */ 52 | -------------------------------------------------------------------------------- /src/kobolog.h: -------------------------------------------------------------------------------- 1 | /*(GPLv2) 2 | ------------------------------------------------------------ 3 | Kobo Deluxe - Logger definitions 4 | ------------------------------------------------------------ 5 | * Copyright 2003, 2009, 2017 David Olofson 6 | * 7 | * This program is free software; you can redistribute it and/or modify it 8 | * under the terms of the GNU General Public License as published by the 9 | * Free Software Foundation; either version 2 of the License, or (at your 10 | * option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, but 13 | * WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General 15 | * Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License along 18 | * with this program; if not, write to the Free Software Foundation, Inc., 19 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 | */ 21 | 22 | #ifndef KOBOLOG_H 23 | #define KOBOLOG_H 24 | 25 | #include "logger.h" 26 | 27 | #ifdef __cplusplus 28 | extern "C" { 29 | #endif 30 | 31 | /* Critical error messages: "Huston, we have a problem." */ 32 | #define CELOG 5 33 | 34 | /* Debug messages; level 2: Detailed */ 35 | #define D2LOG 6 36 | 37 | /* Debug messages; level 3: Deep Hack Mode stuff */ 38 | #define D3LOG 7 39 | 40 | #ifdef __cplusplus 41 | }; 42 | #endif 43 | 44 | // Logger targets (streams/files/callbacks) 45 | enum { 46 | KOBO_LOG_TARGET_STDOUT = 0, // stdout 47 | KOBO_LOG_TARGET_STDERR, // stderr 48 | KOBO_LOG_TARGET_DEBUG, // Debug log file 49 | KOBO_LOG_TARGET_USER // User log file (if used) 50 | }; 51 | 52 | #endif /* KOBOLOG_H */ 53 | -------------------------------------------------------------------------------- /src/logger.h: -------------------------------------------------------------------------------- 1 | /*(LGPLv2.1) 2 | --------------------------------------------------------------------------- 3 | logger.h - Simple logger with redirection 4 | --------------------------------------------------------------------------- 5 | * Copyright 2003, 2009, 2017 David Olofson 6 | * 7 | * This library is free software; you can redistribute it and/or modify it 8 | * under the terms of the GNU Lesser General Public License as published by 9 | * the Free Software Foundation; either version 2.1 of the License, or (at 10 | * your option) any later version. 11 | * 12 | * This library is distributed in the hope that it will be useful, but 13 | * WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser 15 | * General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with this library; if not, write to the Free Software Foundation, 19 | * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA 20 | */ 21 | 22 | #ifndef DO_LOGGER_H 23 | #define DO_LOGGER_H 24 | 25 | #include 26 | 27 | #ifdef __cplusplus 28 | extern "C" { 29 | #endif 30 | 31 | #define LOG_TARGETS 8 32 | #define LOG_LEVELS 32 33 | 34 | /* 35 | * Standard log levels (so libs and stuff can share your logger! :-) 36 | */ 37 | #define ULOG 0 /* User: Messages meant for normal users */ 38 | #define WLOG 1 /* Warning: Warning messages */ 39 | #define ELOG 2 /* Error: Error messages */ 40 | #define VLOG 3 /* Verbose: Messages for advanced users */ 41 | #define DLOG 4 /* Debug: Debug messages */ 42 | 43 | 44 | typedef enum 45 | { 46 | /* For log_open() */ 47 | LOG_RESET_TIME = 0x00010000, 48 | 49 | /* For log_set_target_flags() */ 50 | LOG_ANSI = 0x00000001, /* Use ANSI escape codes */ 51 | LOG_HTML = 0x00000002, /* Use HTML formatting tags */ 52 | LOG_TIMESTAMP = 0x00000100 /* Timestamp messages */ 53 | } LOG_flags; 54 | 55 | 56 | typedef enum 57 | { 58 | LOG_COLORS = 0x000f, /* Mask for color bits */ 59 | LOG_NOCOLOR = 0, /* Don't try to change! */ 60 | LOG_BLACK, 61 | LOG_RED, 62 | LOG_GREEN, 63 | LOG_YELLOW, 64 | LOG_BLUE, 65 | LOG_MAGENTA, 66 | LOG_CYAN, 67 | LOG_WHITE, 68 | LOG_BRIGHT = 0x0100, /* High intensity colors */ 69 | LOG_STRONG = 0x0200, /* Bold or underlined */ 70 | LOG_BLINK = 0x0400 /* Blinking, if possible */ 71 | } LOG_attributes; 72 | 73 | 74 | /* 75 | * The usual open/close calls... 76 | * 77 | * Note that log_close() may write footers and stuff to files, so you may get 78 | * slightly broken log files if you exit without calling it! 79 | * 80 | * log_open() returns a negative value in case of failure. 81 | */ 82 | int log_open(int flags); 83 | void log_close(void); 84 | 85 | 86 | /* 87 | * Send output through 'target' to 'stream'. 'stream' must be a valid stdio 88 | * stream opened for output. 89 | * 90 | * If 'target' is -1, all targets are changed. 91 | */ 92 | void log_set_target_stream(int target, FILE *stream); 93 | 94 | 95 | /* 96 | * Send output through 'target' to 'callback'. The callback will receive the 97 | * 'handle' pointer as its first argument, followed by the null terminated 98 | * string to output. The callback should return the number of bytes 99 | * successfully handled, or, in case of failure, a negative value. 100 | * 101 | * If 'target' is -1, all targets are changed. 102 | */ 103 | void log_set_target_callback(int target, 104 | int (*callback)(void *handle, const char *data), void *handle); 105 | 106 | 107 | /* 108 | * Set formatting flags for 'target'. 109 | * 110 | * If 'target' is -1, all targets are changed. 111 | */ 112 | void log_set_target_flags(int target, unsigned flags); 113 | 114 | 115 | /* 116 | * Enable/disable sending of output through 'level' to 'target'. 117 | * 118 | * If 'level' is -1, all levels are changed. 119 | * 120 | * If 'target' is -1, all target are changed on the specified level(s). 121 | */ 122 | void log_enable_level_target(int level, int target); 123 | void log_disable_level_target(int level, int target); 124 | 125 | 126 | /* 127 | * Set attributes for 'level'. 128 | * 129 | * If 'level' is -1, all levels are changed. 130 | */ 131 | void log_set_level_attr(int level, unsigned attr); 132 | 133 | 134 | /* 135 | * Print 'text' to 'level'. 'level' is the index of the log 136 | * level to print to. No formatting will be done, and the 137 | * output will be followed by a "newline". 138 | * 139 | * Returns a negative value in case of failure. 140 | */ 141 | int log_puts(int level, const char *text); 142 | 143 | 144 | /* 145 | * Format and print to 'level'. 'level' is the index of the 146 | * log level to print to. 147 | * 148 | * Returns a negative value in case of failure. 149 | */ 150 | int log_printf(int level, const char *format, ...); 151 | 152 | #ifdef __cplusplus 153 | }; 154 | #endif 155 | 156 | #endif /* DO_LOGGER_H */ 157 | -------------------------------------------------------------------------------- /src/map.h: -------------------------------------------------------------------------------- 1 | /*(GPLv2) 2 | ------------------------------------------------------------ 3 | Kobo Deluxe - An enhanced SDL port of XKobo 4 | ------------------------------------------------------------ 5 | * Copyright 1995, 1996 Akira Higuchi 6 | * Copyright 2002, 2007, 2009 David Olofson 7 | * Copyright 2015-2016 David Olofson (Kobo Redux) 8 | * 9 | * This program is free software; you can redistribute it and/or modify it 10 | * under the terms of the GNU General Public License as published by the 11 | * Free Software Foundation; either version 2 of the License, or (at your 12 | * option) any later version. 13 | * 14 | * This program is distributed in the hope that it will be useful, but 15 | * WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General 17 | * Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License along 20 | * with this program; if not, write to the Free Software Foundation, Inc., 21 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 22 | */ 23 | 24 | #ifndef XKOBO_H_MAP 25 | #define XKOBO_H_MAP 26 | 27 | #include "config.h" 28 | #include "scenes.h" 29 | 30 | #define SITE_MAX 1024 31 | 32 | #define WALL 1 33 | 34 | // Tile state bits 35 | #define U_MASK (1<<0) 36 | #define R_MASK (1<<1) 37 | #define D_MASK (1<<2) 38 | #define L_MASK (1<<3) 39 | #define CORE (1<<4) 40 | #define HIT_MASK (CORE | U_MASK | R_MASK | D_MASK | L_MASK) 41 | #define HARD (1<<5) 42 | #define SPACE (1<<6) 43 | #define MAP_BITS(x) ((x) & 0xff) 44 | #define MAP_TILE(x) ((x) >> 8) 45 | 46 | #define IS_SPACE(x) ((x) & SPACE) 47 | #define IS_BASE(x) (!IS_SPACE(x) && ((x) & HIT_MASK)) 48 | 49 | #define COLL_HORIZONTAL 0x01 50 | #define COLL_VERTICAL 0x02 51 | #define COLL_STUCK 0x04 52 | 53 | class KOBO_map 54 | { 55 | public: 56 | void init(const KOBO_scene *s); 57 | unsigned short &pos(int x, int y) 58 | { 59 | x &= MAP_SIZEX - 1; 60 | y &= MAP_SIZEY - 1; 61 | return data[(y << MAP_SIZEX_LOG2) + x]; 62 | } 63 | // Find first tile collision on the line (x1, y1)-(x3, y3). If there is 64 | // a solution, the return value indicates if a horizontal and/or 65 | // vertical wall was hit, the position of the collision is written 66 | // to (hx, hy), and the intersection point (effectively the point right 67 | // before collision) is written to (x2, y2). (24:8 world coordinates.) 68 | int test_line(int x1, int y1, int x3, int y3, 69 | int *x2, int *y2, int *hx, int *hy); 70 | 71 | protected: 72 | int sitex[SITE_MAX]; 73 | int sitey[SITE_MAX]; 74 | int site_max; 75 | unsigned short data[1 << (MAP_SIZEX_LOG2 + MAP_SIZEY_LOG2)]; 76 | int maze_pop(); 77 | void maze_push(int x, int y); 78 | void maze_move_and_push(int x, int y, int d); 79 | int maze_judge(int cx, int cy, int dx, int dy, int x, int y); 80 | void clear(); 81 | void make_maze(int x, int y, int difx, int dify); 82 | void convert(unsigned ratio); // ratio < 64 83 | }; 84 | 85 | #endif // XKOBO_H_MAP 86 | -------------------------------------------------------------------------------- /src/mathutil.h: -------------------------------------------------------------------------------- 1 | /*(LGPLv2.1) 2 | ---------------------------------------------------------------------- 3 | mathutil.h - Various handy integer/fixp math functions 4 | ---------------------------------------------------------------------- 5 | * Copyright 2017 David Olofson (Kobo Redux) 6 | * 7 | * This library is free software; you can redistribute it and/or modify it 8 | * under the terms of the GNU Lesser General Public License as published by 9 | * the Free Software Foundation; either version 2.1 of the License, or (at 10 | * your option) any later version. 11 | * 12 | * This library is distributed in the hope that it will be useful, but 13 | * WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser 15 | * General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with this library; if not, write to the Free Software Foundation, 19 | * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA 20 | */ 21 | 22 | 23 | #ifndef KOBO_MATHUTIL_H 24 | #define KOBO_MATHUTIL_H 25 | 26 | #ifdef __cplusplus 27 | extern "C" { 28 | #endif 29 | 30 | /* Integer modulo */ 31 | static inline int mod(int a, int b) 32 | { 33 | int r = a % b; 34 | return r < 0 ? r + b : r; 35 | } 36 | 37 | /* 38 | * Fast integer atan() approximation. Input is 24:8 fixed point. 39 | * Output is 0..64 for 0..45 deg, accurate down to LSB. 40 | * In: q = 256 * minv / maxv (0..256 <==> 0..1) 41 | * Out: atan(q / 256) * 256 (0..64 <==> 0..45 deg) 42 | * 43 | * atan() approximations for 0..90 deg: 44 | * a = 83 * q / 256 - q*q / 2844 (+/- 2.1%) 45 | * a = 82 * q / 256 - q*q / 8500 - q*q*q / 1600000 (+/- 0.6%) 46 | * 47 | * FIXME: Better version? 48 | * a = 84 * q / 256 - 95 * q*q / 524288 - 8 * q*q*q / 16777216 49 | */ 50 | static inline int fastatan(int q) 51 | { 52 | int q2 = q * q; 53 | int q3 = q2 * q; 54 | return (82 * q >> 8) - (62 * q2 >> 19) - (10 * q3 >> 24); 55 | } 56 | 57 | static inline int speed2dir(int sx, int sy, int frames) 58 | { 59 | if(!sx && !sy) 60 | return 0; 61 | 62 | int at2; 63 | if(sx > 0) 64 | { 65 | // Right 66 | if(sy < 0) 67 | { 68 | // Top-right quadrant 69 | sy = -sy; 70 | if(sy > sx) 71 | at2 = fastatan(sx * 256 / sy); 72 | else 73 | at2 = 128 - fastatan(sy * 256 / sx); 74 | } 75 | else 76 | { 77 | // Bottom-right quadrant 78 | if(sx > sy) 79 | at2 = 128 + fastatan(sy * 256 / sx); 80 | else 81 | at2 = 256 - fastatan(sx * 256 / sy); 82 | } 83 | } 84 | else 85 | { 86 | // Left 87 | sx = -sx; 88 | if(sy > 0) 89 | { 90 | // Bottom-left quadrant 91 | if(sy > sx) 92 | at2 = 256 + fastatan(sx * 256 / sy); 93 | else 94 | at2 = 384 - fastatan(sy * 256 / sx); 95 | } 96 | else 97 | { 98 | // Top-left quadrant 99 | sy = -sy; 100 | if(sx > sy) 101 | at2 = 384 + fastatan(sy * 256 / sx); 102 | else 103 | at2 = 512 - fastatan(sx * 256 / sy); 104 | } 105 | } 106 | at2 = (at2 * frames + 256) >> 9; 107 | return at2 > frames - 1 ? 1 : at2 + 1; 108 | } 109 | 110 | #ifdef __cplusplus 111 | }; 112 | #endif 113 | 114 | #endif /* KOBO_MATHUTIL_H */ 115 | -------------------------------------------------------------------------------- /src/myship.h: -------------------------------------------------------------------------------- 1 | /*(GPLv2) 2 | ------------------------------------------------------------ 3 | Kobo Deluxe - An enhanced SDL port of XKobo 4 | ------------------------------------------------------------ 5 | * Copyright 1995, 1996 Akira Higuchi 6 | * Copyright 2001, 2003, 2007, 2009 David Olofson 7 | * Copyright 2015-2017 David Olofson (Kobo Redux) 8 | * 9 | * This program is free software; you can redistribute it and/or modify it 10 | * under the terms of the GNU General Public License as published by the 11 | * Free Software Foundation; either version 2 of the License, or (at your 12 | * option) any later version. 13 | * 14 | * This program is distributed in the hope that it will be useful, but 15 | * WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General 17 | * Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License along 20 | * with this program; if not, write to the Free Software Foundation, Inc., 21 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 22 | */ 23 | 24 | #ifndef XKOBO_H_MYSHIP 25 | #define XKOBO_H_MYSHIP 26 | 27 | #include "config.h" 28 | #include "gfxengine.h" 29 | #include "game.h" 30 | #include "gamectl.h" 31 | 32 | enum KOBO_myship_state 33 | { 34 | SHIP_NORMAL, 35 | SHIP_SHIELD, 36 | SHIP_INVULNERABLE, 37 | SHIP_DEAD 38 | }; 39 | 40 | struct KOBO_player_bolt 41 | { 42 | int x, y; 43 | int dx, dy; 44 | int dir, state; 45 | cs_obj_t *object; 46 | }; 47 | 48 | class KOBO_myship 49 | { 50 | static KOBO_myship_state _state; 51 | static int shield_timer; 52 | static KOBO_player_controls ctrl; 53 | static int di; // Direction (1: N, 2: NE, 3: W etc) 54 | static int fdi; // Filtered direction (sprite frames, 24:8) 55 | static int dframes; // Number of sprite rotation frames 56 | static int x, y; // Position 57 | static int vx, vy; // Velocity 58 | static int ax, ay; // Acceleration 59 | static int hitsize; 60 | static int _health; 61 | static int _charge; // Weapon boost capacitor charge 62 | static float charge_blipp_granularity; 63 | static int charged_cooltimer; // Charged Blast cooldown timer 64 | static int blossom_cooltimer; // Fire Blossom cooldown timer 65 | static int health_time; 66 | static int nose_reload_timer; 67 | static int tail_reload_timer; 68 | static KOBO_player_bolt bolts[MAX_BOLTS]; 69 | 70 | // For the gfxengine connection 71 | static cs_obj_t *object; 72 | static bool _visible; 73 | 74 | static void shot_single(float dir, int loffset, int hoffset, 75 | int speed = 65536); 76 | static void nose_fire(); 77 | static void tail_fire(); 78 | static void charged_fire(int dir); 79 | static void fire_blossom(); 80 | static void apply_position(); 81 | static void explode(); 82 | static void thruster(int xo, int yo, int vel, 83 | KOBO_ParticleFXDef *pfxd); 84 | static void fire_control(); 85 | static void handle_controls(); 86 | static void update_position(); 87 | static void kill_bolt(int bolt, bool impact); 88 | public: 89 | static KOBO_player_controls decode_input(); 90 | static void control(KOBO_player_controls c) { ctrl = c; } 91 | static KOBO_player_controls control() { return ctrl; } 92 | static void state(KOBO_myship_state s); 93 | static int get_velx() { return vx; } 94 | static int get_vely() { return vy; } 95 | static int get_x() { return CS2PIXEL(x); } 96 | static int get_y() { return CS2PIXEL(y); } 97 | static int get_csx() { return x; } 98 | static int get_csy() { return y; } 99 | static int get_hitsize() { return hitsize; } 100 | static void impulse(int ix, int iy) 101 | { 102 | vx += ix; 103 | vy += iy; 104 | } 105 | static void init(bool newship); // New game or new stage 106 | static void init(int rhealth, int rcharge); // Replay init 107 | static void off(); 108 | static void move(); 109 | static int put(); 110 | static void force_position(); 111 | static void render(); 112 | static int hit_bolt(int ex, int ey, int hitsize, int health); 113 | static void check_base_bolts(); 114 | static void hit(int dmg); 115 | static int health() { return _health; } 116 | static int shield_time(); 117 | static void health_bonus(int h); 118 | static int regen_next() 119 | { 120 | return (_health + game.regen_step - 1) / 121 | game.regen_step * game.regen_step; 122 | } 123 | static int charge() { return _charge; } 124 | static bool secondary_available(); 125 | static bool tertiary_available(); 126 | static void set_position(int px, int py); 127 | static int alive() { return _state != SHIP_DEAD; } 128 | static bool in_range(int px, int py, int range, int &dist); 129 | static int bolt_frame(int dir, int frame) 130 | { 131 | const char animtab[8] = { 0, 1, 2, 3, 2, 1, 2, 1 }; 132 | if(frame < 4) 133 | return (dir - 1) * 4 + frame; 134 | else 135 | return 32 + ((dir - 1) & 3) * 8 + 136 | animtab[(frame - 4) & 7]; 137 | } 138 | static int bolt_frame_fade(int dir, int frame) 139 | { 140 | return 32 + 4 + ((dir - 1) & 3) * 8; 141 | } 142 | static void visible(bool vis) { _visible = vis; } 143 | static void restart_sounds(); 144 | }; 145 | 146 | extern KOBO_myship myship; 147 | 148 | #endif // XKOBO_H_MYSHIP 149 | -------------------------------------------------------------------------------- /src/openurl.cpp: -------------------------------------------------------------------------------- 1 | /*(GPLv2) 2 | ------------------------------------------------------------ 3 | Kobo Deluxe - An enhanced SDL port of XKobo 4 | ------------------------------------------------------------ 5 | * Copyright 2016-2017 David Olofson 6 | * 7 | * This program is free software; you can redistribute it and/or modify it 8 | * under the terms of the GNU General Public License as published by the 9 | * Free Software Foundation; either version 2 of the License, or (at your 10 | * option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, but 13 | * WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General 15 | * Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License along 18 | * with this program; if not, write to the Free Software Foundation, Inc., 19 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 | */ 21 | 22 | #include "openurl.h" 23 | #include "kobo.h" 24 | 25 | #ifdef _WIN32 26 | #include 27 | #include 28 | #else 29 | #include 30 | #include 31 | #endif 32 | 33 | int kobo_OpenURL(const char *url) 34 | { 35 | if(gengine && gengine->fullscreen()) 36 | gengine->switch_video_mode(KOBO_VIDEOMODE_WINDOWED); 37 | #ifdef _WIN32 38 | HINSTANCE res; 39 | CoInitializeEx(NULL, COINIT_APARTMENTTHREADED | 40 | COINIT_DISABLE_OLE1DDE); 41 | res = ShellExecute(NULL, "open", url, NULL, NULL, SW_SHOWNORMAL); 42 | CoUninitialize(); 43 | return (res > (HINSTANCE)32); 44 | #else 45 | char buf[1024]; 46 | snprintf(buf, sizeof(buf), "xdg-open %s", url); 47 | return (system(buf) != -1); 48 | #endif 49 | } 50 | -------------------------------------------------------------------------------- /src/openurl.h: -------------------------------------------------------------------------------- 1 | /*(GPLv2) 2 | ------------------------------------------------------------ 3 | Kobo Deluxe - An enhanced SDL port of XKobo 4 | ------------------------------------------------------------ 5 | * Copyright 2016-2017 David Olofson 6 | * 7 | * This program is free software; you can redistribute it and/or modify it 8 | * under the terms of the GNU General Public License as published by the 9 | * Free Software Foundation; either version 2 of the License, or (at your 10 | * option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, but 13 | * WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General 15 | * Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License along 18 | * with this program; if not, write to the Free Software Foundation, Inc., 19 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 | */ 21 | 22 | #ifndef _KOBO_OPENURL_H_ 23 | #define _KOBO_OPENURL_H_ 24 | 25 | int kobo_OpenURL(const char *url); 26 | 27 | #endif /* _KOBO_OPENURL_H_ */ 28 | -------------------------------------------------------------------------------- /src/options.h: -------------------------------------------------------------------------------- 1 | /*(GPLv2) 2 | ------------------------------------------------------------ 3 | Kobo Deluxe - An enhanced SDL port of XKobo 4 | ------------------------------------------------------------ 5 | * Copyright 2001, 2003, 2007, 2009 David Olofson 6 | * Copyright 2015-2017 David Olofson (Kobo Redux) 7 | * 8 | * This program is free software; you can redistribute it and/or modify it 9 | * under the terms of the GNU General Public License as published by the 10 | * Free Software Foundation; either version 2 of the License, or (at your 11 | * option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, but 14 | * WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General 16 | * Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License along 19 | * with this program; if not, write to the Free Software Foundation, Inc., 20 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 21 | */ 22 | 23 | #ifndef _KOBO_OPTIONS_H_ 24 | #define _KOBO_OPTIONS_H_ 25 | 26 | #include "cfgform.h" 27 | #include "vidmodes.h" 28 | 29 | #define MAX_AUDIO_DRIVERS 20 30 | 31 | class system_options_t : public config_form_t 32 | { 33 | public: 34 | system_options_t(gfxengine_t *e) : config_form_t(e) { } 35 | void build(); 36 | }; 37 | 38 | class video_options_t : public config_form_t 39 | { 40 | int showmodes; 41 | int showlow; 42 | int firstbuild; 43 | public: 44 | video_options_t(gfxengine_t *e) : config_form_t(e) 45 | { 46 | showmodes = VMM_PC; 47 | showlow = 0; 48 | firstbuild = 1; 49 | } 50 | void build(); 51 | void close(); 52 | }; 53 | 54 | class controls_options_t : public config_form_t 55 | { 56 | public: 57 | controls_options_t(gfxengine_t *e) : config_form_t(e) { } 58 | void build(); 59 | }; 60 | 61 | class bindings_options_t : public config_form_t 62 | { 63 | public: 64 | bindings_options_t(gfxengine_t *e) : config_form_t(e) { } 65 | void build(); 66 | }; 67 | 68 | class audio_options_t : public config_form_t 69 | { 70 | int driver; 71 | const char *drivers[MAX_AUDIO_DRIVERS]; 72 | public: 73 | audio_options_t(gfxengine_t *e) : config_form_t(e) 74 | { 75 | driver = -1; 76 | memset(drivers, 0, sizeof(drivers)); 77 | } 78 | void build(); 79 | void prepare_to_apply(); 80 | }; 81 | 82 | class interface_options_t : public config_form_t 83 | { 84 | void add_theme_items(const char *type); 85 | public: 86 | interface_options_t(gfxengine_t *e) : config_form_t(e) { } 87 | void build(); 88 | }; 89 | 90 | class game_options_t : public config_form_t 91 | { 92 | public: 93 | game_options_t(gfxengine_t *e) : config_form_t(e) { } 94 | void build(); 95 | }; 96 | 97 | class cheat_options_t : public config_form_t 98 | { 99 | public: 100 | cheat_options_t(gfxengine_t *e) : config_form_t(e) { } 101 | void build(); 102 | }; 103 | 104 | class debug_options_t : public config_form_t 105 | { 106 | public: 107 | debug_options_t(gfxengine_t *e) : config_form_t(e) { } 108 | void build(); 109 | }; 110 | 111 | #endif //_KOBO_OPTIONS_H_ 112 | -------------------------------------------------------------------------------- /src/pfile.h: -------------------------------------------------------------------------------- 1 | /*(LGPLv2.1) 2 | --------------------------------------------------------------------------- 3 | pfile.h - Portable File Access Toolkit 4 | --------------------------------------------------------------------------- 5 | * Copyright 2002, 2009, 2017 David Olofson 6 | * 7 | * This library is free software; you can redistribute it and/or modify it 8 | * under the terms of the GNU Lesser General Public License as published by 9 | * the Free Software Foundation; either version 2.1 of the License, or (at 10 | * your option) any later version. 11 | * 12 | * This library is distributed in the hope that it will be useful, but 13 | * WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser 15 | * General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with this library; if not, write to the Free Software Foundation, 19 | * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA 20 | */ 21 | 22 | #ifndef _PFILE_H_ 23 | #define _PFILE_H_ 24 | 25 | #include 26 | #include 27 | #include 28 | 29 | #define PFILE_ALIGN 4 30 | 31 | #ifdef WIN32 32 | time_t timegm(struct tm *brokentime); 33 | #endif 34 | 35 | 36 | //////////////////////////////////////////////////////////// 37 | // Note that these classes can keep track of only one 38 | // chunk at a time! Recursive chunk-inside-chunk is *NOT* 39 | // supported. 40 | //////////////////////////////////////////////////////////// 41 | 42 | //Create a little endian "FOURCC" ID code. (That is, 'a' will be 43 | //first if the integer result is stored in little endian format 44 | //in a file.) 45 | #define MAKE_4CC(a, b, c, d) \ 46 | (((a)&0xff) | (((b)<<8)&0xff00) | \ 47 | (((c)<<16)&0xff0000) | (((d)<<24)&0xff000000)) 48 | 49 | 50 | //////////////////////////////////////////////////////////// 51 | // pfile_t - Portable File Access Base Class 52 | //////////////////////////////////////////////////////////// 53 | // Handles the reading and writing of data from/to file via 54 | // the internal buffer. 55 | // 56 | // Reading can be done either directly from the file, or 57 | // through the internal buffer. 58 | // 59 | // To read through the buffer, the desired number of bytes 60 | // (for example, all bytes of a chunk) must be read into the 61 | // buffer using read_buffer(). Subsequent reads will be from 62 | // the buffer, and end-of-buffer is treated like EOF. 63 | // 64 | // Writing is always done to the buffer. To actually write 65 | // data to file, call write_buffer(). 66 | // 67 | // Chunks are 4 byte aligned when written, with zero padding 68 | // before the FourCC. The pad bytes are NOT included in the 69 | // size of the previous chunk. Instead, chunk_read() will 70 | // start by skipping bytes until it finds a non-zero byte, 71 | // or hits EOF, so alignment changes will not break 72 | // compatibility. 73 | // 74 | // IMPORTANT: 75 | // Written data is LOST if the pfile object is destroyed 76 | // before write_buffer() is called! 77 | // 78 | // Reading RIFF style chunks: 79 | // Use chunk_read() to read the entire chunk into the 80 | // internal buffer. If this succeeds, chunk_type() and 81 | // chunk_size() will return information about the chunk, 82 | // and subsequent read() calls will read from the data 83 | // section of the chunk. Use chunk_end() to stop reading, 84 | // and discard the buffer. The next read() will start at 85 | // the first byte after the end of the chunk. 86 | // 87 | // Writing RIFF style chunks: 88 | // Use chunk_write() to set the type of the chunk to 89 | // write. Subsequent write()ing will be done to the 90 | // internal buffer, which will grow as needed. Use 91 | // chunk_end() to write the whole chunk, with the correct 92 | // size and all data. chunk_end() will discard the buffer 93 | // and return the object to "direct" operation. 94 | // 95 | class pfile_t 96 | { 97 | FILE *f; // Just a plain file handle... 98 | int _status; // < 0 if there was an error 99 | int bufsize; // Actual malloc()ed size of buffer 100 | int bufused; // Current buffer write position 101 | int bufpos; // Current buffer read position 102 | char *buffer; // Read/write buffer 103 | uint32_t chunk_id; // Chunk type ID 104 | int32_t chunk_ver; // Chunk format version 105 | bool chunk_writing; // true if building a chunk for writing 106 | 107 | char fourccbuf[8]; 108 | 109 | // Initialize buffer for writing. Subsequent write() calls 110 | // will write to the buffer instead of the file. 111 | int buffer_init(); 112 | 113 | // Initialize buffer, and read 'len' bytes into it. 114 | // Subsequent read() calls will read from the buffer 115 | // instead of the file. 116 | int buffer_read(int len); 117 | 118 | //Unbuffered write operations 119 | int write_ub(const void *data, int len); 120 | int write_ub(uint32_t x); 121 | int write_ub(int32_t x); 122 | int write_ub_align(int alignment); 123 | public: 124 | pfile_t(FILE *file); 125 | virtual ~pfile_t(); 126 | 127 | int status(); //Read and reset current status. 128 | int status(int new_status); //Set (provided the current status 129 | // >= 0) and return (new) status 130 | 131 | //These return # of bytes read, or -1 in case of EOF, or an error. 132 | int read(void *data, int len); 133 | int read(uint32_t &x); 134 | int read(int32_t &x); 135 | int read(int16_t &x); 136 | int read(int8_t &x); 137 | int read(struct tm &t); 138 | 139 | void buffer_close(); //Discard the buffer and return to 140 | //"direct" operation. 141 | 142 | //These return # of bytes written, or -1 in case of EOF, or an error. 143 | int write(const void *data, int len); 144 | int write(uint32_t x); 145 | int write(int32_t x); 146 | int write(int16_t x); 147 | int write(int8_t x); 148 | int write(const struct tm *t); 149 | 150 | int buffer_write(); //Write the whole buffer to the file. 151 | //This will flush the buffer as well. 152 | 153 | //RIFF style chunk handling 154 | const char *fourcc2string(unsigned int c); 155 | int chunk_read(); 156 | int chunk_type() { return chunk_id; } 157 | int chunk_version() { return chunk_ver; } 158 | int chunk_size() { return bufused; } 159 | int chunk_write(uint32_t id, int32_t version); 160 | int chunk_end(); 161 | }; 162 | 163 | #endif 164 | -------------------------------------------------------------------------------- /src/profiler.h: -------------------------------------------------------------------------------- 1 | /*(LGPLv2.1) 2 | ---------------------------------------------------------------------- 3 | profiler.h - Performance counter based profiling tool 4 | ---------------------------------------------------------------------- 5 | * Copyright 2017 David Olofson (Kobo Redux) 6 | * 7 | * This library is free software; you can redistribute it and/or modify it 8 | * under the terms of the GNU Lesser General Public License as published by 9 | * the Free Software Foundation; either version 2.1 of the License, or (at 10 | * your option) any later version. 11 | * 12 | * This library is distributed in the hope that it will be useful, but 13 | * WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser 15 | * General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with this library; if not, write to the Free Software Foundation, 19 | * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA 20 | */ 21 | 22 | #ifndef KOBO_PROFILER_H 23 | #define KOBO_PROFILER_H 24 | 25 | #include "SDL.h" 26 | 27 | class KOBO_Profiler 28 | { 29 | protected: 30 | Uint64 f; // Counter frequency (Hz) 31 | int samples; // Samples taken 32 | Uint64 period_start; 33 | Uint64 sample_start; // Sample start 34 | Uint64 total; // Total cycles spent 35 | 36 | // Result 37 | int r_samples; 38 | double r_average_time; // ms per sample 39 | public: 40 | KOBO_Profiler() 41 | { 42 | f = SDL_GetPerformanceFrequency(); 43 | r_samples = samples = 0; 44 | period_start = 0; 45 | sample_start = 0; 46 | total = 0; 47 | r_average_time = 0.0f; 48 | Period(); 49 | } 50 | 51 | void SampleBegin() 52 | { 53 | sample_start = SDL_GetPerformanceCounter(); 54 | } 55 | 56 | void SampleEnd() 57 | { 58 | Uint64 t = SDL_GetPerformanceCounter(); 59 | total += t - sample_start; 60 | ++samples; 61 | } 62 | 63 | void Period() 64 | { 65 | Uint64 t = SDL_GetPerformanceCounter(); 66 | r_samples = samples; 67 | if(r_samples) 68 | { 69 | r_average_time = (double)total / r_samples / f * 70 | 1000.0f; 71 | } 72 | else 73 | { 74 | r_average_time = 0.0f; 75 | } 76 | period_start = t; 77 | samples = 0; 78 | total = 0; 79 | } 80 | 81 | float PeriodDuration() 82 | { 83 | Uint64 t = SDL_GetPerformanceCounter(); 84 | return (double)(t - period_start) / f; 85 | } 86 | 87 | int Samples() 88 | { 89 | return r_samples; 90 | } 91 | 92 | float AverageTime() 93 | { 94 | return r_average_time; 95 | } 96 | }; 97 | 98 | #endif // KOBO_PROFILER_H 99 | -------------------------------------------------------------------------------- /src/radar.cpp: -------------------------------------------------------------------------------- 1 | /*(GPLv2) 2 | ------------------------------------------------------------ 3 | Kobo Deluxe - An enhanced SDL port of XKobo 4 | ------------------------------------------------------------ 5 | * Copyright 1995, 1996 Akira Higuchi 6 | * Copyright 2001-2003, 2005-2007, 2009 David Olofson 7 | * Copyright 2015-2016 David Olofson (Kobo Redux) 8 | * 9 | * This program is free software; you can redistribute it and/or modify it 10 | * under the terms of the GNU General Public License as published by the 11 | * Free Software Foundation; either version 2 of the License, or (at your 12 | * option) any later version. 13 | * 14 | * This program is distributed in the hope that it will be useful, but 15 | * WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General 17 | * Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License along 20 | * with this program; if not, write to the Free Software Foundation, Inc., 21 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 22 | */ 23 | 24 | #include 25 | #include 26 | 27 | #include "kobo.h" 28 | #include "kobolog.h" 29 | #include "screen.h" 30 | #include "myship.h" 31 | #include "radar.h" 32 | #include "prefs.h" 33 | #include "random.h" 34 | 35 | /*--------------------------------------------------------------------- 36 | KOBO_radar_map 37 | ---------------------------------------------------------------------*/ 38 | KOBO_radar_map::KOBO_radar_map(gfxengine_t *e) : window_t(e) 39 | { 40 | w = MAP_SIZEX; 41 | h = MAP_SIZEY; 42 | } 43 | 44 | 45 | void KOBO_radar_map::update(int x, int y, int draw_space) 46 | { 47 | int a = MAP_BITS(screen.get_map(x, y)); 48 | if(IS_SPACE(a)) 49 | { 50 | if(!draw_space) 51 | return; 52 | foreground(colors[KOBO_RC_BACKGROUND]); 53 | } 54 | else if(a & CORE) 55 | foreground(colors[KOBO_RC_CORE]); 56 | else if((a == U_MASK) || (a == R_MASK) || (a == D_MASK) || 57 | (a == L_MASK)) 58 | foreground(colors[KOBO_RC_NODE]); 59 | else if(a & HIT_MASK) 60 | foreground(colors[KOBO_RC_BASE]); 61 | point(x, y); 62 | } 63 | 64 | 65 | void KOBO_radar_map::refresh(SDL_Rect *r) 66 | { 67 | int draw_space = 1; 68 | SDL_Rect nr; 69 | if(!r) 70 | { 71 | nr.x = 0; 72 | nr.y = 0; 73 | nr.w = w; 74 | nr.h = h; 75 | r = &nr; 76 | clear(r); 77 | draw_space = 0; 78 | } 79 | int i, j; 80 | for(i = 0; i < r->w; i++) 81 | for(j = 0; j < r->h; j++) 82 | update(r->x + i, r->y + j, draw_space); 83 | } 84 | 85 | 86 | /*--------------------------------------------------------------------- 87 | KOBO_radar_window 88 | ---------------------------------------------------------------------*/ 89 | KOBO_radar_window::KOBO_radar_window(gfxengine_t *e) : window_t(e) 90 | { 91 | _mode = RM_OFF; 92 | old_scrollradar = -1; 93 | xpos = -1; 94 | ypos = -1; 95 | xoffs = 0; 96 | yoffs = 0; 97 | time = 0; 98 | } 99 | 100 | 101 | void KOBO_radar_window::update(int mx, int my) 102 | { 103 | SDL_Rect r; 104 | r.x = mx & (MAP_SIZEX - 1); 105 | r.y = my & (MAP_SIZEY - 1); 106 | r.w = r.h = 1; 107 | wmap->invalidate(&r); 108 | } 109 | 110 | 111 | void KOBO_radar_window::refresh(SDL_Rect *r) 112 | { 113 | switch(_mode) 114 | { 115 | case RM__REINIT: 116 | case RM_OFF: 117 | case RM_NOISE: 118 | case RM_INFO: 119 | clear(r); 120 | break; 121 | case RM_SHOW: 122 | blit(0, 0, wmap); 123 | break; 124 | case RM_RADAR: 125 | if(prefs->scrollradar) 126 | { 127 | blit(-xoffs, MAP_SIZEY - yoffs, wmap); 128 | blit(-xoffs, -yoffs, wmap); 129 | blit(MAP_SIZEX - xoffs, MAP_SIZEY - yoffs, wmap); 130 | blit(MAP_SIZEX - xoffs, -yoffs, wmap); 131 | } 132 | else 133 | blit(0, 0, wmap); 134 | int t = SDL_GetTicks(); 135 | // NOTE: 136 | // This is not the wmap window, so there is at least a 137 | // theoretical possibility that wmap->colors[] is mapped 138 | // for a different pixel format! 139 | foreground(map_rgb(engine->palette(KOBO_P_RADAR, 140 | KOBO_RC_PLAYER0 + t / 100 % 8))); 141 | point((xpos - pxoffs) & (MAP_SIZEX - 1), 142 | (ypos - pyoffs) & (MAP_SIZEY - 1)); 143 | break; 144 | } 145 | } 146 | 147 | 148 | void KOBO_radar_window::mode(KOBO_radar_modes newmode) 149 | { 150 | if(newmode == RM__REINIT) 151 | newmode = _mode; 152 | for(int i = 0; i < KOBO_RC__COUNT; ++i) 153 | wmap->colors[i] = map_rgb(engine->palette(KOBO_P_RADAR, i)); 154 | wmap->background(wmap->colors[KOBO_RC_BACKGROUND]); 155 | _mode = newmode; 156 | time = SDL_GetTicks(); 157 | wmap->invalidate(); 158 | invalidate(); 159 | } 160 | 161 | 162 | void KOBO_radar_window::set_scroll(int xscroll, int yscroll) 163 | { 164 | xoffs = (xscroll + MAP_SIZEX / 2) & (MAP_SIZEX - 1); 165 | yoffs = (yscroll + MAP_SIZEY / 2) & (MAP_SIZEY - 1); 166 | } 167 | 168 | 169 | void KOBO_radar_window::radar() 170 | { 171 | int xpos_new = (myship.get_x() & (WORLD_SIZEX - 1)) >> 4; 172 | int ypos_new = (myship.get_y() & (WORLD_SIZEY - 1)) >> 4; 173 | if((xpos_new == xpos) && (ypos_new == ypos)) 174 | return; 175 | if(prefs->scrollradar) 176 | { 177 | // Scrolling 178 | xpos = xpos_new; 179 | ypos = ypos_new; 180 | set_scroll(xpos, ypos); 181 | pxoffs = xoffs; 182 | pyoffs = yoffs; 183 | } 184 | else 185 | { 186 | // Fixed 187 | xpos = xpos_new; 188 | ypos = ypos_new; 189 | pxoffs = pyoffs = xoffs = yoffs = 0; 190 | } 191 | } 192 | 193 | 194 | void KOBO_radar_window::frame() 195 | { 196 | if(prefs->scrollradar != old_scrollradar) 197 | { 198 | old_scrollradar = prefs->scrollradar; 199 | time = SDL_GetTicks(); 200 | pxoffs = pyoffs = xoffs = yoffs = 0; 201 | } 202 | switch(_mode) 203 | { 204 | case RM__REINIT: 205 | case RM_OFF: 206 | break; 207 | case RM_RADAR: 208 | radar(); 209 | break; 210 | case RM_SHOW: 211 | break; 212 | case RM_NOISE: 213 | case RM_INFO: 214 | clear(); 215 | break; 216 | } 217 | } 218 | -------------------------------------------------------------------------------- /src/radar.h: -------------------------------------------------------------------------------- 1 | /*(GPLv2) 2 | ------------------------------------------------------------ 3 | Kobo Deluxe - An enhanced SDL port of XKobo 4 | ------------------------------------------------------------ 5 | * Copyright 1995, 1996 Akira Higuchi 6 | * Copyright 2001-2003, 2005-2007, 2009 David Olofson 7 | * Copyright 2015-2016 David Olofson (Kobo Redux) 8 | * 9 | * This program is free software; you can redistribute it and/or modify it 10 | * under the terms of the GNU General Public License as published by the 11 | * Free Software Foundation; either version 2 of the License, or (at your 12 | * option) any later version. 13 | * 14 | * This program is distributed in the hope that it will be useful, but 15 | * WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General 17 | * Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License along 20 | * with this program; if not, write to the Free Software Foundation, Inc., 21 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 22 | */ 23 | 24 | #ifndef KOBO_RADAR_H 25 | #define KOBO_RADAR_H 26 | 27 | #include "window.h" 28 | 29 | enum KOBO_radar_modes 30 | { 31 | RM__REINIT, // Reinitialize (lost windows etc) 32 | RM_OFF, // Gray, empty 33 | RM_RADAR, // Radar display 34 | RM_SHOW, // Show map (no player ship cursor) 35 | RM_NOISE, // Radar interference 36 | RM_INFO // Scrolling info display 37 | }; 38 | 39 | enum KOBO_radar_colors 40 | { 41 | KOBO_RC_BACKGROUND = 0, 42 | KOBO_RC_BASE, 43 | KOBO_RC_NODE, 44 | KOBO_RC_CORE, 45 | KOBO_RC_PLAYER0, 46 | KOBO_RC_PLAYER1, 47 | KOBO_RC_PLAYER2, 48 | KOBO_RC_PLAYER3, 49 | KOBO_RC_PLAYER4, 50 | KOBO_RC_PLAYER5, 51 | KOBO_RC_PLAYER6, 52 | KOBO_RC_PLAYER7, 53 | KOBO_RC__COUNT 54 | }; 55 | 56 | // The off-screen map window 57 | class KOBO_radar_map : public window_t 58 | { 59 | public: 60 | int w, h; //Map size (tiles) 61 | Uint32 colors[KOBO_RC__COUNT]; //Pixel colors 62 | KOBO_radar_map(gfxengine_t *e); 63 | void refresh(SDL_Rect *r); 64 | void update(int x, int y, int draw_space); //Update one tile 65 | }; 66 | 67 | // The on-screen radar window 68 | class KOBO_radar_window : public window_t 69 | { 70 | KOBO_radar_modes _mode; 71 | int old_scrollradar; //To detect prefs change 72 | int xpos, ypos; //Player position (tiles) 73 | int xoffs, yoffs; //Scroll offset (tiles) 74 | int pxoffs, pyoffs; //Scroll offset for player marker 75 | int platched; //p*offset latched yet? 76 | int time; //for delta time calc 77 | void radar(); //Drive any actual radar mode 78 | void noise(); //Render noise effect 79 | void set_scroll(int xscroll, int yscroll); //Set map scroll offset 80 | public: 81 | KOBO_radar_window(gfxengine_t *e); 82 | void refresh(SDL_Rect *r); 83 | void mode(KOBO_radar_modes newmode);//Set radar mode 84 | void update(int mx, int my); //Update map + radar 85 | void frame(); //Track player, drive logic etc... 86 | }; 87 | 88 | #endif // KOBO_RADAR_H 89 | -------------------------------------------------------------------------------- /src/random.cpp: -------------------------------------------------------------------------------- 1 | /*(GPLv2) 2 | ------------------------------------------------------------ 3 | Kobo Deluxe - An enhanced SDL port of XKobo 4 | ------------------------------------------------------------ 5 | * Copyright (C) 1995, 1996 Akira Higuchi 6 | * Copyright (C) 2002, 2009 David Olofson 7 | * 8 | * This program is free software; you can redistribute it and/or modify it 9 | * under the terms of the GNU General Public License as published by the 10 | * Free Software Foundation; either version 2 of the License, or (at your 11 | * option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, but 14 | * WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General 16 | * Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License along 19 | * with this program; if not, write to the Free Software Foundation, Inc., 20 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 21 | */ 22 | 23 | #include "random.h" 24 | 25 | rand_num_t gamerand; 26 | rand_num_t pubrand; 27 | -------------------------------------------------------------------------------- /src/random.h: -------------------------------------------------------------------------------- 1 | /*(GPLv2) 2 | ------------------------------------------------------------ 3 | Kobo Deluxe - An enhanced SDL port of XKobo 4 | ------------------------------------------------------------ 5 | * Copyright 1995, 1996 Akira Higuchi 6 | * Copyright 2002, 2007, 2009 David Olofson 7 | * Copyright 2015, 2017 David Olofson (Kobo Redux) 8 | * 9 | * This program is free software; you can redistribute it and/or modify it 10 | * under the terms of the GNU General Public License as published by the 11 | * Free Software Foundation; either version 2 of the License, or (at your 12 | * option) any later version. 13 | * 14 | * This program is distributed in the hope that it will be useful, but 15 | * WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General 17 | * Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License along 20 | * with this program; if not, write to the Free Software Foundation, Inc., 21 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 22 | */ 23 | 24 | #ifndef _KOBO_RANDOM_H_ 25 | #define _KOBO_RANDOM_H_ 26 | 27 | #include "SDL.h" 28 | 29 | class rand_num_t 30 | { 31 | Uint32 seed; 32 | public: 33 | void init(Uint32 _seed = 0) 34 | { 35 | if(_seed) 36 | seed = _seed; 37 | else 38 | seed = SDL_GetTicks(); 39 | } 40 | 41 | Uint32 get_seed() { return seed; } 42 | 43 | Uint32 get() 44 | { 45 | seed *= 1566083941UL; 46 | seed++; 47 | seed &= 0xffffffffUL; 48 | return seed; 49 | } 50 | 51 | Uint32 get(Uint32 bit) 52 | { 53 | seed *= 1566083941UL; 54 | seed++; 55 | seed &= 0xffffffffUL; 56 | return (seed >> (32 - bit)); 57 | } 58 | }; 59 | 60 | // This instance is ONLY for map generation and game logic! Stealing numbers 61 | // from here will screw up demo/replay playback, checkpoints, saves and the 62 | // like totally, as demos record only the seed used for each level; not every 63 | // random number used. 64 | extern rand_num_t gamerand; 65 | 66 | // Use this "public" random number generator for other stuff, like explosion 67 | // effects, and things that may pick different amounts of numbers depending on 68 | // engine version, configuration, computer speed and the like. Due to the 69 | // issues mentioned above, this generator must NOT be used for anything that 70 | // affects the game logic in any way. 71 | extern rand_num_t pubrand; 72 | 73 | #endif //_KOBO_RANDOM_H_ 74 | -------------------------------------------------------------------------------- /src/replay.h: -------------------------------------------------------------------------------- 1 | /*(GPLv2) 2 | ------------------------------------------------------------ 3 | Kobo Redux - Replay/gamesave logger 4 | ------------------------------------------------------------ 5 | * Copyright 2017 David Olofson 6 | * 7 | * This program is free software; you can redistribute it and/or modify it 8 | * under the terms of the GNU General Public License as published by the 9 | * Free Software Foundation; either version 2 of the License, or (at your 10 | * option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, but 13 | * WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General 15 | * Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License along 18 | * with this program; if not, write to the Free Software Foundation, Inc., 19 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 | */ 21 | 22 | /* 23 | * Save/replay versioning 24 | * 25 | * KOBO_REPLAY_VERSION 26 | * Integer 8:8:8:8 version code that is bumped to the current game 27 | * version (KOBO_VERSION) whenever a compatibility breaking change 28 | * (that is, basically any change at all) is made to the game 29 | * logic code. 30 | * Some versions of the game may accept the initial state part 31 | * from older version saves with some restrictions, but replay 32 | * data will just not work, as it's totally dependent on the game 33 | * logic. 34 | * 35 | * KOBO_replay.version 36 | * Initialized to KOBO_REPLAY_VERSION as a KOBO_replay is created. 37 | * 38 | * KOBO_replay.gameversion 39 | * Initialized to KOBO_VERSION. Intended for debugging purposes, 40 | * and may be checked in special cases, if unintentional 41 | * compatibility breaking changes are discovered. 42 | */ 43 | 44 | #ifndef _KOBO_REPLAY_H_ 45 | #define _KOBO_REPLAY_H_ 46 | 47 | #include "pfile.h" 48 | #include "gamectl.h" 49 | 50 | // Replay header 51 | #define KOBO_PF_REPH_4CC MAKE_4CC('R', 'E', 'P', 'H') 52 | #define KOBO_PF_REPH_VERSION 1 53 | 54 | // Replay data 55 | #define KOBO_PF_REPD_4CC MAKE_4CC('R', 'E', 'P', 'D') 56 | #define KOBO_PF_REPD_VERSION 1 57 | 58 | // Minimal acceptable length of a replay. (Game logic frames) This is used to 59 | // determine whether or not a replay is long enough to start the game in replay 60 | // mode, or if we should just start in "Get Ready" state instead. 61 | #define KOBO_MIN_REPLAY_LENGTH 30 62 | 63 | enum KOBO_replay_compat 64 | { 65 | KOBO_RPCOM_NONE = 0, 66 | KOBO_RPCOM_LIMITED, 67 | KOBO_RPCOM_FULL 68 | }; 69 | 70 | enum KOBO_replay_logdump 71 | { 72 | KOBO_RLD_ALL, 73 | KOBO_RLD_HEADER, 74 | KOBO_RLD_REPLAY, 75 | KOBO_RLD_GAMESTATE 76 | }; 77 | 78 | class KOBO_replay_gst; 79 | 80 | class KOBO_replay 81 | { 82 | int32_t version; // Game logic version 83 | int32_t gameversion; // Game version that generated this 84 | uint32_t config; // Relevant config switches 85 | 86 | // Player input log 87 | uint32_t bufsize; // Physical size of buffer 88 | uint32_t bufrecord; // Number of frames recorded 89 | uint32_t bufplay; // Current playback frame 90 | uint8_t *buffer; 91 | 92 | KOBO_replay_gst *gst_first; // List head 93 | KOBO_replay_gst *gst_last; // List tail 94 | KOBO_replay_gst *gst_current; // Current item 95 | 96 | KOBO_replay_compat compat; // Compatibility status of current data 97 | 98 | bool _modified; 99 | 100 | uint32_t get_config(); 101 | void write(uint8_t b); 102 | bool load_reph(pfile_t *pf); 103 | bool load_repd(pfile_t *pf); 104 | bool load_gstd(pfile_t *pf); 105 | public: 106 | KOBO_replay(); 107 | virtual ~KOBO_replay(); 108 | 109 | bool modified() { return _modified; } 110 | void modified(bool m) { _modified = m; } 111 | 112 | // Game parameters 113 | int32_t stage; 114 | int32_t type; // game_types_t 115 | int32_t skill; // skill_levels_t 116 | 117 | // Initial game state 118 | time_t starttime; // Level start time 119 | uint32_t seed; // Seed for gamerand 120 | int32_t health; // Player health 121 | int32_t charge; // Player secondary weapon accu charge 122 | int32_t score; // Player score 123 | 124 | // Final game state 125 | time_t endtime; // End/save time 126 | int32_t end_health; 127 | int32_t end_charge; 128 | int32_t end_score; 129 | 130 | // Total number of deaths/rewinds on this stage during this campaign 131 | int32_t deaths; 132 | 133 | // Record 134 | void write(KOBO_player_controls ctrl); // Record + advance 135 | void compact(); // Drop preallocated buffer space to save RAM 136 | 137 | // Compatibility check 138 | KOBO_replay_compat compatibility() { return compat; } 139 | 140 | // Playback 141 | void rewind(); // Rewind to start 142 | KOBO_player_controls read(); // Read + advance 143 | 144 | // Punch-in (Start recording at the current playback position, 145 | // overwriting any previous data from this point on.) 146 | void punchin(); 147 | 148 | // Delete replay data and reset version and config data to current 149 | void reset(); 150 | 151 | // reset() and clear game stats 152 | void clear(); 153 | 154 | void log_dump(int level, KOBO_replay_logdump rld = KOBO_RLD_ALL); 155 | 156 | // Status 157 | unsigned position() { return bufplay; } 158 | float progress(); 159 | unsigned recorded() { return bufrecord; } 160 | 161 | // Game state snapshots 162 | bool record_state(); // Record snapshot of current game state 163 | bool verify_state(); // Verify game state against snapshot, if any 164 | 165 | // Write REPH, REPD, and (optionally) GSTD chucks to campaign file 166 | bool save(pfile_t *pf); 167 | 168 | // Read REPH, REPD, or GSTD chuck from campaign file 169 | // NOTE: This call expects chunk_read() to have been called first! 170 | bool load(pfile_t *pf); 171 | }; 172 | 173 | #endif // _KOBO_REPLAY_H_ 174 | -------------------------------------------------------------------------------- /src/replay_gst.cpp: -------------------------------------------------------------------------------- 1 | /*(GPLv2) 2 | ------------------------------------------------------------ 3 | Kobo Redux - Game state logging/verification 4 | ------------------------------------------------------------ 5 | * Copyright 2017 David Olofson 6 | * 7 | * This program is free software; you can redistribute it and/or modify it 8 | * under the terms of the GNU General Public License as published by the 9 | * Free Software Foundation; either version 2 of the License, or (at your 10 | * option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, but 13 | * WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General 15 | * Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License along 18 | * with this program; if not, write to the Free Software Foundation, Inc., 19 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 | */ 21 | 22 | #include "kobolog.h" 23 | #include "replay_gst.h" 24 | #include "myship.h" 25 | #include "manage.h" 26 | #include "enemies.h" 27 | 28 | KOBO_replay_gst::KOBO_replay_gst() 29 | { 30 | next = NULL; 31 | } 32 | 33 | 34 | KOBO_replay_gst::~KOBO_replay_gst() 35 | { 36 | } 37 | 38 | 39 | bool KOBO_replay_gst::record() 40 | { 41 | frame = manage.game_time(); 42 | score = manage.current_score(); 43 | player.x = myship.get_csx(); 44 | player.y = myship.get_csy(); 45 | player.health = myship.health(); 46 | player.charge = myship.charge(); 47 | for(int i = 0; i < KOBO_EK__COUNT; ++i) 48 | { 49 | enemystats[i].spawned = enemies.stats[i].spawned; 50 | enemystats[i].killed = enemies.stats[i].killed; 51 | enemystats[i].health = enemies.stats[i].health; 52 | enemystats[i].damage = enemies.stats[i].damage; 53 | } 54 | return true; 55 | } 56 | 57 | 58 | void KOBO_replay_gst::verify(const char *desc, const char *desc2, 59 | uint32_t snap, uint32_t current) 60 | { 61 | if(snap == current) 62 | return; 63 | status = false; 64 | log_printf(ELOG, "REPLAY DIFF in frame %d: %s%s is %u; " 65 | "should be %u!\n", 66 | frame, desc, desc2 ? desc2 : "", current, snap); 67 | } 68 | 69 | 70 | void KOBO_replay_gst::verify(const char *desc, const char *desc2, 71 | int32_t snap, int32_t current) 72 | { 73 | if(snap == current) 74 | return; 75 | status = false; 76 | log_printf(ELOG, "REPLAY DIFF in frame %d: %s%s is %d; " 77 | "should be %d!\n", 78 | frame, desc, desc2 ? desc2 : "", current, snap); 79 | } 80 | 81 | 82 | bool KOBO_replay_gst::verify() 83 | { 84 | if(frame != manage.game_time()) 85 | { 86 | log_printf(ELOG, "KOBO_replay_gst::verify() called on wrong " 87 | "frame!\n"); 88 | return false; 89 | } 90 | status = true; 91 | verify("score", "", score, manage.current_score()); 92 | verify("player.x", "", player.x, myship.get_csx()); 93 | verify("player.y", "", player.y, myship.get_csy()); 94 | verify("player.health", "", player.health, myship.health()); 95 | verify("player.charge", "", player.charge, myship.charge()); 96 | for(int i = 0; i < KOBO_EK__COUNT; ++i) 97 | { 98 | switch((KOBO_enemy_kinds)i) 99 | { 100 | case KOBO_EK_RINGEXPL: 101 | case KOBO_EK_GREENBLTEXPL: 102 | case KOBO_EK_REDBLTEXPL: 103 | case KOBO_EK_BLUEBLTEXPL: 104 | case KOBO_EK_BOLTEXPL: 105 | case KOBO_EK_ROCKEXPL: 106 | // These enemies should not affect gameplay! 107 | continue; 108 | default: 109 | break; 110 | } 111 | const char *ename = enemies.enemy_name((KOBO_enemy_kinds)i); 112 | verify(ename, ".spawned", enemystats[i].spawned, 113 | enemies.stats[i].spawned); 114 | verify(ename, ".killed", enemystats[i].killed, 115 | enemies.stats[i].killed); 116 | verify(ename, ".health", enemystats[i].health, 117 | enemies.stats[i].health); 118 | verify(ename, ".damage", enemystats[i].damage, 119 | enemies.stats[i].damage); 120 | } 121 | return status; 122 | } 123 | 124 | 125 | bool KOBO_replay_gst::save(pfile_t *pf) 126 | { 127 | pf->chunk_write(KOBO_PF_GSTD_4CC, KOBO_PF_GSTD_VERSION); 128 | 129 | pf->write(frame); 130 | pf->write(score); 131 | pf->write(player.x); 132 | pf->write(player.y); 133 | pf->write(player.health); 134 | pf->write(player.charge); 135 | 136 | pf->write((uint32_t)KOBO_EK__COUNT); 137 | for(int i = 0; i < KOBO_EK__COUNT; ++i) 138 | { 139 | pf->write(enemystats[i].spawned); 140 | pf->write(enemystats[i].killed); 141 | pf->write(enemystats[i].health); 142 | pf->write(enemystats[i].damage); 143 | } 144 | 145 | pf->chunk_end(); 146 | return !pf->status(); 147 | } 148 | 149 | 150 | bool KOBO_replay_gst::load(pfile_t *pf) 151 | { 152 | if(pf->chunk_version() != KOBO_PF_GSTD_VERSION) 153 | return false; 154 | 155 | pf->read(frame); 156 | pf->read(score); 157 | pf->read(player.x); 158 | pf->read(player.y); 159 | pf->read(player.health); 160 | pf->read(player.charge); 161 | 162 | uint32_t ek; 163 | pf->read(ek); 164 | if(ek != KOBO_EK__COUNT) 165 | return false; 166 | 167 | for(int i = 0; i < KOBO_EK__COUNT; ++i) 168 | { 169 | pf->read(enemystats[i].spawned); 170 | pf->read(enemystats[i].killed); 171 | pf->read(enemystats[i].health); 172 | pf->read(enemystats[i].damage); 173 | } 174 | 175 | pf->chunk_end(); 176 | return !pf->status(); 177 | } 178 | -------------------------------------------------------------------------------- /src/replay_gst.h: -------------------------------------------------------------------------------- 1 | /*(GPLv2) 2 | ------------------------------------------------------------ 3 | Kobo Redux - Game state logging/verification 4 | ------------------------------------------------------------ 5 | * Copyright 2017 David Olofson 6 | * 7 | * This program is free software; you can redistribute it and/or modify it 8 | * under the terms of the GNU General Public License as published by the 9 | * Free Software Foundation; either version 2 of the License, or (at your 10 | * option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, but 13 | * WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General 15 | * Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License along 18 | * with this program; if not, write to the Free Software Foundation, Inc., 19 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 | */ 21 | 22 | #ifndef _KOBO_REPLAY_GST_H_ 23 | #define _KOBO_REPLAY_GST_H_ 24 | 25 | #include "pfile.h" 26 | #include "enemies.h" 27 | 28 | // Game state data (debug/test/verification) 29 | #define KOBO_PF_GSTD_4CC MAKE_4CC('G', 'S', 'T', 'D') 30 | #define KOBO_PF_GSTD_VERSION 2 31 | 32 | class KOBO_replay_gst 33 | { 34 | bool status; 35 | void verify(const char *desc, const char *desc2, 36 | uint32_t snap, uint32_t current); 37 | void verify(const char *desc, const char *desc2, 38 | int32_t snap, int32_t current); 39 | public: 40 | KOBO_replay_gst(); 41 | ~KOBO_replay_gst(); 42 | 43 | bool record(); 44 | bool verify(); 45 | 46 | bool save(pfile_t *pf); 47 | bool load(pfile_t *pf); 48 | 49 | KOBO_replay_gst *next; 50 | 51 | uint32_t frame; 52 | uint32_t score; 53 | struct { 54 | int32_t x, y; 55 | int16_t health; 56 | int16_t charge; 57 | } player; 58 | KOBO_enemystats enemystats[KOBO_EK__COUNT]; 59 | }; 60 | 61 | #endif /* _KOBO_REPLAY_GST_H_ */ 62 | -------------------------------------------------------------------------------- /src/savemanager.cpp: -------------------------------------------------------------------------------- 1 | /*(GPLv2) 2 | ------------------------------------------------------------ 3 | Kobo Redux - Save Manager 4 | ------------------------------------------------------------ 5 | * Copyright 2017 David Olofson 6 | * 7 | * This program is free software; you can redistribute it and/or modify it 8 | * under the terms of the GNU General Public License as published by the 9 | * Free Software Foundation; either version 2 of the License, or (at your 10 | * option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, but 13 | * WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General 15 | * Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License along 18 | * with this program; if not, write to the Free Software Foundation, Inc., 19 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 | */ 21 | 22 | #include "savemanager.h" 23 | #include "random.h" 24 | 25 | 26 | char *KOBO_campaign::construct_path(unsigned slot, const char *ext) 27 | { 28 | char buf[64]; 29 | snprintf(buf, sizeof(buf), "SAVES>>campaign_slot_%d.%s", slot, ext); 30 | return strdup(buf); 31 | } 32 | 33 | 34 | KOBO_save_manager::KOBO_save_manager() 35 | { 36 | for(int i = 0; i < KOBO_MAX_CAMPAIGN_SLOTS; ++i) 37 | { 38 | char dat[64]; 39 | char bak[64]; 40 | 41 | // Save slot 42 | snprintf(dat, sizeof(dat), "SAVES>>campaign_slot_%d.dat", i); 43 | snprintf(bak, sizeof(bak), "SAVES>>campaign_slot_%d.bak", i); 44 | slots[i].campaign = new KOBO_campaign(dat, bak); 45 | slots[i].cinfo = NULL; 46 | 47 | // Demo slot (read-only) 48 | snprintf(dat, sizeof(dat), "DEMOS>>demo_%d.dat", i); 49 | demos[i].campaign = new KOBO_campaign(dat, NULL); 50 | demos[i].cinfo = NULL; 51 | } 52 | } 53 | 54 | 55 | KOBO_save_manager::~KOBO_save_manager() 56 | { 57 | for(int i = 0; i < KOBO_MAX_CAMPAIGN_SLOTS; ++i) 58 | { 59 | if(slots[i].campaign) 60 | delete slots[i].campaign; 61 | if(slots[i].cinfo) 62 | delete slots[i].cinfo; 63 | if(demos[i].campaign) 64 | delete demos[i].campaign; 65 | if(demos[i].cinfo) 66 | delete demos[i].cinfo; 67 | } 68 | } 69 | 70 | 71 | bool KOBO_save_manager::exists(int slot) 72 | { 73 | if(slot < 0) 74 | { 75 | for(int i = 0; i < KOBO_MAX_CAMPAIGN_SLOTS; ++i) 76 | if(exists(i)) 77 | return true; 78 | return false; 79 | } 80 | if(slot >= KOBO_MAX_CAMPAIGN_SLOTS) 81 | return false; 82 | 83 | return slots[slot].campaign->exists() || 84 | !slots[slot].campaign->empty(); 85 | } 86 | 87 | 88 | bool KOBO_save_manager::demo_exists(int slot) 89 | { 90 | if(slot < 0) 91 | { 92 | for(int i = 0; i < KOBO_MAX_CAMPAIGN_SLOTS; ++i) 93 | if(demo_exists(i)) 94 | return true; 95 | return false; 96 | } 97 | if(slot >= KOBO_MAX_CAMPAIGN_SLOTS) 98 | return false; 99 | 100 | return demos[slot].campaign->exists() || 101 | !demos[slot].campaign->empty(); 102 | } 103 | 104 | 105 | bool KOBO_save_manager::load(int slot) 106 | { 107 | if(slot < 0) 108 | { 109 | bool loaded = false; 110 | for(int i = 0; i < KOBO_MAX_CAMPAIGN_SLOTS; ++i) 111 | if(load(i)) 112 | loaded = true; 113 | return loaded; 114 | } 115 | if(slot >= KOBO_MAX_CAMPAIGN_SLOTS) 116 | return false; 117 | 118 | if(slots[slot].cinfo) 119 | { 120 | delete slots[slot].cinfo; 121 | slots[slot].cinfo = NULL; 122 | } 123 | return slots[slot].campaign->load(); 124 | } 125 | 126 | 127 | void KOBO_save_manager::analyze() 128 | { 129 | for(int i = 0; i < KOBO_MAX_CAMPAIGN_SLOTS; ++i) 130 | { 131 | delete slots[i].cinfo; 132 | slots[i].cinfo = NULL; 133 | if(slots[i].campaign) 134 | slots[i].cinfo = slots[i].campaign->analyze(); 135 | 136 | delete demos[i].cinfo; 137 | demos[i].cinfo = NULL; 138 | if(demos[i].campaign) 139 | demos[i].cinfo = demos[i].campaign->analyze(); 140 | } 141 | } 142 | 143 | 144 | KOBO_campaign_info *KOBO_save_manager::analysis(KOBO_campaign *campaign) 145 | { 146 | for(int i = 0; i < KOBO_MAX_CAMPAIGN_SLOTS; ++i) 147 | if(slots[i].campaign == campaign) 148 | return slots[i].cinfo; 149 | else if(demos[i].campaign == campaign) 150 | return demos[i].cinfo; 151 | return NULL; 152 | } 153 | 154 | 155 | bool KOBO_save_manager::load_demos() 156 | { 157 | bool loaded = false; 158 | for(int i = 0; i < KOBO_MAX_CAMPAIGN_SLOTS; ++i) 159 | { 160 | if(demos[i].cinfo) 161 | { 162 | delete demos[i].cinfo; 163 | demos[i].cinfo = NULL; 164 | } 165 | if(demos[i].campaign->load()) 166 | { 167 | loaded = true; 168 | demos[i].cinfo = demos[i].campaign->analyze(); 169 | } 170 | } 171 | return loaded; 172 | } 173 | 174 | 175 | KOBO_campaign *KOBO_save_manager::campaign(unsigned slot) 176 | { 177 | if(slot >= KOBO_MAX_CAMPAIGN_SLOTS) 178 | return NULL; 179 | 180 | return slots[slot].campaign; 181 | } 182 | 183 | 184 | KOBO_campaign *KOBO_save_manager::demo(int slot) 185 | { 186 | if(slot < 0) 187 | { 188 | slot = pubrand.get() % KOBO_MAX_CAMPAIGN_SLOTS; 189 | for(int i = 0; i < KOBO_MAX_CAMPAIGN_SLOTS; ++i) 190 | { 191 | KOBO_campaign *k = demo((slot + i) % 192 | KOBO_MAX_CAMPAIGN_SLOTS); 193 | if(k && k->last_stage()) 194 | return k; 195 | } 196 | return NULL; 197 | } 198 | if(slot >= KOBO_MAX_CAMPAIGN_SLOTS) 199 | return NULL; 200 | 201 | return demos[slot].campaign; 202 | } 203 | 204 | 205 | bool KOBO_save_manager::save(unsigned slot) 206 | { 207 | if(slot >= KOBO_MAX_CAMPAIGN_SLOTS) 208 | return false; 209 | 210 | return slots[slot].campaign->save(); 211 | } 212 | 213 | 214 | void KOBO_save_manager::resave_all() 215 | { 216 | load(-1); 217 | for(int i = 0; i < KOBO_MAX_CAMPAIGN_SLOTS; ++i) 218 | if(!slots[i].campaign->empty()) 219 | slots[i].campaign->save(true); 220 | } 221 | -------------------------------------------------------------------------------- /src/savemanager.h: -------------------------------------------------------------------------------- 1 | /*(GPLv2) 2 | ------------------------------------------------------------ 3 | Kobo Redux - Save Manager 4 | ------------------------------------------------------------ 5 | * Copyright 2017 David Olofson 6 | * 7 | * This program is free software; you can redistribute it and/or modify it 8 | * under the terms of the GNU General Public License as published by the 9 | * Free Software Foundation; either version 2 of the License, or (at your 10 | * option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, but 13 | * WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General 15 | * Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License along 18 | * with this program; if not, write to the Free Software Foundation, Inc., 19 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 | */ 21 | 22 | #ifndef _KOBO_SAVEMANAGER_H_ 23 | #define _KOBO_SAVEMANAGER_H_ 24 | 25 | #include "config.h" 26 | #include "campaign.h" 27 | 28 | struct KOBO_save_slot 29 | { 30 | KOBO_campaign *campaign; 31 | KOBO_campaign_info *cinfo; 32 | }; 33 | 34 | class KOBO_save_manager 35 | { 36 | KOBO_save_slot slots[KOBO_MAX_CAMPAIGN_SLOTS]; 37 | KOBO_save_slot demos[KOBO_MAX_CAMPAIGN_SLOTS]; 38 | public: 39 | KOBO_save_manager(); 40 | virtual ~KOBO_save_manager(); 41 | 42 | // Load/analyze/save 43 | bool exists(int slot = -1); // File exists or there's recorded data 44 | bool load(int slot = -1); // (Re)load specified, or all 45 | KOBO_campaign *campaign(unsigned slot); 46 | bool save(unsigned slot); 47 | void resave_all(); 48 | 49 | // Demos 50 | bool load_demos(); 51 | KOBO_campaign *demo(int slot = -1); 52 | bool demo_exists(int slot = -1); 53 | 54 | // Campaign and demo analysis 55 | void analyze(); 56 | KOBO_campaign_info *analysis(KOBO_campaign *campaign); 57 | }; 58 | 59 | #endif // _KOBO_SAVEMANAGER_H_ 60 | -------------------------------------------------------------------------------- /src/scenes.h: -------------------------------------------------------------------------------- 1 | /*(GPLv2) 2 | * XKOBO, a video-oriented game 3 | * Copyright 1995, 1996 Akira Higuchi 4 | * a-higuti@math.hokudai.ac.jp 5 | * Copyright 2006, 2007, 2009 David Olofson 6 | * Copyright 2015-2017 David Olofson (Kobo Redux) 7 | * 8 | * This program is free software; you can redistribute it and/or modify it 9 | * under the terms of the GNU General Public License as published by the 10 | * Free Software Foundation; either version 2 of the License, or (at your 11 | * option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, but 14 | * WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General 16 | * Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License along 19 | * with this program; if not, write to the Free Software Foundation, Inc., 20 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 21 | */ 22 | 23 | #ifndef XKOBO_H_SCENES 24 | #define XKOBO_H_SCENES 25 | 26 | #include "config.h" 27 | #include "enemies.h" 28 | 29 | #define SCENE_ENEMY_MAX 20 30 | #define SCENE_BASE_MAX 40 31 | 32 | struct KOBO_enemy_set 33 | { 34 | const KOBO_enemy_kind *kind; 35 | int num; 36 | int speed; 37 | }; 38 | 39 | struct KOBO_base 40 | { 41 | int x, y, h, v; 42 | }; 43 | 44 | struct KOBO_scene 45 | { 46 | int ratio; 47 | int startx; 48 | int starty; 49 | const KOBO_enemy_kind *ek1; 50 | int ek1_interval; 51 | const KOBO_enemy_kind *ek2; 52 | int ek2_interval; 53 | int enemy_max; 54 | KOBO_enemy_set enemy[SCENE_ENEMY_MAX]; 55 | int base_max; 56 | KOBO_base base[SCENE_BASE_MAX]; 57 | }; 58 | 59 | class KOBO_scene_manager 60 | { 61 | int nscenes; 62 | const KOBO_scene *scenes; 63 | public: 64 | KOBO_scene_manager(); 65 | const KOBO_scene *get(int stage); 66 | int scene_count() { return nscenes; } 67 | int region(int stage) 68 | { 69 | return (stage - 1) / KOBO_LEVELS_PER_REGION % KOBO_REGIONS; 70 | } 71 | int level(int stage) 72 | { 73 | return (stage - 1) % KOBO_LEVELS_PER_REGION + 1; 74 | } 75 | }; 76 | 77 | extern KOBO_scene_manager scene_manager; 78 | 79 | #endif // XKOBO_H_SCENES 80 | -------------------------------------------------------------------------------- /src/screen.h: -------------------------------------------------------------------------------- 1 | /*(GPLv2) 2 | ------------------------------------------------------------ 3 | Kobo Deluxe - An enhanced SDL port of XKobo 4 | ------------------------------------------------------------ 5 | * Copyright 1995, 1996 Akira Higuchi 6 | * Copyright 2001-2003, 2007, 2009 David Olofson 7 | * Copyright 2015-2017 David Olofson (Kobo Redux) 8 | * 9 | * This program is free software; you can redistribute it and/or modify it 10 | * under the terms of the GNU General Public License as published by the 11 | * Free Software Foundation; either version 2 of the License, or (at your 12 | * option) any later version. 13 | * 14 | * This program is distributed in the hope that it will be useful, but 15 | * WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General 17 | * Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License along 20 | * with this program; if not, write to the Free Software Foundation, Inc., 21 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 22 | */ 23 | 24 | #ifndef _KOBO_SCREEN_H_ 25 | #define _KOBO_SCREEN_H_ 26 | 27 | #include "map.h" 28 | #include "radar.h" 29 | #include "starfield.h" 30 | #include "gridtfx.h" 31 | 32 | class window_t; 33 | 34 | class KOBO_screen 35 | { 36 | protected: 37 | static window_t *target; 38 | static int stage; 39 | static int region; 40 | static int level; 41 | static const KOBO_scene *scene; 42 | static int bg_altitude; 43 | static int bg_backdrop; 44 | static int bg_clouds; 45 | static int bg_planet; 46 | static int restarts; 47 | static int generate_count; 48 | static KOBO_map map[KOBO_BG_MAP_LEVELS + 1]; 49 | static int show_title; 50 | static int do_noise; 51 | static float _fps; 52 | static float scroller_speed; 53 | static float target_speed; 54 | static int noise_y; 55 | static int noise_h; 56 | static int noise_source; 57 | static float noise_fade; 58 | static float noise_bright; 59 | static float noise_depth; 60 | 61 | static float fade_level; 62 | static float fade_target; 63 | static Uint32 fade_time; 64 | 65 | static int highlight_y; 66 | static int highlight_h; 67 | static KOBO_ParticleFXDef highlight_fxd; 68 | static Uint32 highlight_time; 69 | 70 | static int hi_sc[10]; 71 | static int hi_st[10]; 72 | static char hi_nm[10][20]; 73 | static int long_credits_wrap; 74 | static KOBO_Starfield stars; 75 | 76 | static KOBO_GridTFX gridtfx; 77 | static bool curtains_below; 78 | 79 | static void render_noise(); 80 | static void render_highlight(); 81 | static void render_bases(KOBO_map &map, int tileset, int vx, int vy); 82 | static void clean_scrap_tile(int x, int y) 83 | { 84 | if((map[0].pos(x, y) & SPACE) && (MAP_TILE(map[0].pos(x, y)))) 85 | set_map(x, y, SPACE); 86 | } 87 | static void render_anim(int x, int y, int bank, int first, int last, 88 | float speed, int t); 89 | public: 90 | static void init_graphics(); 91 | static void init_background(); 92 | static void init_stage(int st, bool ingame); 93 | static int prepare(); 94 | static void generate_wave(const KOBO_enemy_set *wave); 95 | static void generate_fixed_enemies(); 96 | static inline int get_map(int x, int y) 97 | { 98 | return map[0].pos(x, y); 99 | } 100 | static inline int test_line(int x1, int y1, int x3, int y3, 101 | int *x2, int *y2, int *hx, int *hy) 102 | { 103 | return map[0].test_line(x1, y1, x3, y3, x2, y2, hx, hy); 104 | } 105 | static void set_map(int x, int y, int n); 106 | static void clean_scrap(int x, int y) 107 | { 108 | clean_scrap_tile(x + 1, y); 109 | clean_scrap_tile(x - 1, y); 110 | clean_scrap_tile(x, y + 1); 111 | clean_scrap_tile(x, y - 1); 112 | clean_scrap_tile(x, y); 113 | } 114 | static void set_highlight(int y, int h); 115 | static void set_highlight(); 116 | static void set_noise(int source, float fade, float bright, 117 | float depth); 118 | static void set_fade(float ft) { fade_target = ft; } 119 | static void render_background(); 120 | static void render_fx(); 121 | static void title(int t, float fade); 122 | static void credits(int t); 123 | static void long_credits(int t); 124 | static void help(int t); 125 | static void fps(float f); 126 | static float fps() { return _fps; } 127 | static void noise(int on); 128 | static void curtains(bool st, float dur = 1.0f, bool on_top = false); 129 | static bool curtains(); 130 | static void render_curtains(); 131 | static void render_countdown(int y, float t, int timeout, 132 | int countdown); 133 | }; 134 | 135 | extern KOBO_screen screen; 136 | 137 | #endif //_KOBO_SCREEN_H_ 138 | -------------------------------------------------------------------------------- /src/spinplanet.h: -------------------------------------------------------------------------------- 1 | /*(LGPLv2.1) 2 | ---------------------------------------------------------------------- 3 | spinplanet.h - Spinning planet effect 4 | ---------------------------------------------------------------------- 5 | * Copyright 2015-2017 David Olofson (Kobo Redux) 6 | * 7 | * This library is free software; you can redistribute it and/or modify it 8 | * under the terms of the GNU Lesser General Public License as published by 9 | * the Free Software Foundation; either version 2.1 of the License, or (at 10 | * your option) any later version. 11 | * 12 | * This library is distributed in the hope that it will be useful, but 13 | * WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser 15 | * General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public License 18 | * along with this library; if not, write to the Free Software Foundation, 19 | * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA 20 | */ 21 | 22 | #ifndef _SPINPLANET_H_ 23 | #define _SPINPLANET_H_ 24 | 25 | #include "window.h" 26 | #include "config.h" 27 | 28 | #define SPINPLANET_MAX_COLORS 16 29 | 30 | enum spinplanet_modes_t 31 | { 32 | SPINPLANET_OFF, 33 | SPINPLANET_BLACK, 34 | SPINPLANET_SPIN 35 | }; 36 | 37 | class spinplanet_t : public stream_window_t 38 | { 39 | int sbank, sframe; 40 | int tlayer; // Engine scroll layer to track 41 | int psize; // Actual planet size 42 | int msize; // World map size 43 | int msizemask; // Mask for msize wrapping 44 | float texrep; // Texture repeat factor 45 | 46 | // Tracking wrap handling 47 | float xspeed, yspeed; // Tracking speed scaling factors 48 | float trackox, trackoy; // Tracking offset 49 | float lastnx, lastny; // Last normalized offsets 50 | float wox, woy; // Wrap offsets 51 | 52 | unsigned ditherstate; // Dither state 53 | int dither_brightness; 54 | int dither_contrast; 55 | Uint32 colors[SPINPLANET_MAX_COLORS + 1]; // Dither palette 56 | int lastx, lasty; // Last rendered map position 57 | 58 | bool needs_prepare; 59 | 60 | // Lens encoding: 61 | // [i + 0]: target X (pixels) 62 | // [i + 1]: target Y (pixels) 63 | // [i + 2]: length (pixels; 0: end of data) 64 | // [i + 3 + n]: source X offset (12:4) 65 | // [i + 3 + n + 1]: source Y offset (12:4) 66 | int16_t *lens; 67 | 68 | // Source texture; either 32 bpp xRGB or 8 bpp grayscale 69 | void *source; // uint8_t grayscale, or uint32_t xRGB 70 | int sourcepitch; // Pixels 71 | bool free_source; 72 | 73 | spinplanet_modes_t mode; 74 | gfx_dither_t dither; 75 | 76 | void set_msize(int size); 77 | void init_lens(); 78 | uint8_t *grayscale_convert(uint32_t *src, int sp, int w, int h, 79 | int brightness, int contrast); 80 | uint32_t *palette_remap(uint8_t *src, int sp, int w, int h, 81 | uint32_t *palette, int palettesize); 82 | uint8_t *downscale_8bpp(uint8_t *src, int sp, int w, int h, int n); 83 | uint32_t *downscale_32bpp(uint32_t *src, int sp, int w, int h, int n); 84 | void scale_texture(); 85 | void dth_prepare(); 86 | 87 | inline int noise() 88 | { 89 | ditherstate *= 1566083941UL; 90 | ditherstate++; 91 | return (int)(ditherstate * (ditherstate >> 16) >> 16); 92 | } 93 | inline void dth_raw(uint32_t *s, int sp, Uint32 *d, 94 | int16_t *l, int len, int x, int y, int vx, int vy); 95 | inline void dth_random(uint8_t *s, int sp, Uint32 *d, 96 | int16_t *l, int len, int x, int y, int vx, int vy); 97 | inline void dth_2x2(uint8_t *s, int sp, Uint32 *d, 98 | int16_t *l, int len, int x, int y, int vx, int vy); 99 | inline void dth_ordered(uint8_t *s, int sp, Uint32 *d, 100 | int16_t *l, int len, int x, int y, int vx, int vy); 101 | public: 102 | spinplanet_t(gfxengine_t *e); 103 | virtual ~spinplanet_t(); 104 | void clear(); 105 | void set_source(int bank, int frame); 106 | void set_palette(unsigned pal); 107 | void set_size(int size) { psize = size; } 108 | void set_mode(spinplanet_modes_t md); 109 | void set_dither(gfx_dither_t dth, int brightness, int contrast); 110 | void set_texture_repeat(int txr) { texrep = txr; } 111 | void track_layer(int lr) { tlayer = lr; } 112 | void track_speed(float _xspeed, float _yspeed) 113 | { 114 | xspeed = _xspeed; 115 | yspeed = _yspeed; 116 | } 117 | void track_offset(float tox, float toy) 118 | { 119 | trackox = tox; 120 | trackoy = toy; 121 | } 122 | void refresh(SDL_Rect *r); 123 | void render(SDL_Rect *r); 124 | }; 125 | 126 | #endif // _SPINPLANET_H_ 127 | -------------------------------------------------------------------------------- /src/starfield.cpp: -------------------------------------------------------------------------------- 1 | /*(GPLv2) 2 | ------------------------------------------------------------ 3 | Kobo Deluxe - An enhanced SDL port of XKobo 4 | ------------------------------------------------------------ 5 | * Copyright 2015-2017 David Olofson (Kobo Redux) 6 | * 7 | * This program is free software; you can redistribute it and/or modify it 8 | * under the terms of the GNU General Public License as published by the 9 | * Free Software Foundation; either version 2 of the License, or (at your 10 | * option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, but 13 | * WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General 15 | * Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License along 18 | * with this program; if not, write to the Free Software Foundation, Inc., 19 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 | */ 21 | 22 | #include "starfield.h" 23 | #include "gfxengine.h" 24 | #include "random.h" 25 | #include "config.h" 26 | 27 | 28 | KOBO_Starfield::KOBO_Starfield() 29 | { 30 | target = NULL; 31 | nstars = 0; 32 | stars = NULL; 33 | oxo = 0; 34 | oyo = 0; 35 | } 36 | 37 | 38 | KOBO_Starfield::~KOBO_Starfield() 39 | { 40 | free(stars); 41 | } 42 | 43 | 44 | void KOBO_Starfield::init_colors(unsigned pal) 45 | { 46 | ncolors = target->get_engine()->palette_size(pal); 47 | if(ncolors > MAX_STAR_COLORS) 48 | ncolors = MAX_STAR_COLORS; 49 | for(unsigned i = 0; i < ncolors; ++i) 50 | colors[ncolors - i - 1] = target->map_rgb( 51 | target->get_engine()->palette(pal, i)); 52 | } 53 | 54 | 55 | void KOBO_Starfield::set_target(window_t *_target, unsigned pal) 56 | { 57 | target = _target; 58 | init_colors(pal); 59 | } 60 | 61 | 62 | bool KOBO_Starfield::init(int _nstars, int _altitude, int _planetsize, 63 | bool distant_only) 64 | { 65 | altitude = _altitude; 66 | planetsize = _planetsize; 67 | if(distant_only) 68 | { 69 | planetscale = altitude / 2; 70 | pivot = 0; 71 | } 72 | else 73 | { 74 | if(altitude < 64) 75 | planetscale = 512; 76 | else if(altitude > 192) 77 | planetscale = 256; 78 | else 79 | planetscale = 512 - ((altitude - 64) << 1); 80 | pivot = altitude; 81 | } 82 | if(_nstars != nstars) 83 | { 84 | free(stars); 85 | nstars = _nstars; 86 | stars = (KOBO_Star *)malloc(nstars * sizeof(KOBO_Star)); 87 | if(!stars) 88 | { 89 | nstars = 0; 90 | return false; // Out of memory!!! 91 | } 92 | } 93 | for(int i = 0; i < nstars; ++i) 94 | { 95 | stars[i].x = pubrand.get(); 96 | stars[i].y = pubrand.get(); 97 | int zz = 255 * i / nstars; 98 | stars[i].z = 65025 - zz * zz; 99 | } 100 | return true; 101 | } 102 | 103 | 104 | void KOBO_Starfield::render(int xo, int yo) 105 | { 106 | int w = target->width() * 256; 107 | int h = target->height() * 256; 108 | if(!w || !h) 109 | return; 110 | 111 | int xc = w / 2; 112 | int yc = h / 2; 113 | int pivot8 = pivot << 8; // Rotation pivot z coordinate 114 | int pclip = planetsize * planetsize / 4; // Planet radius squared 115 | 116 | // Calculate delta from last position, dealing with map position wrap 117 | const int WSX = WORLD_SIZEX << 8; 118 | const int WSY = WORLD_SIZEY << 8; 119 | int dx = (xo - oxo) & (WSX - 1); 120 | oxo = xo; 121 | if(dx & (WSX >> 1)) 122 | dx |= 1 - (WSX - 1); 123 | int dy = (yo - oyo) & (WSY - 1); 124 | oyo = yo; 125 | if(dy & (WSY >> 1)) 126 | dy |= 1 - (WSY - 1); 127 | 128 | // Scale the deltas to compensate for window/starfield size mismatch 129 | // (Otherwise stars at zero distance won't sync up with the map as 130 | // intended!) 131 | dx = (dx << 16) / w; 132 | dy = (dy << 16) / h; 133 | 134 | target->select(); 135 | for(int i = 0; i < nstars; ++i) 136 | { 137 | int iz = (int)stars[i].z; 138 | int z = (iz - pivot8) * planetscale >> 8; 139 | 140 | // Move star! 141 | stars[i].x += dx * z >> 16; 142 | stars[i].y += dy * z >> 16; 143 | 144 | // Scale to fixp "native" display coordinates 145 | int x = stars[i].x * (w >> 8) >> 8; 146 | int y = stars[i].y * (h >> 8) >> 8; 147 | 148 | // Skip stars occluded by the planet 149 | int xi = x >> 8; 150 | int yi = y >> 8; 151 | if((z > 0) && ((xi * xi + yi * yi) < pclip)) 152 | continue; 153 | 154 | // Center 155 | x += xc; 156 | y += yc; 157 | 158 | // Plot! 159 | target->foreground(colors[iz * ncolors >> 16]); 160 | target->fillrect_fxp(x, y, 256, 256); 161 | } 162 | } 163 | -------------------------------------------------------------------------------- /src/starfield.h: -------------------------------------------------------------------------------- 1 | /*(GPLv2) 2 | ------------------------------------------------------------ 3 | Kobo Deluxe - An enhanced SDL port of XKobo 4 | ------------------------------------------------------------ 5 | * Copyright 2015-2016 David Olofson (Kobo Redux) 6 | * 7 | * This program is free software; you can redistribute it and/or modify it 8 | * under the terms of the GNU General Public License as published by the 9 | * Free Software Foundation; either version 2 of the License, or (at your 10 | * option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, but 13 | * WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General 15 | * Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License along 18 | * with this program; if not, write to the Free Software Foundation, Inc., 19 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 | */ 21 | 22 | /*----------------------------------------------------------------------------- 23 | 24 | This starfield implementation may seem a bit backwards. Instead of moving 25 | around in a 3D point cloud, projecting by dividing x and y by z etc, we're 26 | doing a plain orthogonal projection. That is, the z coordinates have no direct 27 | impact on rendering! 28 | 29 | What actually creates the parallax effect is that we scroll the *stars* around 30 | at different speeds, depending on their distance from the screen, which 31 | effectively replaces the usual (x/z, y/z) operation when projecting. 32 | 33 | The interesting part is that stars wrap around the edges automatically as a 34 | side effect of the integer arithmetics. Thus we can have a nice, dense "3D" 35 | starfield covering the whole window - no nearby stars way off screen, and no 36 | distant stars wrapping around in a small square in the middle of the screen. No 37 | clipping is needed, and thus, no cycles are wasted animating off-screen stars. 38 | 39 | Of course, this design means we cannot move along the Z axis (well, not 40 | trivially, at least), but we don't really need that here anyway. 41 | 42 | -----------------------------------------------------------------------------*/ 43 | 44 | #ifndef KOBO_STARFIELD_H 45 | #define KOBO_STARFIELD_H 46 | 47 | #include "window.h" 48 | 49 | #define MAX_STAR_COLORS 256 50 | 51 | struct KOBO_Star 52 | { 53 | short x; 54 | short y; 55 | unsigned short z; 56 | }; 57 | 58 | class KOBO_Starfield 59 | { 60 | window_t *target; 61 | int altitude; 62 | int planetsize; 63 | int planetscale; 64 | int pivot; 65 | int nstars; 66 | KOBO_Star *stars; 67 | unsigned ncolors; 68 | Uint32 colors[MAX_STAR_COLORS]; 69 | int oxo, oyo; 70 | void init_colors(unsigned pal); 71 | public: 72 | KOBO_Starfield(); 73 | ~KOBO_Starfield(); 74 | void set_target(window_t *_target, unsigned pal); 75 | bool init(int _nstars, int _altitude, int _planetsize, 76 | bool distant_only = false); 77 | void render(int xo, int yo); 78 | }; 79 | 80 | #endif /* KOBO_STARFIELD_H */ 81 | --------------------------------------------------------------------------------