diff --git a/Makefile b/Makefile index 7b02406..60a39e5 100644 --- a/Makefile +++ b/Makefile @@ -1,17 +1,27 @@ # Updates content of SD directory. # +# SPDX-FileCopyrightText: 2021 Ivan Tatarinov +# +# SPDX-License-Identifier: GPL-3.0-or-later +# # Supported environments: # * GNU on Linux, FreeBSD etc. # * GNU on Windows NT (using MinGW/MSYS/Cygwin/WSL) # -# Build: -# make +# Build the project: +# make [all] +# Compile only: +# make build | build- +# Install: +# make install | install- +# Uninstall: +# make uninstall | uninstall- # Clean: -# make clean +# make clean | clean- +# make distclean | distclean- # -# SPDX-FileCopyrightText: 2021 Ivan Tatarinov -# -# SPDX-License-Identifier: GPL-3.0-or-later +# where: +# is one of the values for `TARGETS' variable. include sdk/common.mk @@ -20,65 +30,75 @@ prefix ?= SD exec_prefix ?= $(prefix) bindir ?= $(exec_prefix)/BIN -INSTALL ?= install -INSTALL_PROGRAM ?= $(INSTALL) -RM = rm -f +TARGETS=\ + utils\ + software -SOFTWARE_TARGETS=\ - ESPRST\ - IWCONFIG +SOFTWARE_SUBDIRS=\ + esprst\ + iwconfig .PHONY: all -all:\ - install-utils\ - install-software +all: $(foreach t,$(TARGETS),install-$(t)) @echo 'Done.' # utils +.PHONY: build-utils +build-utils: | utils + $(MAKE) -w -C $| bindir=$(shell realpath --relative-to=$| $(bindir)) + .PHONY: install-utils install-utils: | utils $(MAKE) -w -C $| bindir=$(shell realpath --relative-to=$| $(bindir)) install +.PHONY: uninstall-utils +uninstall-utils: | utils + $(MAKE) -w -C $| bindir=$(shell realpath --relative-to=$| $(bindir)) uninstall + .PHONY: clean-utils clean-utils: | utils $(MAKE) -w -C $| clean -.PHONY: uninstall-utils -uninstall-utils: clean-utils | utils - $(MAKE) -w -C $| bindir=$(shell realpath --relative-to=$| $(bindir)) uninstall +.PHONY: distclean-utils +distclean-utils: | utils + $(MAKE) -w -C $| distclean # software +.PHONY: build-software +build-software: | software + $(MAKE) -w -C $| bindir=$(shell realpath --relative-to=$| $(bindir)) + .PHONY: install-software -install-software: $(foreach t,$(SOFTWARE_TARGETS),$(DESTDIR)$(bindir)/$(t)) - -$(DESTDIR)$(bindir)/ESPRST: software/esprst/esprst - $(INSTALL) $< $@ - -$(DESTDIR)$(bindir)/IWCONFIG: software/iwconfig/IWCONFIG - $(INSTALL) $< $@ - -software/esprst/esprst: | software/esprst - $(MAKE) -w -C $| - -software/iwconfig/IWCONFIG: | software/iwconfig - $(MAKE) -w -C $| - -.PHONY: clean-software -clean-software: |\ - software/esprst\ - software/iwconfig - $(MAKE) -w -C software/esprst clean - $(MAKE) -w -C software/iwconfig clean +install-software: | software + for d in $(SOFTWARE_SUBDIRS); do d=$|/$$d; $(MAKE) -w -C $$d bindir=$$(realpath --relative-to=$$d $(bindir)) install; done .PHONY: uninstall-software -uninstall-software: clean-software - $(RM) $(foreach t,$(SOFTWARE_TARGETS),$(DESTDIR)$(bindir)/$(t)) +uninstall-software: | software + for d in $(SOFTWARE_SUBDIRS); do d=$|/$$d; $(MAKE) -w -C $$d bindir=$$(realpath --relative-to=$$d $(bindir)) uninstall; done -# clean +.PHONY: clean-software +clean-software: | software + for d in $(SOFTWARE_SUBDIRS); do d=$|/$$d; $(MAKE) -w -C $$d bindir=$$(realpath --relative-to=$$d $(bindir)) clean; done + +.PHONY: distclean-software +distclean-software: | software + for d in $(SOFTWARE_SUBDIRS); do d=$|/$$d; $(MAKE) -w -C $$d bindir=$$(realpath --relative-to=$$d $(bindir)) distclean; done + +# all + +.PHONY: build +build: $(foreach t,$(TARGETS),build-$(t)) + +.PHONY: install +install: $(foreach t,$(TARGETS),install-$(t)) + +.PHONY: uninstall +uninstall: $(foreach t,$(TARGETS),uninstall-$(t)) .PHONY: clean -clean:\ - uninstall-utils\ - uninstall-software +clean: $(foreach t,$(TARGETS),clean-$(t)) + +.PHONY: distclean +distclean: $(foreach t,$(TARGETS),distclean-$(t)) diff --git a/firmware/bootloader.asm b/firmware/bootloader.asm index 916f492..9e0acb2 100644 --- a/firmware/bootloader.asm +++ b/firmware/bootloader.asm @@ -1,17 +1,42 @@ +; firmware.asm +; +; Copyright (C) 2016-2021 Antonio Villena +; Contributors: +; 2015 Einar Saukas (ZX7 Backwards) +; 2021 Ivan Tatarinov +; +; This program is free software: you can redistribute it and/or modify +; it under the terms of the GNU General Public License as published by +; the Free Software Foundation, version 3. +; +; This program is distributed in the hope that it will be useful, +; but WITHOUT ANY WARRANTY; without even the implied warranty of +; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +; GNU General Public License for more details. +; +; You should have received a copy of the GNU General Public License +; along with this program. If not, see . +; +; SPDX-FileCopyrightText: Copyright (C) 2016-2021 Antonio Villena +; +; SPDX-FileContributor: 2015 Einar Saukas (ZX7 Backwards) +; SPDX-FileContributor: 2021 Ivan Tatarinov +; +; SPDX-License-Identifier: GPL-3.0-only + +; Compatible compilers: +; SJAsmPlus, +; SJAsmPlus by aprisobal, + + output bootloader.rom + + include zxuno.def + macro wreg dir, dato rst $28 defb dir, dato endm - output bootloader.rom - define zxuno_port $fc3b - define master_conf 0 - define master_mapper 1 - define flash_spi 2 - define flash_cs 3 - define joyconf 6 - define scandbl_ctrl 11 - di ld sp, $bfff-ini+6 wreg flash_cs, 1 ; desactivamos spi, enviando un 0 @@ -51,7 +76,7 @@ nmi66 jp $c003 retn cont wreg flash_cs, 1 ; desactivamos spi, enviando un 1 - wreg joyconf, %00010000 + wreg joy_conf, %00010000 wreg master_mapper, 8 ; paginamos la ROM en $c000 lee in a, ($1f) djnz lee @@ -85,10 +110,10 @@ recov ld hl, firmware-1 block $0100 - $ include scroll/define.asm ld sp, 0 - ld de, $5e6d+filesize-1 + ld de, filestart+filesize-1 ld hl, scroll-1 call dzx7b - jp $7be4 + jp start ; ----------------------------------------------------------------------------- ; ZX7 Backwards by Einar Saukas, Antonio Villena diff --git a/software/esprst/.gitignore b/software/esprst/.gitignore index f8cb13a..7cef27e 100644 --- a/software/esprst/.gitignore +++ b/software/esprst/.gitignore @@ -2,4 +2,4 @@ # # SPDX-License-Identifier: GPL-3.0-or-later -esprst +build diff --git a/software/esprst/Makefile b/software/esprst/Makefile index a93b5b1..c589414 100644 --- a/software/esprst/Makefile +++ b/software/esprst/Makefile @@ -1,15 +1,82 @@ # SPDX-FileCopyrightText: Copyright (C) 2019 Alexander Sharikhin # +# SPDX-FileContributor: 2021 Ivan Tatarinov +# # SPDX-License-Identifier: GPL-3.0-or-later +# +# Supported environments: +# * GNU on Linux, FreeBSD etc. +# * GNU on Windows NT (using MinGW/MSYS/Cygwin/WSL) +# +# Build: +# make [ ...] +# Install / Uninstall: +# make [prefix=] install | uninstall +# Clean: +# make clean | distclean +# +# where: +# is one of values for `BINS' variable prefixed with "build/" +# (see target `all' below). +# is a prefix directory to install files into. include ../../sdk/common.mk -.PHONY: all -all: esprst +# Use uppercase for FAT filesystem +srcdir = . +prefix ?= . +exec_prefix ?= $(prefix) +bindir ?= $(exec_prefix)/BIN -esprst: main.asm uart.asm ring.asm - sjasmplus $< +# Disable execution mode for FAT filesystem +INSTALL ?= install +INSTALL_PROGRAM ?= $(INSTALL) -m 644 +RM = rm -f + +AS = sjasmplus +ifeq ($(USE_SJASMPLUS_VERSION),sjasmplus) +AFLAGS = --nobanner +else ifeq ($(USE_SJASMPLUS_VERSION),z00m128) +AFLAGS = --nologo +else +AFLAGS = +endif + +BINS=\ + ESPRST + +.PHONY: all +all: $(foreach t,$(BINS),build/$(t)) + +build\ +$(DESTDIR)$(bindir): + mkdir -p $@ + +build/ESPRST: $(srcdir)/main.asm\ + $(srcdir)/uart.asm\ + $(srcdir)/ring.asm\ + | build + $(AS) $(AFLAGS) --raw=$@ $< + +# $1 = target +define install_bin_rule = +$$(DESTDIR)$$(bindir)/$1: build/$1 | $$(DESTDIR)$$(bindir) + $$(INSTALL_PROGRAM) $$< $$@ +endef + +$(foreach t,$(BINS),$(eval $(call install_bin_rule,$(t)))) + +.PHONY: install +install: $(foreach t,$(BINS),$(DESTDIR)$(bindir)/$(t)) + +.PHONY: uninstall +uninstall: + $(RM) $(foreach t,$(BINS),$(DESTDIR)$(bindir)/$(t)) .PHONY: clean clean: - rm -f esprst + rm -f $(foreach t,$(BINS),build/$(t)) + +.PHONY: distclean +distclean: + rm -rf build/* diff --git a/software/esprst/main.asm b/software/esprst/main.asm index 0b55662..901f00e 100644 --- a/software/esprst/main.asm +++ b/software/esprst/main.asm @@ -90,4 +90,4 @@ cmd_info defb "AT+GMR", 13, 10, 0 response_ok defb "OK", 13, 10, 0 response_er defb "ready", 0 - SAVEBIN "esprst", Start, $ - Start +; SAVEBIN "esprst", Start, $ - Start diff --git a/software/iwconfig/.gitignore b/software/iwconfig/.gitignore index 3fd67f3..7cef27e 100644 --- a/software/iwconfig/.gitignore +++ b/software/iwconfig/.gitignore @@ -2,6 +2,4 @@ # # SPDX-License-Identifier: GPL-3.0-or-later -*.bin -*.def -IWCONFIG +build diff --git a/software/iwconfig/Makefile b/software/iwconfig/Makefile index 4757207..596c2ee 100644 --- a/software/iwconfig/Makefile +++ b/software/iwconfig/Makefile @@ -1,15 +1,74 @@ # SPDX-FileCopyrightText: Copyright (C) 2019 Alexander Sharikhin # +# SPDX-FileContributor: 2021 Ivan Tatarinov +# # SPDX-License-Identifier: GPL-3.0-or-later +# +# Supported environments: +# * GNU on Linux, FreeBSD etc. +# * GNU on Windows NT (using MinGW/MSYS/Cygwin/WSL) +# +# Build: +# make [ ...] +# Install / Uninstall: +# make [prefix=] install | uninstall +# Clean: +# make clean | distclean +# +# where: +# is one of values for `BINS' variable prefixed with "build/" +# (see target `all' below). +# is a prefix directory to install files into. include ../../sdk/common.mk -.PHONY: all -all: IWCONFIG +# Use uppercase for FAT filesystem +srcdir = . +prefix ?= . +exec_prefix ?= $(prefix) +bindir ?= $(exec_prefix)/BIN -IWCONFIG: iwconfig.c - zcc +zx -vn -startup=30 -clib=new $< -SO3 -o $@ -subtype=dot -create-app +# Disable execution mode for FAT filesystem +INSTALL ?= install +INSTALL_PROGRAM ?= $(INSTALL) -m 644 +RM = rm -f + +BINS=\ + IWCONFIG + +# `zcc' compiler's behavior: +# * produces binary file in source's directory only +# * creates temporary files +TMPS=\ + $(foreach t,$(BINS),$(t)_CODE.bin $(t)_UNASSIGNED.bin) + +.PHONY: all +all: $(foreach t,$(BINS),build/$(t)) + +build\ +$(DESTDIR)$(bindir): + mkdir -p $@ + +build/IWCONFIG: $(srcdir)/iwconfig.c | build + zcc +zx -vn -startup=30 -clib=new $< -SO3 -o $(@F) -subtype=dot -create-app +# Workaround for zcc: + rm -f $(TMPS) + mv $(@F) $@ + +$(DESTDIR)$(bindir)/%: build/% | $(DESTDIR)$(bindir) + cp $< $@ + +.PHONY: install +install: $(foreach t,$(BINS),$(DESTDIR)$(bindir)/$(t)) + +.PHONY: uninstall +uninstall: + $(RM) $(foreach t,$(BINS),$(DESTDIR)$(bindir)/$(t)) .PHONY: clean clean: - rm -f *.bin *.def IWCONFIG + rm -f $(BINS) $(TMPS) $(foreach t,$(BINS),build/$(t)) + +.PHONY: distclean +distclean: + rm -rf build/* diff --git a/software/ugophy/.gitignore b/software/ugophy/.gitignore index b216dab..7cef27e 100644 --- a/software/ugophy/.gitignore +++ b/software/ugophy/.gitignore @@ -2,7 +2,4 @@ # # SPDX-License-Identifier: GPL-3.0-or-later -*.tap -player.bin -ugoph.bin -.vscode +build diff --git a/software/ugophy/Makefile b/software/ugophy/Makefile index cdf74da..5e2c601 100644 --- a/software/ugophy/Makefile +++ b/software/ugophy/Makefile @@ -1,15 +1,83 @@ # SPDX-FileCopyrightText: Copyright (C) 2019 Alexander Sharikhin # +# SPDX-FileContributor: 2021 Ivan Tatarinov +# # SPDX-License-Identifier: GPL-3.0-or-later +# +# Supported environments: +# * GNU on Linux, FreeBSD etc. +# * GNU on Windows NT (using MinGW/MSYS/Cygwin/WSL) +# +# Build: +# make [ ...] +# Install / Uninstall: +# make [prefix=] install | uninstall +# Clean: +# make clean | distclean +# +# where: +# is one of values for `BINS' variable prefixed with "build/" +# (see target `all' below). +# is a prefix directory to install files into. include ../../sdk/common.mk -.PHONY: all -all: ugoph.bin +# Use uppercase for FAT filesystem +srcdir = . +prefix ?= . +exec_prefix ?= $(prefix) +bindir ?= $(exec_prefix)/BIN -ugoph.bin ugoph.tap: main.asm tscreen.asm keyboard.asm utils.asm wifi.asm gopher.asm render.asm textrender.asm uart.asm ring.asm esxdos.asm vtpl.asm - sjasmplus $< +# Disable execution mode for FAT filesystem +INSTALL ?= install +INSTALL_PROGRAM ?= $(INSTALL) -m 644 +RM = rm -f + +AS = sjasmplus +ifeq ($(USE_SJASMPLUS_VERSION),sjasmplus) +AFLAGS = --nobanner +else ifeq ($(USE_SJASMPLUS_VERSION),z00m128) +AFLAGS = --nologo +else +AFLAGS = +endif + +BINS=\ + UGOPH + +.PHONY: all +all: $(foreach t,$(BINS),build/$(t)) + +build\ +$(DESTDIR)$(bindir): + mkdir -p $@ + +build/UGOPH: $(srcdir)/main.asm\ + $(srcdir)/tscreen.asm\ + $(srcdir)/keyboard.asm\ + $(srcdir)/utils.asm\ + $(srcdir)/wifi.asm\ + $(srcdir)/gopher.asm\ + $(srcdir)/render.asm\ + $(srcdir)/textrender.asm\ + $(srcdir)/uart.asm\ + $(srcdir)/ring.asm\ + $(srcdir)/esxdos.asm\ + $(srcdir)/vtpl.asm\ + | build + $(AS) $(AFLAGS) --raw=$@ $< + +.PHONY: install +install: $(foreach t,$(BINS),$(DESTDIR)$(bindir)/$(t)) + +.PHONY: uninstall +uninstall: + $(RM) $(foreach t,$(BINS),$(DESTDIR)$(bindir)/$(t)) .PHONY: clean clean: - rm -f ugoph.bin ugoph.tap + rm -f $(foreach t,$(BINS),build/$(t)) + +.PHONY: distclean +distclean: + rm -rf build/* diff --git a/software/ugophy/main.asm b/software/ugophy/main.asm index 4ff208e..f5b2b79 100644 --- a/software/ugophy/main.asm +++ b/software/ugophy/main.asm @@ -92,5 +92,5 @@ player DISPLAY "Player ends: ", $ ENT eop equ $ - SAVEBIN "ugoph.bin", Start, $ - Start - SAVETAP "ugoph.tap", Start +; SAVEBIN "ugoph.bin", Start, $ - Start +; SAVETAP "ugoph.tap", Start