From 64da1f5d6bf96ff7f35165476ecc8d623f76060d Mon Sep 17 00:00:00 2001 From: Rangi Date: Fri, 3 Jul 2020 17:32:21 -0400 Subject: Move graphics-only object file sources into gfx/ Previously this wasn't working, but now the Makefile uses pokegold's technique for running scan_includes. It also enables and fixes some rgbds warnings ("Non-local labels without a colon are deprecated"). --- Makefile | 45 ++++++++++++++++++++++++++++++--------------- 1 file changed, 30 insertions(+), 15 deletions(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index 9475c377..684d665e 100644 --- a/Makefile +++ b/Makefile @@ -5,11 +5,11 @@ audio.o \ home.o \ main.o \ maps.o \ -pics.o \ -sprites.o \ text.o \ -tilesets.o \ wram.o \ +gfx/pics.o \ +gfx/sprites.o \ +gfx/tilesets.o pokered_obj := $(rom_obj:.o=_red.o) pokeblue_obj := $(rom_obj:.o=_blue.o) @@ -35,7 +35,7 @@ RGBLINK ?= $(RGBDS)rgblink .PHONY: all red blue clean tidy compare tools all: $(roms) -red: pokered.gbc +red: pokered.gbc blue: pokeblue.gbc # For contributors to make sure a change didn't affect the contents of the rom. @@ -44,7 +44,7 @@ compare: $(roms) clean: rm -f $(roms) $(pokered_obj) $(pokeblue_obj) $(roms:.gbc=.map) $(roms:.gbc=.sym) - find . \( -iname '*.1bpp' -o -iname '*.2bpp' -o -iname '*.pic' \) -exec rm {} + + find gfx \( -iname '*.1bpp' -o -iname '*.2bpp' -o -iname '*.pic' \) -delete $(MAKE) clean -C tools/ tidy: @@ -55,28 +55,43 @@ tools: $(MAKE) -C tools/ +RGBASMFLAGS = -h -Weverything +# Create a sym/map for debug purposes if `make` run with `DEBUG=1` +ifeq ($(DEBUG),1) +RGBASMFLAGS += -E +endif + +$(pokered_obj): RGBASMFLAGS += -D _RED +$(pokeblue_obj): RGBASMFLAGS += -D _BLUE + +# The dep rules have to be explicit or else missing files won't be reported. +# As a side effect, they're evaluated immediately instead of when the rule is invoked. +# It doesn't look like $(shell) can be deferred so there might not be a better way. +define DEP +$1: $2 $$(shell tools/scan_includes $2) + $$(RGBASM) $$(RGBASMFLAGS) -o $$@ $$< +endef + # Build tools when building the rom. # This has to happen before the rules are processed, since that's when scan_includes is run. ifeq (,$(filter clean tools,$(MAKECMDGOALS))) + $(info $(shell $(MAKE) -C tools)) -endif +# Dependencies for objects (drop _red and _blue from asm file basenames) +$(foreach obj, $(pokered_obj), $(eval $(call DEP,$(obj),$(obj:_red.o=.asm)))) +$(foreach obj, $(pokeblue_obj), $(eval $(call DEP,$(obj),$(obj:_blue.o=.asm)))) -%.asm: ; +endif -%_red.o: dep = $(shell tools/scan_includes $(@D)/$*.asm) -$(pokered_obj): %_red.o: %.asm $$(dep) - $(RGBASM) -D _RED -h -o $@ $*.asm -%_blue.o: dep = $(shell tools/scan_includes $(@D)/$*.asm) -$(pokeblue_obj): %_blue.o: %.asm $$(dep) - $(RGBASM) -D _BLUE -h -o $@ $*.asm +%.asm: ; pokered_opt = -jsv -k 01 -l 0x33 -m 0x13 -p 0 -r 03 -t "POKEMON RED" pokeblue_opt = -jsv -k 01 -l 0x33 -m 0x13 -p 0 -r 03 -t "POKEMON BLUE" -%.gbc: $$(%_obj) - $(RGBLINK) -d -m $*.map -n $*.sym -l layout.link -o $@ $^ +%.gbc: $$(%_obj) layout.link + $(RGBLINK) -d -m $*.map -n $*.sym -l layout.link -o $@ $(filter %.o,$^) $(RGBFIX) $($*_opt) $@ -- cgit v1.3.1-sl0p From 73be62fad6007b1a84675153634aaf57676455ac Mon Sep 17 00:00:00 2001 From: Rangi Date: Sat, 4 Jul 2020 01:03:25 -0400 Subject: Verify that rgbds is at least verson 0.4.0 Adapt the INSTALL guide from pokecrystal. --- INSTALL.md | 184 +++++++++++++++++++++++++++++++++++++++++++++++---------- Makefile | 17 +++--- rgbdscheck.asm | 12 ++++ 3 files changed, 174 insertions(+), 39 deletions(-) create mode 100644 rgbdscheck.asm (limited to 'Makefile') diff --git a/INSTALL.md b/INSTALL.md index c708a013..48b0fa7c 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -1,60 +1,180 @@ -# Linux +# Instructions - sudo apt-get install make git gcc +These instructions explain how to set up the tools required to build **pokered**, including [**rgbds**](https://github.com/rednex/rgbds), which assembles the source files into a ROM. - sudo apt-get install byacc flex pkg-config libpng-dev - git clone https://github.com/rednex/rgbds - cd rgbds - sudo make install - cd .. +If you run into trouble, ask for help on IRC or Discord (see [README.md](README.md)). - git clone https://github.com/pret/pokered - cd pokered -To build **pokered.gbc** and **pokeblue.gbc**: +## Windows 10 - make +Download and install [**Windows Subsystem for Linux**](https://docs.microsoft.com/en-us/windows/wsl/install-win10). Then open the **WSL terminal**. -To build them individually: +WSL has its own file system that's not accessible from Windows, but Windows files *are* accessible from WSL. So you're going to want to install pokered within Windows. You'll have to change the **current working directory** every time you open WSL. - make red - make blue +For example, if you want to store pokered in **C:\Users\\*\*\Desktop**, enter this command: +```bash +cd /mnt/c/Users//Desktop +``` -# Mac +(The Windows `C:\` drive is called `/mnt/c/` in WSL. Replace *\* in the example path with your username.) -Get [**Homebrew**](http://brew.sh/). +Then follow [the instructions for **Linux**](#linux). -Then in **Terminal**, run: +If this doesn't work, try following [the regular Windows instructions](#windows) below. - xcode-select --install - brew install rgbds - git clone https://github.com/pret/pokered - cd pokered +## Windows -To build **pokered.gbc** and **pokeblue.gbc**: +Download [**Cygwin**](http://cygwin.com/install.html): **setup-x86_64.exe** for 64-bit Windows, **setup-x86.exe** for 32-bit. - make +Run setup and leave the default settings. At the "**Select Packages**" step, choose to install the following, all of which are in the "**Devel**" category: +- `make` +- `git` +- `gcc-core` -# Windows +Double click on the text that says "**Skip**" next to each package to select the most recent version to install. -Download [**Cygwin**](http://cygwin.com/install.html): **setup-x86_64.exe** for 64-bit Windows, **setup-x86.exe** for 32-bit. +Then download [**rgbds**](https://github.com/rednex/rgbds/releases/): the latest **win64.zip** or **win32.zip** release. Extract it and put all the `exe` and `dll` files individually in **C:\cygwin64\usr\local\bin**. + +**Note: If you already have an older rgbds, you will need to update to 0.4.0.** Ignore this if you have never installed rgbds before. If a version newer than 0.4.0 does not work, try downloading 0.4.0. + +Now open the **Cygwin terminal** and enter the following commands. + +Cygwin has its own file system that's within Windows, at **C:\cygwin64\home\\*\***. If you don't want to store pokered there, you'll have to change the **current working directory** every time you open Cygwin. + +For example, if you want to store pokered in **C:\Users\\*\*\Desktop**: + +```bash +cd /cygdrive/c/Users//Desktop +``` + +(The Windows `C:\` drive is called `/cygdrive/c/` in Cygwin. Replace *\* in the example path with your username.) + +Now you're ready to [build **pokered**](#build-pokered). + + +## Mac OS X + +Install [**Homebrew**](https://brew.sh/). Follow the official instructions. + +Open **Terminal** and enter the following commands. + +To install **rgbds**: + +```bash +brew install rgbds +``` + +Now you're ready to [build **pokered**](#build-pokered). + + +## Linux + +Open **Terminal** and enter the following commands, depending on which distro you're using. + +### Debian or Ubuntu + +To install the software required for **pokered**: + +```bash +sudo apt-get install make gcc git +``` -Run setup and leave the default settings. At "Select Packages", choose to install the following: +To install **rgbds**: + +```bash +sudo apt-get install pkg-config flex bison libpng-dev +git clone -b v0.4.0 --depth=1 https://github.com/rednex/rgbds +sudo make -C rgbds install +``` + +### OpenSUSE + +To install the software required for **pokered**: + +```bash +sudo zypper install make gcc git +``` + +To install **rgbds**: + +```bash +sudo zypper install pkg-config flex bison libpng16-devel +git clone -b v0.4.0 --depth=1 https://github.com/rednex/rgbds +sudo make -C rgbds install +``` + +### Arch Linux + +To install the software required for **pokered**: + +```bash +sudo pacman -S make gcc git +``` + +**rgbds** is available on the [AUR](https://aur.archlinux.org/packages/rgbds/). + +Alternatively, to install **rgbds** manually: + +```bash +sudo pacman -S pkg-config flex bison libpng +git clone -b v0.4.0 --depth=1 https://github.com/rednex/rgbds +sudo make -C rgbds install +``` + +### Termux + +To install the software required for **pokered**: + +```bash +sudo apt install make clang git sed +``` + +To install **rgbds**: + +```bash +sudo apt install rgbds +``` + +### Other distros + +If your distro is not listed here, try to find the required software in its repositories: - `make` +- `gcc` (or `clang`) - `git` -- `gcc-core` +- `rgbds` + +If `rgbds` is not available, you'll also need these: + +- `pkg-config` +- `flex` +- `bison` +- `libpng` (and the development headers) + +To install **rgbds**: + +```bash +git clone -b v0.4.0 --depth=1 https://github.com/rednex/rgbds +sudo make -C rgbds install +``` + +Now you're ready to [build **pokered**](#build-pokered). + -Then download [**rgbds**](https://github.com/rednex/rgbds/releases/): the latest **win64.tar.gz** or **win32.tar.gz** release. Extract it and put all the `exe` and `dll` files individually in **C:\cygwin64\usr\local\bin**. +## Build pokered -In the **Cygwin terminal**, enter these commands: +To download the **pokered** source files: - git clone https://github.com/pret/pokered - cd pokered +```bash +git clone https://github.com/pret/pokered +cd pokered +``` To build **pokered.gbc** and **pokeblue.gbc**: - make +```bash +make +``` diff --git a/Makefile b/Makefile index 684d665e..3e2a6e89 100644 --- a/Makefile +++ b/Makefile @@ -38,19 +38,19 @@ all: $(roms) red: pokered.gbc blue: pokeblue.gbc -# For contributors to make sure a change didn't affect the contents of the rom. -compare: $(roms) - @$(MD5) roms.md5 - clean: - rm -f $(roms) $(pokered_obj) $(pokeblue_obj) $(roms:.gbc=.map) $(roms:.gbc=.sym) + rm -f $(roms) $(pokered_obj) $(pokeblue_obj) $(roms:.gbc=.map) $(roms:.gbc=.sym) rgbdscheck.o find gfx \( -iname '*.1bpp' -o -iname '*.2bpp' -o -iname '*.pic' \) -delete $(MAKE) clean -C tools/ tidy: - rm -f $(roms) $(pokered_obj) $(pokeblue_obj) $(roms:.gbc=.map) $(roms:.gbc=.sym) + rm -f $(roms) $(pokered_obj) $(pokeblue_obj) $(roms:.gbc=.map) $(roms:.gbc=.sym) rgbdscheck.o $(MAKE) clean -C tools/ +# For contributors to make sure a change didn't affect the original contents of the ROMs. +compare: $(roms) + @$(MD5) roms.md5 + tools: $(MAKE) -C tools/ @@ -64,11 +64,14 @@ endif $(pokered_obj): RGBASMFLAGS += -D _RED $(pokeblue_obj): RGBASMFLAGS += -D _BLUE +rgbdscheck.o: rgbdscheck.asm + $(RGBASM) -o $@ $< + # The dep rules have to be explicit or else missing files won't be reported. # As a side effect, they're evaluated immediately instead of when the rule is invoked. # It doesn't look like $(shell) can be deferred so there might not be a better way. define DEP -$1: $2 $$(shell tools/scan_includes $2) +$1: $2 $$(shell tools/scan_includes $2) | rgbdscheck.o $$(RGBASM) $$(RGBASMFLAGS) -o $$@ $$< endef diff --git a/rgbdscheck.asm b/rgbdscheck.asm new file mode 100644 index 00000000..d10f8d50 --- /dev/null +++ b/rgbdscheck.asm @@ -0,0 +1,12 @@ +; pokered requires rgbds 0.4.0 or newer. +MAJOR EQU 0 +MINOR EQU 4 +PATCH EQU 0 + +if !DEF(__RGBDS_MAJOR__) || !DEF(__RGBDS_MINOR__) || !DEF(__RGBDS_PATCH__) + fail "pokered requires rgbds {MAJOR}.{MINOR}.{PATCH} or newer." +elif (__RGBDS_MAJOR__ < MAJOR) || \ + (__RGBDS_MAJOR__ == MAJOR && __RGBDS_MINOR__ < MINOR) || \ + (__RGBDS_MAJOR__ == MAJOR && __RGBDS_MINOR__ == MINOR && __RGBDS_PATCH__ < PATCH) + fail "pokered requires rgbds {MAJOR}.{MINOR}.{PATCH} or newer." +endc -- cgit v1.3.1-sl0p