msxbuild/lib/make/mb_openmsx.mk

63 lines
2.9 KiB
Makefile
Raw Normal View History

2020-12-23 17:14:13 +00:00
# TODO move to new msxhub native posix+win cmd tool
# + local userdir caching like ~/.cache/msxhub/repro/m/s/x/msxdos2
CMD_WGET ?= wget
PATH_OPENMSX ?= /usr/bin
# Define openmsx defaults
MB_OPENMSX_BOOT_TIMEOUT ?= 25
MB_OPENMSX_MACHINE ?= Philips_NMS_8250
MB_OPENMSX_JOYPORTA ?=
MB_OPENMSX_JOYPORTB ?=
# Workaround for include msxbuild.mk file and 'older' openmsx segfaults on relative settings path.
MB_OPENMSX_SETTING := $(if $(realpath $(PATH_MSXBUILD)),$(realpath $(PATH_MSXBUILD)),$(PATH_MSXBUILD))/lib/openmsx/boot_settings.xml
MB_OPENMSX_EXTS_ORG += -ext ide -ext ram4mb
MB_OPENMSX_ARGS = \
-setting $(MB_OPENMSX_SETTING) \
-machine $(MB_OPENMSX_MACHINE) \
-ext slotexpander $(MB_OPENMSX_EXTS_ORG) $(MB_OPENMSX_EXTS) \
-script $(PATH_MSXBUILD)/lib/openmsx/boot_env.tcl \
-script $(PATH_MSXBUILD)/lib/openmsx/boot_hdd.tcl \
-script $(PATH_MSXBUILD)/lib/openmsx/fail_after.tcl \
-script $(PATH_MSXBUILD)/bin/wget/omsxctl.tcl
# TODO: add run flag to disable xml output like "-control stdio-boot-only"
ifeq ($(OS),Windows_NT)
MB_OPENMSX_CMD = $(PATH_OPENMSX)/openmsx $(MB_OPENMSX_ARGS) -control stdio < $(PATH_MSXBUILD)/lib/openmsx/boot_stdio.xml
else
MB_OPENMSX_CMD = $(PATH_OPENMSX)/openmsx $(MB_OPENMSX_ARGS) -control stdio < $(PATH_MSXBUILD)/lib/openmsx/boot_stdio.xml | sed -n -e 's/.*>\(.*\)<.*/\1/p' | tail -n+3
endif
define _mb_openmsx_run
@echo === Running openmsx
test -f $(PATH_MSXBUILD)/bin/wget/omsxctl.tcl || $(CMD_WGET) -O $(PATH_MSXBUILD)/bin/wget/omsxctl.tcl https://msxhub.com/api/OMSXCTL/1.0-1/get/OMSXCTL/omsxctl.tcl
FAIL_AFTER_BOOT=$(MB_OPENMSX_BOOT_TIMEOUT) \
FAIL_AFTER_PATH=bin \
BOOT_HDD_PATH="$(1)" \
BOOT_HDD_IMAGE="$(1)/../dsk.img" \
JOYPORTA=$(MB_OPENMSX_JOYPORTA) \
JOYPORTB=$(MB_OPENMSX_JOYPORTB) \
$(MB_OPENMSX_CMD)
endef
define _mb_openmsx_run_dos
@echo === run openmsx
test -f $(PATH_MSXBUILD)/bin/wget/omsxctl.com || $(CMD_WGET) -O $(PATH_MSXBUILD)/bin/wget/omsxctl.com https://msxhub.com/api/OMSXCTL/1.0-1/get/OMSXCTL/omsxctl.com
$(call mb_copy,$(PATH_MSXBUILD)/bin/wget/omsxctl.com,$(1))
$(call _mb_openmsx_run,$(1))
endef
# TODO: add msx1+allversions of dos to https://github.com/fr3nd/msxhub-packages/issues/18
#define mb_openmsx_dos1
# @echo === Run openmsx_dos1
# cp build/msxdos1/* $(1)
# $(call _mb_openmsx_run_dos,$(1))
#endef
define mb_openmsx_dos2
@echo === Prepare openmsx run with dos2
test -f $(PATH_MSXBUILD)/bin/wget/msxdos2.sys || $(MB_MKDIR) $(PATH_MSXBUILD)/bin/wget
test -f $(PATH_MSXBUILD)/bin/wget/msxdos2.sys || $(CMD_WGET) -O $(PATH_MSXBUILD)/bin/wget/msxdos2.sys https://msxhub.com/api/MSXDOS2/2.20-1/get/MSXDOS2/MSXDOS2.SYS
test -f $(PATH_MSXBUILD)/bin/wget/command2.com || $(CMD_WGET) -O $(PATH_MSXBUILD)/bin/wget/command2.com https://msxhub.com/api/MSXDOS2/2.20-1/get/MSXDOS2/COMMAND2.COM
$(call mb_copy,$(PATH_MSXBUILD)/bin/wget/msxdos2.sys,$(1))
$(call mb_copy,$(PATH_MSXBUILD)/bin/wget/command2.com,$(1))
$(call _mb_openmsx_run_dos, $(1))
endef