From 80a5ffad6e6a2e0bb8faab202e101feee9061a06 Mon Sep 17 00:00:00 2001 From: Ekaitz Zarraga Date: Thu, 11 Aug 2022 22:52:30 +0200 Subject: WIP: Add some gameboy tooling --- gb.scm | 172 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 172 insertions(+) create mode 100644 gb.scm (limited to 'gb.scm') diff --git a/gb.scm b/gb.scm new file mode 100644 index 0000000..2d4ac2b --- /dev/null +++ b/gb.scm @@ -0,0 +1,172 @@ +(define-module (gb) + #:use-module (electronics) + #:use-module (guix packages) + #:use-module (guix gexp) + #:use-module (gnu packages) + #:use-module (gnu packages autotools) + #:use-module (gnu packages bison) + #:use-module (gnu packages boost) + #:use-module (gnu packages compression) + #:use-module (gnu packages embedded) + #:use-module (gnu packages flex) + #:use-module (gnu packages python) + #:use-module (gnu packages texinfo) + #:use-module (guix git-download) + #:use-module (guix svn-download) + #:use-module (guix build-system gnu) + #:use-module (guix build-system trivial) + #:use-module ((guix licenses) #:prefix license:)) + + + +(define-public sdcc-patched-for-gbdk + (let ((revision 12539)) + (package + (name "sdcc-patched-for-gbdk") + ; It's not that base version, probably 2.96, but IDK how to check that in + ; subversion + (version (string-append "0.0.1" "-" (number->string revision))) + (source (origin + (method svn-fetch) + (uri (svn-reference + (url "https://svn.code.sf.net/p/sdcc/code/trunk/sdcc") + (revision revision))) + (file-name (string-append name "-" version)) + (modules '((guix build utils))) + (snippet + '(begin + ;; Remove non-free source files + (delete-file-recursively "device/non-free") + ;; Remove bundled μCsim source + (delete-file-recursively "sim") + #t)) + (patches + (search-patches + "sdcc-non-free.patch" + "sdcc-makebin-nogogo-v2-bool.patch" + "sdcc-sdas_macro_80_char_overflow.patch" + "sdcc-sdcc_z80_boN_baN.patch" + "sdcc-sdcc_z80_enable_incbin.patch" + "sdcc-sdldz80-sms-virtual-address.patch")) + (sha256 + (base32 + "148zpyxwac8qlbg1pakjmar8h802g6lwjp4qhw6cy77ixlhwgyrg")))) + (build-system gnu-build-system) + (native-inputs (list bison boost flex zlib python-2 texinfo)) + (arguments + `(#:configure-flags + (list "--disable-nonfree" "--disable-pic14-port" + "--disable-pic16-port" "--disable-ucsim") + #:phases + (modify-phases %standard-phases + (add-after 'unpack 'patch-makefile + (lambda _ + (substitute* (find-files "." "(\\.mk$|\\.in$)") + (("/bin/sh") (which "sh"))) + #t))))) + (home-page "http://sdcc.sourceforge.net") + (synopsis "Small devices C compiler") + (description "Patched SDCC for GameBoy development") + (license license:gpl2+)))) + +;; MAYBE USE THIS INSTEAD? +;; https://github.com/flozz/gbdk-n/ +;; It needs a really old sdcc, the patched one works. +;; Maybe we can give it a revival +;; +(define-public gbdk-2020 + ;; This does not build, it fails to generate files... + ;; Also the sdcc it uses (see above) is very old. The docs specifically + ;; mention this one but it's pretty old. They might be using other one + ;; instead. + (package + (name "gbdk-2020") + (version "4.0.5") + (source (origin + (method git-fetch) + (uri (git-reference + (url "https://github.com/gbdk-2020/gbdk-2020") + (commit version))) + (sha256 + (base32 "009361b9b7215s1095q58gdwqc3wwymcr6vknjq218fs0l3nlnjf")))) + (native-inputs (list sdcc-patched-for-gbdk)) + (arguments + (list #:phases + #~(modify-phases %standard-phases + (delete 'configure) + (add-before 'build 'setenv + (lambda _ (setenv "SDCCDIR" #$sdcc-patched-for-gbdk)))))) + (build-system gnu-build-system) + (home-page "https://github.com/gbdk-2020/gbdk-2020") + (synopsis "blahblah") + (description "blablah") + (license license:gpl2))) + + +(define-public gba-tools + (package + (name "gba-tools") + (version "1.2.0") + (source (origin + (method git-fetch) + (uri (git-reference + (url "https://github.com/devkitPro/gba-tools") + (commit (string-append "v" version)))) + (sha256 + (base32 + "1rlhyc9dsdxcmaih3x9qjb3ihr2xxz1rw42ijbz2ylymn9p133gh")))) + (build-system gnu-build-system) + (inputs (list automake autoconf)) + (synopsis "Collection of tools for Game Boy Advance development") + (description "Collection of tools for Game Boy Advance development: +- gbafix: Pads and patches GBA ROMs. +- gbalzss: Compresses and uncompresses ROMs. +- gbfs: Creates a GBFS archive. +- insgbfs: Inserts a GBFS file (or any other file) into a GBFS_SPACE + (identified by symbol name) in a ROM. +- lsgbfs: Lists objects in a GBFS file. +- ungbfs: Dumps the objects in a GBFS file to separate files.") + (home-page "https://github.com/devkitPro/gba-tools") + (license license:gpl3+))) + +#;(define-public gba-minrt + (package + (name "gba-minrt") + (version "0.0.0") ; Obtain from commit-id + )) + +(define-public libseven + (package + (name "libseven") + (version "0.3.5") + (source (origin + (method git-fetch) + (uri (git-reference + (url "https://github.com/LunarLambda/libseven") + (commit (string-append "v" version)))) + (sha256 + (base32 + "1jbkghqjjyjjq4rs8ifzlq7zhrcifnis1b8fwiajv8ga2x0s9qr9")))) + (arguments + (list + #:phases + `(modify-phases %standard-phases + (delete 'configure) + (add-before 'build 'setenv + (lambda* _ + (setenv "DESTDIR" "output"))) + (add-after 'install 'correct-output-dir + (lambda* (#:key inputs outputs #:allow-other-keys) + (copy-recursively "output/libseven" (assoc-ref outputs "out"))))) + #:tests? #f)) + (build-system gnu-build-system) + (inputs (list arm-none-eabi-nano-toolchain-7-2018-q2-update)) + (synopsis "A fully from-scratch library for GBA development, meant to +replace existing libraries like libgba or libtonc.") + (description "Goals: + - Intuitive, consistent, and well organized API + - Optimized code with minimal RAM and ROM size + - Correctness without compromises + - High-quality, understandable documentation") + (home-page "https://github.com/LunarLambda/libseven") + (license license:mpl2.0))) -- cgit v1.2.3