View | Details | Raw Unified | Return to bug 259956 | Differences between
and this patch

Collapse All | Expand All

(-)b/emulators/Makefile (+1 lines)
Lines 158-163 Link Here
158
    SUBDIR += vmips
158
    SUBDIR += vmips
159
    SUBDIR += vmsbackup
159
    SUBDIR += vmsbackup
160
    SUBDIR += vmw
160
    SUBDIR += vmw
161
    SUBDIR += vt100
161
    SUBDIR += vxtools
162
    SUBDIR += vxtools
162
    SUBDIR += wine
163
    SUBDIR += wine
163
    SUBDIR += wine-devel
164
    SUBDIR += wine-devel
(-)b/emulators/vt100/Makefile (+32 lines)
Added Link Here
1
PORTNAME=	vt100
2
DISTVERSION=	0.1
3
CATEGORIES=	emulators
4
5
MAINTAINER=	fuz@fuz.su
6
COMMENT=	Simulation of VT100 terminal hardware
7
8
LICENSE=	GPLv3
9
LICENSE_FILE=	${WRKSRC:H}/LICENSE
10
11
USES=		gl gmake sdl
12
USE_GITHUB=	yes
13
GH_ACCOUNT=	larsbrinkhoff
14
GH_PROJECT=	terminal-simulator
15
USE_GL=		gl
16
USE_SDL=	image2
17
CFLAGS+=	-DSHADERDIR='\"${DATADIR}/\"'
18
WRKSRC_SUBDIR=	vt100
19
20
PLIST_FILES=	bin/vt100
21
PORTDATA=	crt.shader vertex.shader
22
23
do-install:
24
	${INSTALL_PROGRAM} ${WRKSRC}/vt100 ${STAGEDIR}${PREFIX}/bin/
25
	${MKDIR} ${STAGEDIR}${DATADIR}
26
	${INSTALL_DATA} ${WRKSRC}/crt.shader ${STAGEDIR}${DATADIR}/
27
	${INSTALL_DATA} ${WRKSRC}/vertex.shader ${STAGEDIR}${DATADIR}/
28
29
do-test:
30
	cd ${WRKSRC:H} && ${SH} test/test.sh
31
32
.include <bsd.port.mk>
(-)b/emulators/vt100/distinfo (+3 lines)
Added Link Here
1
TIMESTAMP = 1637415028
2
SHA256 (larsbrinkhoff-terminal-simulator-0.1_GH0.tar.gz) = 17640cc8dbbf8aa4d63a9c40fdcce623d7912ccc6dde7e461401f12297718c7b
3
SIZE (larsbrinkhoff-terminal-simulator-0.1_GH0.tar.gz) = 72930080
(-)b/emulators/vt100/files/patch-Makefile (+9 lines)
Added Link Here
1
--- Makefile.orig	2021-11-20 23:05:37 UTC
2
+++ Makefile
3
@@ -1,5 +1,5 @@
4
 all: vt100
5
-CFLAGS=-O3
6
+CFLAGS?=-O3
7
 ifeq "$(shell uname)" "Darwin"
8
  LDFLAGS += -framework OpenGL
9
 else
(-)b/emulators/vt100/files/patch-main.c (+44 lines)
Added Link Here
1
--- main.c.orig	2021-11-20 13:13:34 UTC
2
+++ main.c
3
@@ -1,6 +1,5 @@
4
 #include "vt100.h"
5
 #include "xsdl.h"
6
-#define _XOPEN_SOURCE 600
7
 #include <stdlib.h>
8
 #include <unistd.h>
9
 #include <fcntl.h>
10
@@ -116,7 +115,7 @@ usage(void)
11
 void help(void)
12
 {
13
   printf (
14
-    "Usage: %s [OPTIONS] command...\n"
15
+    "Usage: %s [OPTIONS] [command...]\n"
16
     "Run command [with arguments] in a hardware-emulated VT100.\n"
17
     "\n"
18
     "  -h      Display this help page and exit.\n"
19
@@ -144,6 +143,7 @@ int main (int argc, char **argv)
20
   int debug = 0;
21
   int scale = 1;
22
   int opt;
23
+  char *defaultcommand[2] = { NULL, NULL };
24
 
25
   halt = end;
26
   sdl_capslock (0x7E); //Default is capslock.
27
@@ -187,10 +187,13 @@ int main (int argc, char **argv)
28
     }
29
   }
30
 
31
-  if (optind == argc && !debug)
32
-    usage ();
33
-
34
-  cmd = &argv[optind];
35
+  if (optind < argc)
36
+    cmd = &argv[optind];
37
+  else {
38
+    setenv("SHELL", "/bin/sh", 0);
39
+    defaultcommand[0] = getenv("SHELL");
40
+    cmd = defaultcommand;
41
+  }
42
 
43
   log_file = stderr;
44
 
(-)b/emulators/vt100/files/patch-nvr.c (+68 lines)
Added Link Here
1
--- nvr.c.orig	2021-11-20 14:32:08 UTC
2
+++ nvr.c
3
@@ -1,4 +1,7 @@
4
+#include <stdlib.h>
5
+#include <stdio.h>
6
 #include <string.h>
7
+#include <sys/stat.h>
8
 #include "vt100.h"
9
 
10
 //ER1400 device.
11
@@ -8,7 +11,36 @@ static u8 nvr_latch;
12
 static u32 nvr_addr;
13
 static u16 nvr_data;
14
 static FILE *f;
15
+static char *filename = NULL;
16
+#define NVRAM "vt100-nvram"
17
 
