Skip to content

Commit

Permalink
Add support for Trevor Flowers' mini VT100.
Browse files Browse the repository at this point in the history
  • Loading branch information
larsbrinkhoff committed Oct 24, 2024
1 parent 0fe6abf commit 1aa793b
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 2 deletions.
2 changes: 1 addition & 1 deletion vt100/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ endif
check: vt100 ../test/test.sh
cd ..; sh test/test.sh
WARN=-Wall -Wno-unused-parameter -Wno-parentheses -Wno-unused-result
SRC=main.c cpu.c sys.c ddt.c pusart.c \
SRC=main.c cpu.c sys.c ddt.c pusart.c flowers.c \
nvr.c keyboard.c video.c rom.c sound.c render.c \
../common/sdl.c ../common/opengl.c ../common/event.c \
../common/logger.c ../common/pty.c
Expand Down
21 changes: 21 additions & 0 deletions vt100/flowers.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#include <unistd.h>
#include "vt100.h"

int flowers = 0; // Trevor Flowers' mini VT100.

void flowers_leds(u8 data)
{
char command[100];
int n;
if (!flowers)
return;
n = snprintf(command, sizeof command, "SET_ALL_LEDS %c%c%c%c%c%c%c\n",
(data & 0x20) ? '0' : '1',
(data & 0x20) ? '1' : '0',
(data & 0x10) ? '1' : '0',
(data & 0x08) ? '1' : '0',
(data & 0x04) ? '1' : '0',
(data & 0x02) ? '1' : '0',
(data & 0x01) ? '1' : '0');
write(flowers, command, n);
}
3 changes: 3 additions & 0 deletions vt100/keyboard.c
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,8 @@ static void keyboard_out (u8 port, u8 data)
u8 changed = previous ^ data;
if ((vt100_flags & 0x80) == 0)
return;
if (changed)
flowers_leds(data);
if (changed & ~0x40)
LOG (KEY, "LED:%c%c%c%c %s %s%s",
(data & 0x08) ? '1' : '-',
Expand Down Expand Up @@ -187,4 +189,5 @@ void reset_keyboard (void)
memset (down, 0, sizeof down);
down[0x7F] = 1;
scan = 0x80;
flowers_leds(0);
}
7 changes: 6 additions & 1 deletion vt100/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ int main (int argc, char **argv)
sdl_capslock (0x7E); //Default is capslock.

argv0 = argv[0];
while ((opt = getopt (argc, argv, "aghB2fR:DCQN:c:")) != -1) {
while ((opt = getopt (argc, argv, "aghB2fF:R:DCQN:c:")) != -1) {
switch (opt) {
case 'g':
pixcolor = 1;
Expand Down Expand Up @@ -195,6 +195,11 @@ int main (int argc, char **argv)
case 'c':
curvature = atof (optarg);
break;
case 'F':
flowers = open(optarg, O_RDWR);
if (flowers == -1)
panic("Couldn't open %s: %s", optarg, strerror (errno));
break;
default:
usage();
break;
Expand Down
3 changes: 3 additions & 0 deletions vt100/vt100.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ extern u8 vt100_flags;
extern int pty;
extern int sound_scope;
extern int field_rate;
extern int flowers;

extern int quick;
extern int pixcolor;
Expand Down Expand Up @@ -62,3 +63,5 @@ extern void reset_sound (void);
extern void nvr_clock (void);
extern void key_down (u8 code);
extern void key_up (u8 code);

extern void flowers_leds(u8 data);

0 comments on commit 1aa793b

Please sign in to comment.