Skip to content

Commit c389737

Browse files
committed
Bump version to v1.9, include input fixes and build updates
1 parent ca2b737 commit c389737

5 files changed

Lines changed: 69 additions & 16 deletions

File tree

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,3 +50,8 @@ modules.order
5050
Module.symvers
5151
Mkfile.old
5252
dkms.conf
53+
54+
# Amiberry Host Tools
55+
host-run
56+
host-shell
57+
host-multiview

Makefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@ CC = m68k-amigaos-gcc
55
INCLUDES = -Isrc
66
CFLAGS = -mcpu=68020 -noixemul -Os -fomit-frame-pointer -std=c99
77

8-
host-run: $(OBJS)
8+
host-run: src/host-run.c
99
$(CC) $(CFLAGS) $(INCLUDES) src/host-run.c -o $@
1010

11-
host-multiview: $(OBJS)
11+
host-multiview: src/host-multiview.c
1212
$(CC) $(CFLAGS) $(INCLUDES) src/host-multiview.c -o $@
1313

14-
host-shell: $(OBJS)
14+
host-shell: src/host-shell.c
1515
$(CC) $(CFLAGS) $(INCLUDES) src/host-shell.c -o $@
1616

1717
clean:

src/host-multiview.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33
#include <stdlib.h>
44
#include "uae_pragmas.h"
55

6-
static const char __ver[40] = "$VER: Host-MultiView v1.8 (2025-12-26)";
6+
static const char __ver[40] = "$VER: Host-MultiView v1.9 (2025-12-26)";
77

88
int print_usage()
99
{
10-
printf("Host-MultiView v1.8\n");
10+
printf("Host-MultiView v1.9\n");
1111
printf("Host-MultiView is a command line tool to open files with the host default handler, from within UAE.\n");
1212
printf("%s\nUsage: host-multiview <filename> [filename2 ...]\n", __ver);
1313
return 0;

src/host-run.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@
33
#include <stdlib.h>
44
#include "uae_pragmas.h"
55

6-
static const char __ver[40] = "$VER: Host-Run v1.8 (2025-12-26)";
6+
static const char __ver[40] = "$VER: Host-Run v1.9 (2025-12-26)";
77

88
#define MAX_CMD_LEN 4096
99

1010
int print_usage()
1111
{
12-
printf("Host-Run v1.8\n");
12+
printf("Host-Run v1.9\n");
1313
printf("Host-Run is a command line tool to run host commands from within UAE.\n");
1414
printf("%s\nUsage: host-run <command> <argument1> <argument2> ...\n", __ver);
1515
return 0;

src/host-shell.c

Lines changed: 57 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
#include <stdio.h>
22
#include <string.h>
33
#include <stdlib.h>
4-
#include "uae_pragmas.h"
5-
64
#include <proto/exec.h>
75
#include <proto/dos.h>
86

7+
#include "uae_pragmas.h"
8+
99
#define OUTBUFSIZE 4095
1010

11-
static const char version[] = "$VER: Host-Shell v1.8 (2025-12-26)";
11+
static const char version[] = "$VER: Host-Shell v1.9 (2025-12-26)";
1212
char outbuf[OUTBUFSIZE + 1];
1313

1414
int main(int argc, char *argv[])
@@ -49,14 +49,42 @@ int main(int argc, char *argv[])
4949
return 10;
5050
}
5151

52+
BOOL esc_pending = FALSE;
53+
5254
while (!brk)
5355
{
5456
// Check for output from host
55-
actual = HostShell_Read(handle, (UBYTE *)buffer, sizeof(buffer) - 1);
57+
actual = HostShell_Read(handle, (UBYTE *)buffer, sizeof(buffer) - 2);
5658
if (actual > 0)
5759
{
58-
buffer[actual] = 0;
59-
Write(out, buffer, actual);
60+
int outptr = 0;
61+
for (int i = 0; i < actual; i++) {
62+
unsigned char c = (unsigned char)buffer[i];
63+
if (esc_pending) {
64+
if (c == 0x5B) { // '['
65+
outbuf[outptr++] = 0x9B; // CSI
66+
} else {
67+
outbuf[outptr++] = 0x1B; // Original ESC
68+
outbuf[outptr++] = c;
69+
}
70+
esc_pending = FALSE;
71+
} else {
72+
if (c == 0x1B) {
73+
esc_pending = TRUE;
74+
} else {
75+
outbuf[outptr++] = c;
76+
}
77+
}
78+
79+
// Safety check for outbuf overflow (should rarely happen given the math)
80+
if (outptr >= OUTBUFSIZE) {
81+
Write(out, outbuf, outptr);
82+
outptr = 0;
83+
}
84+
}
85+
if (outptr > 0) {
86+
Write(out, outbuf, outptr);
87+
}
6088
}
6189
else if (actual < 0) // Error or closed
6290
{
@@ -67,10 +95,27 @@ int main(int argc, char *argv[])
6795
// Wait up to 20ms (20000 microseconds)
6896
if (WaitForChar(in, 20000))
6997
{
70-
actual = Read(in, buffer, sizeof(buffer));
98+
// Read less than buffer size to allow for expansion (max 2x)
99+
actual = Read(in, buffer, 1024);
71100
if (actual > 0)
72101
{
73-
HostShell_Write(handle, (UBYTE *)buffer, actual);
102+
int outptr = 0;
103+
for (int i = 0; i < actual; i++) {
104+
unsigned char c = (unsigned char)buffer[i];
105+
if (c == 0x9B) { // Amiga CSI
106+
// Convert to ANSI ESC [
107+
outbuf[outptr++] = 0x1B;
108+
outbuf[outptr++] = 0x5B;
109+
} else if (c == 0x08) { // Backspace
110+
// Convert BS (0x08) to DEL (0x7F)
111+
outbuf[outptr++] = 0x7F;
112+
} else {
113+
outbuf[outptr++] = c;
114+
}
115+
}
116+
if (outptr > 0) {
117+
HostShell_Write(handle, (UBYTE *)outbuf, outptr);
118+
}
74119
}
75120
else if (actual == 0) // EOF
76121
{
@@ -80,7 +125,10 @@ int main(int argc, char *argv[])
80125

81126
if (SetSignal(0, 0) & SIGBREAKF_CTRL_C)
82127
{
83-
brk = TRUE;
128+
SetSignal(0, SIGBREAKF_CTRL_C); // Clear the signal
129+
// Send Ctrl-C (ETX) to host
130+
char ctrlc = 0x03;
131+
HostShell_Write(handle, (UBYTE *)&ctrlc, 1);
84132
}
85133
}
86134

0 commit comments

Comments
 (0)