18
+static void setfilename(void) {
19
+	char *statehome, *home;
20
+
21
+	if (filename != NULL)
22
+		return;
23
+
24
+	statehome = getenv("XDG_STATE_HOME");
25
+	if (statehome != NULL) {
26
+		asprintf(&filename, "%s/%s", statehome, NVRAM);
27
+		return;
28
+	}
29
+
30
+	home = getenv("HOME");
31
+	if (home != NULL) {
32
+		asprintf(&statehome, "%s/.local", home);
33
+		mkdir(statehome, 0777);
34
+		free(statehome);
35
+		asprintf(&statehome, "%s/.local/state", home);
36
+		mkdir(statehome, 0777);
37
+		free(statehome);
38
+		asprintf(&filename, "%s/.local/state/%s", home, NVRAM);
39
+		return;
40
+	}
41
+
42
+	filename = NVRAM;
43
+}
44
+
45
 static u8 nvr_in (u8 port)
46
 {
47
   LOG (NVR, "IN"); 
48
@@ -23,8 +55,9 @@ static void nvr_out (u8 port, u8 data)
49
 
50
 static void save (int addr)
51
 {
52
+  setfilename();
53
   if (f == NULL)
54
-    f = fopen ("nvram", "wb");
55
+    f = fopen (filename, "wb");
56
   if (f == NULL)
57
     return;
58
   fseek (f, 2 * addr, SEEK_SET);
59
@@ -161,7 +194,8 @@ void reset_nvr (void)
60
   register_port (0x62, nvr_in, nvr_out);
61
   nvr_data = 0;
62
   nvr_addr = 0;
63
-  f = fopen ("nvram", "r+b");
64
+  setfilename();
65
+  f = fopen (filename, "r+b");
66
   if (f != NULL)
67
     load ();
68
   else
(-)b/emulators/vt100/files/patch-opengl.c (+24 lines)
Added Link Here
1
--- opengl.c.orig	2021-11-20 23:05:51 UTC
2
+++ opengl.c
3
@@ -7,6 +7,10 @@
4
 #include <GL/gl.h>
5
 #endif
6
 
7
+#ifndef SHADERDIR
8
+# define SHADERDIR ""
9
+#endif
10
+
11
 static PFNGLCREATESHADERPROC glCreateShader;
12
 static PFNGLSHADERSOURCEPROC glShaderSource;
13
 static PFNGLCOMPILESHADERPROC glCompileShader;
14
@@ -102,8 +106,8 @@ static GLuint init_shader (void)
15
   unsigned int prog;
16
   int shader1, shader2, linked;
17
 
18
-  shader1 = compile ("vertex.shader", GL_VERTEX_SHADER);
19
-  shader2 = compile ("crt.shader", GL_FRAGMENT_SHADER);
20
+  shader1 = compile (SHADERDIR "vertex.shader", GL_VERTEX_SHADER);
21
+  shader2 = compile (SHADERDIR "crt.shader", GL_FRAGMENT_SHADER);
22
 
23
   prog = glCreateProgram ();
24
   glAttachShader (prog, shader1);
(-)b/emulators/vt100/files/patch-pty.c (+26 lines)
Added Link Here
1
--- pty.c.orig	2021-11-20 13:13:34 UTC
2
+++ pty.c
3
@@ -1,6 +1,3 @@
4
-#define _XOPEN_SOURCE 600
5
-#define _DEFAULT_SOURCE
6
-#define _DARWIN_C_SOURCE
7
 #include <stdlib.h>
8
 #include <fcntl.h>
9
 #include <unistd.h>
10
@@ -151,6 +148,7 @@ static void spawn (char **cmd)
11
     close (pty);
12
     dup (0);
13
     dup (1);
14
+    ioctl (0, TIOCSCTTY);
15
     shell (cmd);
16
   }
17
 }
18
@@ -235,7 +233,7 @@ u8 receive_character (void)
19
   while (throttle)
20
     SDL_CondWait (cond, lock);
21
   SDL_UnlockMutex (lock);
22
-  if (read (pty, &data, 1) < 0) {
23
+  if (read (pty, &data, 1) <= 0) {
24
     LOG (PTY, "End of file or error from pty.");
25
     exit (0);
26
   }
(-)b/emulators/vt100/files/patch-sound.c (+11 lines)
Added Link Here
1
--- sound.c.orig	2021-11-20 14:06:26 UTC
2
+++ sound.c
3
@@ -3,7 +3,7 @@
4
 #include "xsdl.h"
5
 
6
 #define FREQUENCY 48000
7
-#define SAMPLES (FREQUENCY * 3520 / 2764800)
8
+#define SAMPLES 64
9
 
10
 int sound_scope;
11
 static SDL_AudioDeviceID dev;
(-)b/emulators/vt100/files/patch-vt100.h (+11 lines)
Added Link Here
1
--- vt100.h.orig	2021-11-20 14:08:25 UTC
2
+++ vt100.h
3
@@ -86,7 +86,7 @@ extern void nvr_clock (void);
4
 extern void key_down (u8 code);
5
 extern void key_up (u8 code);
6
 
7
-#if 1
8
+#if 0
9
 #define LOG(COMPONENT, MESSAGE, ...) \
10
   logger (#COMPONENT, MESSAGE, ##__VA_ARGS__)
11
 #else
(-)b/emulators/vt100/pkg-descr (-1 / +7 lines)
Added Link Here
0
- 
1
This is a software simulation of the VT100 hardware. The original
2
firmware ROM is built in and executed by an 8080 emulator.  Other
3
components include video display with character generator ROM, settings
4
NVRAM, Intel 8251 USART, and a keyboard matrix scanner.  The Advance
5
Video Option is not included.
6
7
WWW: https://github.com/larsbrinkhoff/terminal-simulator

Return to bug 259956