From e3d7b425adff8a692d4f4412a20c4742235414d2 Mon Sep 17 00:00:00 2001 From: Dimitris Panokostas Date: Fri, 26 Jun 2020 19:37:37 +0200 Subject: [PATCH] First version --- .vscode/c_cpp_properties.json | 18 ++++++ .vscode/tasks.json | 111 ++++++++++++++++++++++++++++++++++ src/host-run.c | 36 +++++++++++ src/uae_pragmas.h | 108 +++++++++++++++++++++++++++++++++ 4 files changed, 273 insertions(+) create mode 100644 .vscode/c_cpp_properties.json create mode 100644 .vscode/tasks.json create mode 100644 src/host-run.c create mode 100644 src/uae_pragmas.h diff --git a/.vscode/c_cpp_properties.json b/.vscode/c_cpp_properties.json new file mode 100644 index 0000000..500406a --- /dev/null +++ b/.vscode/c_cpp_properties.json @@ -0,0 +1,18 @@ +{ + "configurations": [ + { + "name": "AmigaOS 3.x", + "includePath": [ + "${workspaceFolder}/**", + "${VBCC}/targets/m68k-amigaos/include/", + "${VBCC}/NDK39/Include/include_h" + ], + "defines": ["__USE_SYSBASE"], + "compilerPath": "${VBCC}/bin/vc", + "cStandard": "c99", + "cppStandard": "c++98", + "intelliSenseMode": "${default}" + } + ], + "version": 4 +} \ No newline at end of file diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 0000000..61a305b --- /dev/null +++ b/.vscode/tasks.json @@ -0,0 +1,111 @@ +{ + // See https://go.microsoft.com/fwlink/?LinkId=733558 + // for the documentation about the tasks.json format + "version": "2.0.0", + "tasks": [ + { + "label": "Compile with VBCC", + "type": "shell", + "windows": { + "command": "vc", + "args": [ + "+aos68k", + "-c99", + "-O2", + "-lamiga", + "-lauto", + "-o", + "host-run", + "src/host-run.c" + ] + }, + "osx": { + "command": "vc", + "args": [ + "+aos68k", + "-c99", + "-O2", + "-lamiga", + "-lauto", + "-o", + "host-run", + "src/host-run.c" + ] + }, + "linux": { + "command": "vc", + "args": [ + "+aos68k", + "-c99", + "-O2", + "-lamiga", + "-lauto", + "-o", + "host-run", + "src/host-run.c" + ] + }, + "group": { + "kind": "build", + "isDefault": true + } + }, + { + "label": "Clean", + "type": "shell", + "windows": { + "command": "rm", + "args": [ + "-Path", + "./host-run,", + "./src/host-run.o," + ] + }, + "osx": { + "command": "rm", + "args": [ + "./host-run,", + "./src/host-run.o," + ] + }, + "linux": { + "command": "rm", + "args": [ + "./host-run,", + "./src/host-run.o," + ] + } + }, + { + "label": "LHA Pack", + "type": "shell", + "windows": { + "command": "lha", + "args": [ + "a", + "host-run.lha", + "host-run", + "README.md" + ] + }, + "osx": { + "command": "lha", + "args": [ + "a", + "host-run.lha", + "host-run", + "README.md" + ] + }, + "linux": { + "command": "lha", + "args": [ + "a", + "host-run.lha", + "host-run", + "README.md" + ] + } + } + ] +} \ No newline at end of file diff --git a/src/host-run.c b/src/host-run.c new file mode 100644 index 0000000..9310d3d --- /dev/null +++ b/src/host-run.c @@ -0,0 +1,36 @@ +#include +#include +#include +#include "uae_pragmas.h" + +static const char version[] = "$VER: Host-Run v1.0"; + +int main(int argc, char *argv[]) +{ + char command[255]; + + if (argc <= 1) + { + printf("Missing argument\n"); + return 0; + } + + if (!InitUAEResource()) + { + printf("UAEResource not found!\n"); + return 2; + } + + for (int i = 1; i < argc; i++) + { + strcat(command, argv[i]); + + if (i != argc - 1) + strcat(command, " "); + else + strcat(command, " &\n"); + } + + // printf("DEBUG: %s", command); + ExecuteOnHost((UBYTE*)&command); +} \ No newline at end of file diff --git a/src/uae_pragmas.h b/src/uae_pragmas.h new file mode 100644 index 0000000..1775da0 --- /dev/null +++ b/src/uae_pragmas.h @@ -0,0 +1,108 @@ +#include +#include + +struct uaebase +{ + struct Library uae_lib; + UWORD uae_version; + UWORD uae_revision; + UWORD uae_subrevision; + UWORD zero; + APTR uae_rombase; +}; + +static struct uaebase *UAEResource; + +static int (*calltrap)(int arg0, ...) = (int (*)(int arg0, ...))0xF0FF60; + +static int InitUAEResource(void) +{ + UAEResource = (struct uaebase *)OpenResource("uae.resource"); + if (UAEResource) + { + calltrap = (int (*)(int arg0, ...))((BYTE *)UAEResource->uae_rombase + 0xFF60); + return 1; + } + return 0; +} + +static int GetVersion(void) +{ + return calltrap (0); +} +static int GetUaeConfig(struct UAE_CONFIG *a) +{ + return calltrap (1, a); +} +static int SetUaeConfig(struct UAE_CONFIG *a) +{ + return calltrap (2, a); +} +static int HardReset(void) +{ + return calltrap (3); +} +static int Reset(void) +{ + return calltrap (4); +} +static int EjectDisk(ULONG drive) +{ + return calltrap (5, "", drive); +} +static int InsertDisk(UBYTE *name, ULONG drive) +{ + return calltrap (5, name, drive); +} +static int EnableSound(void) +{ + return calltrap (6, 2); +} +static int DisableSound(void) +{ + return calltrap (6, 1); +} +static int EnableJoystick(void) +{ + return calltrap (7, 1); +} +static int DisableJoystick(void) +{ + return calltrap (7, 0); +} +static int SetFrameRate(ULONG rate) +{ + return calltrap (8, rate); +} +static int ChgCMemSize(ULONG mem) +{ + return calltrap (9, mem); +} +static int ChgSMemSize(ULONG mem) +{ + return calltrap (10, mem); +} +static int ChgFMemSize(ULONG mem) +{ + return calltrap (11, mem); +} +static int ChangeLanguage(ULONG lang) +{ + return calltrap (12, lang); +} +static int ExitEmu(void) +{ + return calltrap (13); +} +static int GetDisk(ULONG drive, UBYTE *name) +{ + return calltrap (14, drive, name); +} +static int DebugFunc(void) +{ + return calltrap (15); +} +static int ExecuteOnHost(UBYTE *name) +{ + return calltrap (88, name); +} \ No newline at end of file