new package: 8086tiny

Requested in https://github.com/termux/termux-packages/issues/4828.
This commit is contained in:
Leonid Pliushch 2020-01-24 21:11:03 +02:00
parent 8a85156fc1
commit ffb396b647
4 changed files with 174 additions and 0 deletions

83
packages/8086tiny/8086tiny.sh Executable file
View File

@ -0,0 +1,83 @@
#!@TERMUX_PREFIX@/bin/bash
VERSION="@PACKAGE_VERSION@"
PROGRAM="@TERMUX_PREFIX@/libexec/8086tiny"
BIOS_IMAGE=""
FD_IMAGE=""
HDD_IMAGE=""
cleanup() {
stty cooked echo
echo
}
usage() {
echo "Usage: 8086tiny [bios image] [floppy image] [harddisk image]"
echo
echo "8086tiny is a tiny, free, open source, portable Intel PC emulator/VM."
echo
echo "Options:"
echo
echo " -h, --help show this help and exit"
echo " -v, --version show version information"
echo
}
while (( $# > 0 )); do
case "$1" in
-h|--help)
usage
exit 0
;;
-v|--version)
echo "8086tiny $VERSION"
exit 0
;;
-*)
echo "Unknown option '$1'."
echo
usage
exit 1
;;
*)
if [ -z "$BIOS_IMAGE" ]; then
BIOS_IMAGE="$1"
shift 1
continue
fi
if [ -z "$FD_IMAGE" ]; then
FD_IMAGE="$1"
shift 1
continue
fi
if [ -z "$HDD_IMAGE" ]; then
HDD_IMAGE="$1"
shift 1
continue
fi
;;
esac
shift 1
done
if [ -z "$BIOS_IMAGE" ]; then
BIOS_IMAGE="@TERMUX_PREFIX@/share/8086tiny/bios.bin"
fi
if [ -z "$FD_IMAGE" ]; then
FD_IMAGE="@TERMUX_PREFIX@/share/8086tiny/dos.img"
fi
trap cleanup INT TERM
stty cbreak raw -echo min 0
if [ -n "$HDD_IMAGE" ]; then
"$PROGRAM" "$BIOS_IMAGE" "$FD_IMAGE" "$HDD_IMAGE"
else
"$PROGRAM" "$BIOS_IMAGE" "$FD_IMAGE"
fi
cleanup

View File

@ -0,0 +1,27 @@
diff -uNr 8086tiny/Makefile 8086tiny.mod/Makefile
--- 8086tiny/Makefile 2014-03-20 01:08:16.000000000 +0200
+++ 8086tiny.mod/Makefile 2020-01-24 20:38:58.709164842 +0200
@@ -7,22 +7,19 @@
# 8086tiny_slowcpu improves graphics performance on slow platforms (e.g. Raspberry Pi)
# no_graphics compiles without SDL graphics/sound
-OPTS_ALL=-O3 -fsigned-char -std=c99
+OPTS_ALL=$(CPPFLAGS) $(CFLAGS) -fsigned-char -std=c99
OPTS_SDL=`sdl-config --cflags --libs`
OPTS_NOGFX=-DNO_GRAPHICS
OPTS_SLOWCPU=-DGRAPHICS_UPDATE_DELAY=25000
8086tiny: 8086tiny.c
${CC} 8086tiny.c ${OPTS_SDL} ${OPTS_ALL} -o 8086tiny
- strip 8086tiny
8086tiny_slowcpu: 8086tiny.c
${CC} 8086tiny.c ${OPTS_SDL} ${OPTS_ALL} ${OPTS_SLOWCPU} -o 8086tiny
- strip 8086tiny
no_graphics: 8086tiny.c
${CC} 8086tiny.c ${OPTS_NOGFX} ${OPTS_ALL} -o 8086tiny
- strip 8086tiny
clean:
rm 8086tiny

View File

@ -0,0 +1,23 @@
TERMUX_PKG_HOMEPAGE=https://github.com/adriancable/8086tiny
TERMUX_PKG_DESCRIPTION="A PC XT-compatible emulator/virtual machine"
TERMUX_PKG_LICENSE="MIT"
TERMUX_PKG_VERSION=1.25
# Version tag is unavailable.
TERMUX_PKG_SRCURL=https://github.com/adriancable/8086tiny/archive/c79ca2a34d96931d55ef724c815b289d0767ae3a.tar.gz
TERMUX_PKG_SHA256=ede246503a745274430fdee77ba639bc133a2beea9f161bff3f7132a03544bf6
TERMUX_PKG_BUILD_IN_SRC=true
termux_step_pre_configure() {
CPPFLAGS+=" -DNO_GRAPHICS"
}
termux_step_make_install() {
install -Dm700 8086tiny "$TERMUX_PREFIX"/libexec/8086tiny
install -Dm600 bios "$TERMUX_PREFIX"/share/8086tiny/bios.bin
install -Dm600 fd.img "$TERMUX_PREFIX"/share/8086tiny/dos.img
sed -e "s|@TERMUX_PREFIX@|$TERMUX_PREFIX|g" \
-e "s|@PACKAGE_VERSION@|$TERMUX_PKG_VERSION|g" \
"$TERMUX_PKG_BUILDER_DIR"/8086tiny.sh > "$TERMUX_PREFIX"/bin/8086tiny
chmod 700 "$TERMUX_PREFIX"/bin/8086tiny
}

View File

@ -0,0 +1,41 @@
diff -uNr 8086tiny/8086tiny.c 8086tiny.mod/8086tiny.c
--- 8086tiny/8086tiny.c 2014-03-20 01:08:16.000000000 +0200
+++ 8086tiny.mod/8086tiny.c 2020-01-24 20:36:56.725634080 +0200
@@ -6,7 +6,37 @@
// This work is licensed under the MIT License. See included LICENSE.TXT.
#include <time.h>
+#ifndef __ANDROID__
#include <sys/timeb.h>
+#else
+struct timeb {
+ time_t time; /* Seconds since epoch, as from `time'. */
+ unsigned short int millitm; /* Additional milliseconds. */
+ short int timezone; /* Minutes west of GMT. */
+ short int dstflag; /* Nonzero if Daylight Savings Time used. */
+};
+
+int ftime(struct timeb *tb)
+{
+ struct timeval tv;
+ struct timezone tz;
+
+ if (gettimeofday (&tv, &tz) < 0)
+ return -1;
+
+ tb->time = tv.tv_sec;
+ tb->millitm = (tv.tv_usec + 500) / 1000;
+
+ if (tb->millitm == 1000) {
+ ++tb->time;
+ tb->millitm = 0;
+ }
+ tb->timezone = tz.tz_minuteswest;
+ tb->dstflag = tz.tz_dsttime;
+
+ return 0;
+}
+#endif
#include <memory.h>
#ifndef _WIN32